Php SQL return value

Source: Internet
Author: User
Php execution of SQL return value problem,
ID is returned when the query is executed successfully. the query statement is correct. for example, the queried ID does not exist, but it is null. what is returned? What is returned when a query error occurs?
After the modification is executed, what is returned successfully, and the modification statement is correct, but what is returned if the modification is null? What is returned when a modification error occurs?
When the execution increases, what is returned successfully, and what is returned when an error is added?
After the deletion is executed, what is returned successfully? the deletion statement is correct, but the deletion is empty. what is returned? What is returned when a deletion error occurs?


Reply to discussion (solution)

You can query it yourself!
Var_dump (output the queried variable)
You can see it!

Echo 'Your SQL statement ';

You can add

Die ("execution failed, error row number". _ LINE _. "error cause". mysql_error ());


If you are not sure, you can execute the command before executing the mysql_query () query.
echo  $sql; exit()
In this way, the SQL statement is displayed and exited. Then you can check the SQL statement mosaic error, and then you can directly execute this statement on the mysql client, such as the command line ....


Generally, if ($ res), a result set is returned for executing the sleect query.
You can call mysql_affected_rows () to add, delete, and modify data. if-1 is returned, the execution fails.

Boolean values: NULL, false, 0, "", all represent false,

Mysql_query returns a Resource identifier for SELECT, SHOW, EXPLAIN, or DESCRIBE statements. the output is a string similar to "Resource id #3", so it is true.

This "Resource id #3" is like a indicator that connects the data you want to operate. when you use a function to operate on the data, for example, mysql_fetch_array ($ insert ), then he takes the result from the database to the function for parameters.

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.