Connecting Tech Pros Worldwide Help | Site Map

syntax error, unexpected T_VARIABLE

stanman
Guest
 
Posts: n/a
#1: Sep 5 '08
I have been trying to get past this error all day. I am unable to
determine why I get syntax error from the following code:

//modify a record
$myDataID = mysql_query("UPDATE members SET first_name = $name_update
WHERE email = $targetEmail", $connectID);

Can someone tell me what is wrong with this.
Thank You
Gerald Stanley
Captain Paralytic
Guest
 
Posts: n/a
#2: Sep 5 '08

re: syntax error, unexpected T_VARIABLE


On Sep 5, 10:02*pm, stanman <GStanle...@gmail.comwrote:
Quote:
I have been trying to get past this error all day. I am unable to
determine why I get syntax error from the following code:
>
//modify a record
$myDataID = mysql_query("UPDATE members SET first_name = $name_update
WHERE email = $targetEmail", $connectID);
>
Can someone tell me what is wrong with this.
Thank You
Gerald Stanley
Please post a few lines before this and also the full error message.
FutureShock
Guest
 
Posts: n/a
#3: Sep 6 '08

re: syntax error, unexpected T_VARIABLE


stanman wrote:
Quote:
I have been trying to get past this error all day. I am unable to
determine why I get syntax error from the following code:
>
//modify a record
$myDataID = mysql_query("UPDATE members SET first_name = $name_update
WHERE email = $targetEmail", $connectID);
>
Can someone tell me what is wrong with this.
Thank You
Gerald Stanley
You may try:

$myDataID = mysql_query("UPDATE members SET first_name = '$name_update'
WHERE email = '$targetEmail'", $connectID);

scotty
AqD
Guest
 
Posts: n/a
#4: Sep 8 '08

re: syntax error, unexpected T_VARIABLE


stanman wrote:
Quote:
I have been trying to get past this error all day. I am unable to
determine why I get syntax error from the following code:
>
//modify a record
$myDataID = mysql_query("UPDATE members SET first_name = $name_update
WHERE email = $targetEmail", $connectID);
>
Can someone tell me what is wrong with this.
It's off-topic, but you should try to escape the string inputs, or
avoid combining inputs to query completely by using parameterized
queries.

A simple version is "UPDATE members SET first_name = '" .
mysql_escape_string($name_update) . "' WHERE email = '" .
mysql_escape_string($targetEmail) . "'"

You would also need to make sure the client encoding is correct.

If you're using PHP5, you can use parameterized queries in mysqli or
PDO
Jerry Stuckle
Guest
 
Posts: n/a
#5: Sep 8 '08

re: syntax error, unexpected T_VARIABLE


AqD wrote:
Quote:
stanman wrote:
Quote:
>I have been trying to get past this error all day. I am unable to
>determine why I get syntax error from the following code:
>>
>//modify a record
>$myDataID = mysql_query("UPDATE members SET first_name = $name_update
>WHERE email = $targetEmail", $connectID);
>>
>Can someone tell me what is wrong with this.
>
It's off-topic, but you should try to escape the string inputs, or
avoid combining inputs to query completely by using parameterized
queries.
>
A simple version is "UPDATE members SET first_name = '" .
mysql_escape_string($name_update) . "' WHERE email = '" .
mysql_escape_string($targetEmail) . "'"
>
You would also need to make sure the client encoding is correct.
>
If you're using PHP5, you can use parameterized queries in mysqli or
PDO
>
Properly constructed statements work quite well without parameterized
queries.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Curtis
Guest
 
Posts: n/a
#6: Sep 8 '08

re: syntax error, unexpected T_VARIABLE


AqD wrote:
Quote:
stanman wrote:
Quote:
>I have been trying to get past this error all day. I am unable to
>determine why I get syntax error from the following code:
>>
>//modify a record
>$myDataID = mysql_query("UPDATE members SET first_name = $name_update
>WHERE email = $targetEmail", $connectID);
>>
>Can someone tell me what is wrong with this.
>
It's off-topic, but you should try to escape the string inputs, or
avoid combining inputs to query completely by using parameterized
queries.
>
A simple version is "UPDATE members SET first_name = '" .
mysql_escape_string($name_update) . "' WHERE email = '" .
mysql_escape_string($targetEmail) . "'"
>
You would also need to make sure the client encoding is correct.
Use mysql_real_escape_string for this.
Quote:
If you're using PHP5, you can use parameterized queries in mysqli or
PDO
--
Curtis
Closed Thread