php เขียนใน raspberry pi มี error ขึ้นว่า PHP Fatal error: Call to undefined method mysqli_stmt::get_result() in /var/www/html/edit.php on line 25, referer:
ผมต้องการดึงข้อมูลในฐานข้อมูลมาแสดงในฟอร์ม เพื่อแก้ไข ประกอบด้วย php และ html ในlogมันขึ้น error PHP Fatal error: Call to undefined method mysqli_stmt::get_result() in /var/www/html/edit.php on line 25, referer: ส่วนหน้าเว็บขึ้น ข้อผิดพลาดของเซิร์ฟเวอร์ 500
1.PHP
Code (PHP)
<?php
include "connect.php";
$id = $_GET["id"];
$sql=" SELECT UserID, UID, UPASS, Name, Surename
FROM tb_user
WHERE UserID = ?";
$qr = $con->prepare($sql);
if($qr === false){
trigger_error("Worng SQL : ".$SQL."Error : ".$con->error, E_USER_ERROR);
}
$qr->bind_param("i", $id);
$qr->execute();
$rs = $qr->get_result();
$rs->mysqli_fetch_all();
foreach($rs as $el);
?>
2.HTML
Code
<!DOCTYPE HTML>
<html>
<head>
<title>edit</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/jquery-1.11.3.min.js" type="text/javascript" ></script>
<script src="js/bootstrap.min.js" type="text/javascript" ></script>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<script src="js/jquery.form-validator.min.js" type="text/javascript" ></script>
<script src="js/security.js" type="text/javascript" ></script>
<script src="js/file.js" type="text/javascript" ></script>
<link href="css/theme-default.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function get_edit(){
$("#txt_uid").val(<?php echo $el["UID"]; ?>);
$("#txt_upass").val(<?php echo $el["UPASS"]; ?>);
$("#txt_name").val(<?php echo $el["Name"]; ?>);
$("#txt_surename").val(<?php echo $el["Surename"]; ?>);
}
</script>
<style type="text/css">
body {
background: url(img/bg1.jpg) no-repeat center center fixed;
background-size: cover;
}
</style>
</head>
<body onload="get_edit()">
<form name="myform" action="process_edit.php" method="post" role="form">
<div class="form-group">
<label for="txt_uid">User</label>
<input type="text" name="txt_uid" id="txt_uid" class="form-control" value="" placeholder="User" data-validation="length" data-validation-length="min8" >
</div>
<div class="form-group">
<label for="txt_upass">Password</label>
<input type="password" name="txt_upass" id="txt_upass" class="form-control" placeholder="Password" value="" data-validation="length" data-validation-length="min8">
</div>
<div class="form-group">
<label for="txt_name">Name</label>
<input type="text" name="txt_name" id="txt_name" class="form-control" value="" placeholder="Name">
</div>
<div class="form-group">
<label for="txt_surename">Surename</label>
<input type="text" name="txt_surename" id="txt_surename" class="form-control" value="" placeholder="Surename">
</div>
<input type="submit" name="btn_submit" id="btn_submit" value="..save" class="btn btn-primary">
</form>
</body>
</html>
อันนี้ไฟล์เชื่อม data base
Code
<?php
$config = array(
"host"=>"localhost",
"user"=>"root",
"pass"=>"1234",
"dbname"=>"Light_Project",
"charset"=>"utf8"
);
$con = new mysqli($config["host"],$config["user"],$config["pass"],$config["dbname"]);
$con->set_charset($config["charset"]);
if($con->connect_error){
trigger_error("Database Connect failed".$con->connect_error, E_USER_ERROR);
}
else{
}
?>
Tag : PHP, MySQL, HTML/CSS, jQuery, Windows
Date :
2015-10-25 20:34:41
By :
kuadmaster
View :
1569
Reply :
5
Code (PHP)
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$serverName = "localhost";
$userName = "root";
$userPassword = "root";
$dbName = "mydatabase";
$conn = new mysqli($serverName,$userName,$userPassword,$dbName);
$strCountryCode = "US";
$sql = "SELECT * FROM customer WHERE CountryCode = ? ";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $strCountryCode); // s - string, b - blob, i - int, etc
$stmt ->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc())
{
echo $row["CustomerID"]."<br>";
echo $row["Name"]."<br>";
echo $row["Email"]."<br>";
echo $row["CountryCode"]."<br>";
echo $row["Budget"]."<br>";
echo $row["Used"]."<br>";
echo "<hr>";
}
$conn->close();
?>
มีอะไรต่างไหม๊ครับ
Date :
2015-10-25 21:04:17
By :
mr.win
Code (PHP)
$stmt = $con->stmt_init();
$stmt->prepare($sql)
Date :
2015-10-26 08:25:25
By :
mr.v
Date :
2016-01-15 09:35:11
By :
mr.win
Load balance : Server 04