The way I execute the INSERT statement is
function Execute_data ($sql) {$result = @mysql_query ($sql) or Die (Mysql_error ()), @mysql_free_result ($result) or Die ( Mysql_error ()); return $result;}
$sql = "INSERT into test (name) VALUES (' $name ')"; if (Execute_data ($sql)) { echo ' OK ';}
In this way, I have executed the INSERT statement so that it has been inserted into the database table, but ECHO has not been exported to the Web page. What's the reason?
echo can be output to a Web page by executing the query statement in a different way.
Methods for executing query statements
function Get_js_array ($sql) {$result = @mysql_query ($sql) or Die (Mysql_error ()), $arr = Array (), while ($row = @mysql_fetch _array ($result, Mysql_assoc)) {$arr [] = $row; } $js = Json_encode ($arr); Mysql_free_result ($result); return $js;}
Reply to discussion (solution)
The return value of the function Execute_data $result was freed by the function mysql_free_result and returned is null.
Print out the $result to see if it's fake.
Print out the $result to see if it's fake.
It's not a lie. I've all succeeded in inserting. Just the echo output does not come out.
Mysql_free_result
You've been released, and you've returned?
mysql_query ($sql) returns only logical values for insert Directives
therefore Mysql_free_result ($result) will error: $result is not a valid resource
But you blocked the PHP error message, and Die (Mysql_error ()) just terminates the program because the SQL command is not wrong (mysql_error () returns an empty string)
mysql_query ($sql) returns only logical values for insert Directives
therefore Mysql_free_result ($result) will error: $result is not a valid resource
But you blocked the PHP error message, and Die (Mysql_error ()) just terminates the program because the SQL command is not wrong (mysql_error () returns an empty string)
So what can I do to get him out of the way?
Comment out @mysql_free_result ($result) or Die (Mysql_error ()); This sentence
Comment out @mysql_free_result ($result) or Die (Mysql_error ()); This sentence
Thanks, it's settled!