I have an insert into statement that runs that doesn’t insert data into database, but there are no errors that show me where the insert into statement fails. I looked all over for a similar problem but I couldn’t find anything with my particular problem. Everybody else insert into statement that fails show errors. I would appreciate if someone else could look at my code and perhaps see something that I’m missing.
Yes, and that is what I did not see in the video. And it is what you are having problems with.
In other words, because you are echo-ing something that does not exist, you should be echo-ing something that does (might) exist. At least while you’re working up the code. For production use you should take out all of the developer “show me” stuff.
Right under $stmt->execute();
I tried that with if(!$stmt){
echo “Connection failed”;
}
The app ran and redirected to home.php but didn’t show an errors. What do you mean by developer “show me” stuff?
I even tried under $stmt->execute();
if (!$stmt) {
echo “\nPDO::errorInfo():\n”;
print_r($dbh->errorInfo());
}
The code ran, redirected to home.php without an error. When I check the database there was nothing inserted.
If you have a “output this to the current page then go to a different page” you’ll have to look quick to see it.
By “developer show me stuff” I mean information that comes in useful while developing but should not be shown to site visitors. Logging is much better.
You could try this to avooid the redirect from happening.
What I meant by redirect is that the page was redirected to the header("location: home.php); There is a select statement in home.php that show the data on the home page in the browser that I put in the database in xampp;The select statement works.
Why are there single-quotes around the variable name? And presumably you’re setting the value of $password somewhere in your code that isn’t shown above, as you’re also using the same variable to connect to the database.