Forum Moderators: coopster

Message Too Old, No Replies

update multiple fields in mysql (strange error)

         

xpiamchris

7:18 pm on Jan 22, 2009 (gmt 0)

10+ Year Member



So I'm not sure why I'm getting this message:

Invalid query: 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 '' at line 1 Whole query: SELECT * FROM albums WHERE albumid=

The strange thing is that for a SPLIT second I can see that it was successful and it updates the information, but then it changes to the invalid query message.

Here is the code behind it:

if ($_POST['editinformation'])

{


$albumname=($_POST['albumname']);
$artistname=($_POST['artistname']);
$dateadd=($_POST['dateadd']);
$genre=($_POST['genre']);
$oreleasedate=($_POST['oreleasedate']);
$dreleasedate=($_POST['dreleasedate']);
$labelname=($_POST['labelname']);
$upc=($_POST['upc']);
$recordlocation=($_POST['recordlocation']);

$query = "UPDATE albums SET albumname='$albumname', artistname='$artistname', genre='$genre', oreleasedate='$oreleasedate', dreleasedate='$dreleasedate', labelname='$labelname', upc='$upc', recordlocation='$recordlocation' WHERE albumid='$album'";


$result = mysql_query($query);
if ($result)
{ echo $query; }

else if (!$result)
{
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);

}

}

And I know it was successful through the first runthrough because when i go to a seperate page taht pulls the information, i receive the updated information

andrewsmd

8:13 pm on Jan 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try setting all of your $ variables to this
UPDATE albus SET albumname = '{$albumname}', genre = '{$genre}' etc.