Self-Study-beg you for questions about the database $ link = mysql_connect ('2017. 0.0.1: 100', 'root', '123 ');
If (! $ Link ){
Die ('could not connect: '. mysql_error ());
}
Mysql_select_db ("stu") or die (mysql_error ());
Mysql_query ("set name UTF-8 ");
$ Name = $ _ POST ['name'];
$ Age = $ _ POST ['age'];
$ Aihao = $ _ POST ['aihao'];
$ SQL = "insert into student (u_name, u_age, u_xq) value ('$ name',' $ age', '$ aihao ')";
$ Res = mysql_query ($ SQL, $ link) or die (mysql_error ());
Mysql_free_result ($ res) or die (mysql_error ());
Mysql_close ($ link );
Echo "chenggong". $ res;
The above is the code why Warning: mysql_free_result (): supplied argument is not a valid MySQL result resource in F: \ PHPnow-1.5.6 \ htdocs \ stu \ addok. php on line 18
This problem
If the database connection is successful, you can print the SQL statement and execute it in the database. why is this always so wrong?
Reply to discussion (solution)
The database cannot be written. Only SQL statements can be printed and executed in the database.
Mysql_free_result () is called only when considering how much memory will be occupied when a large result set is returned. After the script is completed, all associated memory will be automatically released.
The insert command does not return the result set. Therefore, the release of the result set does not exist.
Potential problems:
1. mysql_query ("set name UTF-8 ");
MySQL only has utf8 and does not have UTF-8
2. $ SQL = "insert into student (u_name, u_age, u_xq) value ('$ name',' $ age', '$ aihao ')";
Only values does not have value
Thank you, bro.
I changed it. You still cannot write it in.
Insert into student (u_name, u_age, u_xq) values ('ee ', '22', '123 ')
Warning: mysql_free_result (): supplied argument is not a valid MySQL result resource in F: \ PHPnow-1.5.6 \ htdocs \ stu \ addok. php on line 20
Is it a problem with database restart or installation configuration?
Again!
Executing the insert (update, delete, etc.) command only returns the logical value to indicate whether the execution is successful.
No result set is returned, so it is not released.
Thank you!
Free has already cleared the result set and can be called again .. Can this problem be avoided ..