Home > Backend Development > PHP Problem > PHP fails to add data to mysql

PHP fails to add data to mysql

angryTom
Release: 2023-02-28 14:50:02
Original
4683 people have browsed it

PHP fails to add data to mysql

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template