MySQL Forums
Forum List  »  PHP

SQL error in inserting table values from PHP using localhost
Posted by: Michael Macgowan
Date: March 13, 2021 09:37PM

I am following a great tutorial on using PHP to access the MYSQL 8.0 server that I have installed on my Windows machine. I am registering names and passwords in my mysqltutorial schema. The workbench connection works fine. The first part of the code correctly identifies users already in the database. The second time I run the prepared statement my php page branches to the SQL error and exits the code without writing the user's name and hashed password to the users table.

I tried uninstalling and reinstalling the server and workbench. I tried to find anything in the log files that would help explain the issues and I eliminated all the users and I still get the error. I have also tried rebooting my local machine. I am running localhost for my PHP server and MySQL in development mode.

Here is the code that is branching to the SQL error

$sql = "INSERT INTO (name, password) VALUES (? , ?)";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header ("location: ../register.php?error=SQLerror" . $username);
exit();

Options: ReplyQuote


Subject
Written By
Posted
SQL error in inserting table values from PHP using localhost
March 13, 2021 09:37PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.