Answer the question
In order to leave comments, you need to log in
How to check the success of a write in mysql?
How can I check the success of writing data to mysql?
Well, for example, if you mix up the name of the database, then the skul will not return errors, but simply will not execute the request in silence ....
mysql_query("INSERT INTO goods (name, sum, ..........
if(error_mysql != что то там) {
что то сделать если ошибка записи...
}
Answer the question
In order to leave comments, you need to log in
Check return value with mysql_query function
$res = mysql_query(...)
if ($res === FALSE) {
die( mysql_error() );
}
For SELECT, SHOW, DESCRIBE, EXPLAIN, and other queries that return a result from multiple rows, mysql_query() returns a handle to the result of the query (resource), or FALSE on error.
For other types of SQL queries, INSERT, UPDATE, DELETE, DROP, and others, mysql_query() returns TRUE on success and FALSE on error.
The resulting result descriptor must be passed to the mysql_fetch_assoc() function or any other function that works with query results.
Use mysql_num_rows() to find out the number of rows resulting from a SELECT query, or mysql_affected_rows() to find out the number of rows processed by DELETE, INSERT, REPLACE, and UPDATE queries.
mysql_query() will also fail and return FALSE if the user does not have access to any of the tables in the query.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question