Home  >  Article  >  Backend Development  >  What to do if php cannot add data

What to do if php cannot add data

藏色散人
藏色散人Original
2022-11-01 09:21:311787browse

Solution to the problem that php cannot add data: 1. Open the corresponding php file; 2. Check the "mysqli_query" statement; 3. Change the sentence "if (mysqli_query($conn, $a))" to Just "if($a)".

What to do if php cannot add data

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if php cannot add data?

Problem description:

The database can be connected successfully, but PHP cannot insert data. Can anyone check if there is a problem with the code? ?

" . mysqli_error($conn);
}
mysqli_close($conn);
}
?>

Problem solution:

$a=mysqli_query($conn,"INSERT INTO student.plus1 (用户名, 密码, 性别, 学历) VALUES ('$x','$y','$Z','$O')");

This sentence means that the insert statement has been executed. Mysqli_query executes the query statement and returns the object. If the insert statement is successfully executed, true will be returned.

if (mysqli_query($conn, $a)) Just change this sentence to if ($a).

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if php cannot add data. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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