MadCatter101
Programmer
Hey all. I'm trying to write the code for a web site that updates users short stories etc. onto a database. The only page that I have even vaguely working right now is the "submit" page. After finally debugging the code (or so I thought), I still keep receiving the following error message:
1064: You have an error in your SQL syntax near ' ‘, ‘, '16.11.2002 10:16', ‘)' at line 2
Now, Line 2 of the code for the page (submit.php) is merely my <head> tag. My question: What am I doing wrong here? The relevant lines of my php code looks like such: (the data here is requested from a form, except for "date", which is requested using: $time = time();
$date = strftime("%d.%m.%Y %H:%M" )
if ($enter_data) {
// build query string
$insert = "INSERT INTO stories (authorname, title, authoremail, date, story)
VALUES(‘$authorname’, ‘$title’, ‘$email’, '$date', ‘$story’)";
// execute a query and store the result
$res = mysql_query($insert,$dbh);
// check to make sure the query actually ran
if (!$res) {
echo mysql_errno().": ".mysql_error ()."";
return 0;
}
I've noticed that in the error message, theres a "' ," for every entry there--and the third blank area is, not surprisingly, the timestamped date. What am I doing wrong here? Thanks in advance for reading this and I hope you guys can help me. --MadCatter101--
1064: You have an error in your SQL syntax near ' ‘, ‘, '16.11.2002 10:16', ‘)' at line 2
Now, Line 2 of the code for the page (submit.php) is merely my <head> tag. My question: What am I doing wrong here? The relevant lines of my php code looks like such: (the data here is requested from a form, except for "date", which is requested using: $time = time();
$date = strftime("%d.%m.%Y %H:%M" )
if ($enter_data) {
// build query string
$insert = "INSERT INTO stories (authorname, title, authoremail, date, story)
VALUES(‘$authorname’, ‘$title’, ‘$email’, '$date', ‘$story’)";
// execute a query and store the result
$res = mysql_query($insert,$dbh);
// check to make sure the query actually ran
if (!$res) {
echo mysql_errno().": ".mysql_error ()."";
return 0;
}
I've noticed that in the error message, theres a "' ," for every entry there--and the third blank area is, not surprisingly, the timestamped date. What am I doing wrong here? Thanks in advance for reading this and I hope you guys can help me. --MadCatter101--