Connecting Tech Pros Worldwide Help | Site Map

syntax error, unexpected T_VARIABLE

  #1  
Old September 5th, 2008, 10:05 PM
stanman
Guest
 
Posts: n/a
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
  #2  
Old September 5th, 2008, 10:15 PM
Captain Paralytic
Guest
 
Posts: n/a

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.
  #3  
Old September 6th, 2008, 12:05 AM
FutureShock
Guest
 
Posts: n/a

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
  #4  
Old September 8th, 2008, 03:35 AM
AqD
Guest
 
Posts: n/a

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
  #5  
Old September 8th, 2008, 04:15 AM
Jerry Stuckle
Guest
 
Posts: n/a

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
==================

  #6  
Old September 8th, 2008, 11:25 AM
Curtis
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parse error: syntax error, unexpected T_VARIABLE URmusicandvideo answers 25 October 31st, 2008 07:23 AM
Parse error: syntax error, unexpected T_VARIABLE james2432 answers 1 July 31st, 2008 11:05 PM
dont know how to get rid of syntax error, unexpected T_VARIABLE ashraf02 answers 7 February 25th, 2008 11:53 PM
Parse error: syntax error, unexpected T_VARIABLE on line 4 needhelp08 answers 4 December 25th, 2007 05:38 AM
Parse error: syntax error, unexpected T_VARIABLE SilvaZodiac answers 3 December 2nd, 2007 10:27 AM