php failed to add data to mysql
Case code:
$sql1="insert into content(category,subject,content,username,release_date) values('{$category}','{ $subject}','{$content}','{$user}','{$date}')"; //向数据表中插入数据的操作 $res1=dml($sql1);
Error reason:
(1) Check whether the spelling of each field in the data table is correct;
(2) Check the value of the inserted variable, use the statement var_dump($xxx) to check whether the variable value format and value are correct Correct;
(3) Check the NULL field of the data table and use the command desc table_name. When one or more field attributes are not null but no data is inserted, an insertion data error will occur. (This is the reason for the error in this case)
(4) Print the sql statement, copy it to phpMyAdmin for execution, and check whether it is successful.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of PHP fails to add data to mysql. For more information, please follow other related articles on the PHP Chinese website!