Click to See Complete Forum and Search --> : Unexpected T_STRING


chesemonkyloma
08-31-2006, 05:49 PM
I did just post a question but now I'm having a problem with one of my other scripts. I keep getting this error "unexpected T_STRING". Here's my script:


<?php
$link = mysql_connect("localhost","username","password");
if (!$link)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("newsletter", $link);

mysql_query(UPDATE Members
SET Confirm = 'TRUE'
WHERE ID='$id'
)or die(mysql_error());

echo "Your subscription to the Newsletter has been confirmed";
?>

NogDog
08-31-2006, 05:58 PM
mysql_query("UPDATE Members
SET Confirm = 'TRUE'
WHERE ID='$id'"
)or die(mysql_error());

chestertb
08-31-2006, 05:58 PM
Three errors...
First, your query needs to be wrapped in quotes.
Second, you have no closing bracket at the end of the line query function.
Third, you have no terminating ; at the end of the line.

It should read as follows...

mysql_query("UPDATE Members
SET Confirm = 'TRUE'
WHERE ID = ID='$id'");

For what it's worth, I put my query into a variable first. It makes it easier to debug. Something like this...


$query = "UPDATE Members
SET Confirm = 'TRUE'
WHERE ID = ID='$id'";
mysql_query($query);

CTB

chestertb
08-31-2006, 06:00 PM
Ok. four errors..

WHERE ID = '$ID'

chesemonkyloma
08-31-2006, 06:09 PM
yeah, after i submitted my post i quickly fixed the obvious ones, the one that wasnt as obvious to me was the quotes thing. Thanks for the help!