PHP Novice Help to see why the while inside the non-implementation Thank you

Source: Internet
Author: User
Here's My Code:
$conn =mysql_connect ("localhost", "root", "");
if (! $conn)
Die ("Could Not Connect:". Mysql_error ());
if (!mysql_select_db ("User2", $conn))
echo "Failed to connect to database";
mysql_query ("Set names UTF8", $conn);
mysql_query ("CREATE TABLE table1 (
ID int PRIMARY KEY NOT NULL auto_increment,
Name varchar (+) is not NULL,
Email varchar (+) NOT NULL,
Age int ()) ", $conn);
mysql_query ("INSERT INTO table1 (name,email,age)
VALUES (' Sun ', 12345@emial.com,19), $conn);
echo "Hello world!
";
$result =mysql_query ("SELECT * FROM table1", $conn);
while ($row =mysql_fetch_row ($result))
{
/* echo Var_dump ($row). "
";
echo "
". Var_dump ($row)."
";*/
echo "
$row [0]--$row [1]--$row [2];
foreach ($row as $value)
{
echo "-$value";
}
echo "
";
}
echo "Hello";
Mysql_free_result ($result);
Mysql_close ();
?>

Results:


Reply to discussion (solution)

Check if there's any data in the Table1.

The above code is not added, I can not query through the client
The result of my client query is only one database Information_schema but the Data folder has a database created by PHP.

Under the command line, see if the table exists and see if there is data in the table.

Insert INTO table1 (name,email,age)
VALUES (' Sun ', 12345@emial.com,19)
Don't need to use the citation number?

mysql_query ("INSERT INTO table1 (name,email,age)
VALUES (' Sun ', 12345@emial.com,19), $conn);

There is no success in inserting it.

mysql_query ("INSERT INTO table1 (name,email,age)
VALUES (' Sun ', 12345@emial.com,19), $conn);

There is no success in inserting it.

mysql_query ("INSERT INTO table1 (name,email,age)
VALUES (' Sun ', 12345@emial.com,19), $conn) or Die (Mysql_error ());

Under the command line, see if the table exists and see if there is data in the table.








Why are the two shows different (and don't know if you can see this reply)

Without creating a database, look with the navicate MySQL software.

Without creating a database, look with the navicate MySQL software.




The problem is solved, I want to ask the question of the 9 floor can solve?

What user are you logged in with?

What user are you logged in with?





This is not landing ah is in MySQL bin folder under a mysql.exe and then show databases out of

You are logged in to MySQL with the current Windows user, so you only see the database you can see.
Run: Mysql.exe with--user=root--password= ... You can see all the databases.





Thank you so much!

You are logged in to MySQL with the current Windows user, so you only see the database you can see.
Run: Mysql.exe with--user=root--password= ... You can see all the databases.

  • 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.