Over the past few weeks I've been working on a website for my indie game development group, and I'm stuck on database I've built for displaying news feeds.
Essentially, I have PHP echoing out a news update, user name and date, all of which are stored in our database. It display fine, there is not problem with this part.
I have a hidden admin page which lets [admins] update add entries to the news database via a form. There are three fields which send the user name, date and actual update to a table in the database. Should be pretty simple, right? Wrong, apparently. For me anyways.
I get the following error when I submit the update form:
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 ''name' , 'date' , 'newsupdate' ) ' at line 1
Here is my code:
<?php
$con=mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect:'. mysql_error());
}
mysql_select_db("rlinewsfeed", $con);
$name = mysql_real_escape_string($_POST['name']);
$date = mysql_real_escape_string($_POST['date']);
$newsupdate = mysql_real_escape_string($_POST['newsupdate']);
mysql_query("INSERT INTO newsfeed ( 'name' ,
'date' ,
'newsupdate'
)
VALUES ( '$name',
'$date',
'$newsupdate',
);") or die(mysql_error());
mysql_close($con);
?>
Any help I could get resolving the problem would be hugely appreciated. I asked a friend to check out the code and he couldn't find a problem either. I would like to get this done by next Wednesday, since that's when I start classes up again I wont have much time to finish the site. :bemused:
P.S. Incidentally, where I quoted "name" in the error report above, it should be "Someone's name". I think the comma messed it up, but I'm not positive. It seems like something that would be pretty common, is this the case?
Thanks in advance!