PHP script not writing data to mysql tableGet the solution ↓↓↓
Your main problem:
$STH instead of
To fix this:
$STH = ...to
$sql = ...
$count = $DBH->exec($sql);to
$count = $DBH->exec($STH);
I'd recommend the first one.
Also, you should really consider using prepared statements to prevent SQL injection.
$STH = "INSERT INTO 'users' ('name', 'password', 'email' )" . "VALUES ('$varName', '$varPass', '$varMail')";
This results in:
INSERT INTO 'users' ('name', 'password', 'email' )VALUES ('$varName', '$varPass', '$varMail')
There are a couple of other things wrong with this:
- There's no space between
- The column names have quotes around them instead of backticks
- There's really no point in that string concatenation, just put it all in one string.
The fix: (edited)
$sql = "INSERT INTO users (name, password, email) VALUES ('$varName', '$varPass', '$varMail')";
Share solution ↓
Link To Answer People are also looking for solutions of the problem: a non-numeric value encountered
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.