Help: Mysql_fetch_row (): supplied argument is not a valid MySQL result resource

Source: Internet
Author: User
Mysql_fetch_row


function Db_connect ()
{
$result = new mysqli (' localhost ', ' root ', ' 654321 ', ' smsprj ');
$result = new mysqli (' localhost ', ' root ', ' 654321 ');
if (! $result)
{
throw new Exception (' Could not connect to database server ');
}
Else
{

return $result;
}
}

?>

$conn = Db_connect ();
$sql = $conn->query ("SELECT * from user");

if (! $sql)
{
Echo ("wrong");
}
Else
{
echo "









Reply to discussion (solution)

That's what happens in Db_connect.
$result = new mysqli (' localhost ', ' root ', ' 654321 ', ' smsprj ');

So to query this
$sql = $conn->query ("SELECT * from user");

To read this way
while ($row = $sql->fetch_row ())

Thank you very much, go to the company tomorrow to try.
have been arranged to do not work at all, it really makes people egg pain AH

Thank you very much, go to the company tomorrow to try.
have been arranged to do not work at all, it really makes people egg pain AH

Thank you very much, go to the company tomorrow to try.
have been arranged to do not work at all, it really makes people egg pain AH

  • "; echo " "; while ($row = Mysql_fetch_row ($sql)) {echo " "; }} My goal is to display all the user information in the database, but this program always error, do not know what the reason for the help of the hero, the younger brother greatly appreciated
    Userid Name Pssword Maxsmscount Maxuseday Leftday Leftsmscount
    $row [0] $row [1] $row [2] $row [3] $row [4] $row [5] $row [6]

    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.