Beginner questions. PHP read MySQL

Source: Internet
Author: User
Rookie questions. PHP reads MySQL.
Entry level rookie question:
Connection database Not responding

echo "Test MySQL";
@ $db =mysqli_connect (' 211.71.150.75 ', ' root ', ' 123 ', ' MySQL ');
echo "Test MYSQL1";
if (Mysqli_connect_errno ())
{
echo ' connection Error! ';
Exit
}
$query = "SELECT * from user";
$result = $db->query ($query);
$num _results= $result->num_rows;
echo ' results altogether '. $num _results ';
for ($i =0; $i < $num _results; $i + +)
{
$row = $result->fetch_assoc ();
Echo '

'. ($i + 1). '. Title: ';
}
?>
echo "Test test! ";
?>

Only output test MySQL, no other response.
Test MySQL under the command line, no problem.

Please advise, thank you first.

------Solution--------------------
It seems to be very irregular, some places do not read--#

If the database name is MySQL, there is a table user under it, which has the field name. You can write this:

PHP Code

Test MySQL

Results altogether $num

"; while ($row = Mysql_fetch_assoc ()) { echo "

$row [Name]

"; }? >
  • 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.