r/PHPhelp • • Oct 13 '19

INSERT INTO sql table not working.

Am I inserting rows into my table correctly? This doesn't work for some reason.

$conn->exec("INSERT INTO Questions_Table (ID, Question, Votes) VALUES ($num_rows, $submitted_question, 1)");
9 Upvotes

9 comments sorted by

View all comments

2

u/PopeInnocentXIV Oct 13 '19

Are $num_rows and $submitted_question properly quoted and escaped?

1

u/[deleted] Oct 13 '19

$num_rows is an int and $submitted_question is a string, so I think they would be properly quoted

1

u/PopeInnocentXIV Oct 13 '19

Echo out the statement and see if it looks correct.

Also get the error message from the database connection.