PHP precompilation queries always fetch no data solution

Source: Internet
Author: User
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?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.