PHP precompilation queries always fetch no data
Include ('.. /db/mysqlconnect.php ');
$conn = new Mysqlconnect ();
$mysqli = $conn->getconnection ();
$sql = ' Select id, username, password from admin where id =? ';
$seach _id = 1;
Settype ($seach _id, "integer");
if ($stmt = $mysqli->prepare ($sql)) {
$stmt->bind_param (' i ', $seach _id);
$stmt->execute ();
$stmt->bind_result ($rs _id, $rs _name, $rs _password);
if ($stmt->fetch () = = NULL) {
echo ' no result ';
} else {
', $rs _id, $rs _name, $rs _password);
}
$stmt->close ();
$mysqli->close ();
}
SQL statement can query out the data, I use PHP non-precompiled statements ($result = $mysqli->query ($query);) can also query the record, that is, the above query code is always fetched out of the fetch data, My PHP version is php-5.2.5-x64, the environment is 64-bit Win7, have met friends or know can give analysis, I have been troubled for 2 days .... Thank you. PHP Prepare Fetch
Share to:
------Solution--------------------
The code doesn't look like a problem.
But if you copy your code directly, you can't pass the grammar check.
------Solution--------------------
http://www.php.net/manual/en/mysqli.prepare.php
------Solution--------------------
http://xiaobo-liu.iteye.com/blog/1288008
------Solution--------------------
Settype ($seach _id, "integer");
Can omit
------Solution--------------------
What output does not have? Are you sure you have entered if?