PHP connection MySQL database execution SQL statement no results! Begging for rescue

Source: Internet
Author: User
Rookie first contact with the MySQL database connection operation, imitate the book wrote the following code, found that can connect to the database, but the SQL statement is always not executed, the SQL statement is not a problem, in the phpMyAdmin can be executed successfully, but here is not, Ask the great God to rescue and see where the problem is.
    


Reply to discussion (solution)

What's wrong with the report?

What does the program output?

The program did not error, but the database did not insert successfully

What's wrong with the report?

Output error plus empty string

What does the program output?

Haha big God embarrassed, is I made a black dragon, my MySQL database does not give this user rights, so can not modify the database, after the permission is good, thank God

What does the program output?

!--? php $host = "localhost";    $userName = "Cheng";    $password = "11111111";    $dbName = "Db_student";    $connID =mysqli_connect ($host, $userName, $password, $dbName);        Mysqli_query ($connID, "Set names GBK");    $query =mysqli_query ($connID, "Select Sno,sname,class,chinese,math,english from Tb_student"); $result =mysqli_query ($connID, "INSERT into Tb_student (Sno, Sname, class, Chinese, Math, 中文版) VALUES (' 012531 ', ' SBSB '    , ' 12ji ', ' 70 ', ' 70 ', ' 70 ');    if ($result) {echo "OK";}    Else die (' Error: '. mysql_error ());  Mysqli_close ($connID);   
You try it this way

if ($result) {echo "OK";}
Else Die (' Error: '. Mysqli_error ());
Mysqli_close ($connID);

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