I am relatively new to MySQL and PHP and I have been trying to UPDATE a table for a very long time now, I've searched Google and SO and I still can't figure it out.
Here is the php:
$info = array('about_me' => NULL, 'profile_pic' => NULL, 'political_party' => NULL, 'econ_views' => NULL, 'religious_views' => NULL,
'abortion_view' =>NULL,'gay_marraige' => NULL, 'other' => NULL);
foreach ($_POST as $key => $value) {
$info[$key] = mysql_escape_string($value);
}
$about_me = $info['about_me'];
$profile_pic = $info['profile_pic'];
$econ_views = $info['econ_views'];
$religious_views = $info['religious_views'];
$abortion_view = $info['abortion_view'];
$gay_marraige = $info['gay_marraige'];
$other = $info['other'];
$political_party = $info['political_party'];
//Connect to database
require 'db.php';
$query = "UPDATE `users` SET `about_me`=$about_me, `profile_pic`=$profile_pic, `econ_views`=$econ_views,
`religious_views`=$religious_views,`abortion_view`=$abortion_view,`gay_marriage`=$gay_marraige,
`other`=$other, `political_party`=$political_party WHERE `username`=emoore24";
echo "$query"."<br /><br />";
$result = mysql_query($query) or die(mysql_error());
echo "success"
This is run on a form with many text areas and one select element. I ran everything with simple strings as data and got this:
UPDATE
users
SETabout_me
=test about,profile_pic
=,econ_views
=test econ,religious_views
=test rel,abortion_view
=test abortion,gay_marriage
=test gay marraige,other
=test other,political_party
=democrat WHEREusername
=emoore24You have an error in your SQL syntax; check the manual that corresponds to your MySQL >server version for the right syntax to use near '
econ_views
=test econ, >religious_views
=test rel,abortion_view
=test abor' at line 1
I'm assuming that it's something small, but I can't see it. Could anyone help?