I'm trying to insert a record into my Database. I keep hitting an error...I've been stalled for the past two hours.. I really hope it's not a typographical error, but I also hope it is.. Checking similar SO answers, I don't have connection problems, I don't appear to be using any reserved keywords, I have all permissions, and the table is definitely users:
$username = $mysqli->real_escape_string($_POST['username']);
$joinedOn = time();
$insertQuery = "INSERT INTO users ('username', 'joinedon') VALUES ('$username', $joinedOn);";
if ($mysqli->query($insertQuery)) {
echo "success!";
} else {
echo $mysqli->error;
echo '<br>';
}
Here's the error I'm getting:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''username', 'joinedon') VALUES ('dsf', 1483411360)' at line 1
Other useful information:
Table: users
Columns (3): id INT(11) autoincrement , username VARCHAR(20) , joinedon INT(11)
The other weird thing is, the joinedon
field is of type INT(11)
however, inserting directly from PHPMyAdmin, I am able to insert a strings containing only numbers.