By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

syntax error, unexpected T_VARIABLE

P: 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
Sep 5 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Sep 5, 10:02*pm, stanman <GStanle...@gmail.comwrote:
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.
Sep 5 '08 #2

P: n/a
stanman wrote:
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
Sep 5 '08 #3

P: n/a
AqD
stanman wrote:
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
Sep 8 '08 #4

P: n/a
AqD wrote:
stanman wrote:
>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.
js*******@attglobal.net
==================

Sep 8 '08 #5

P: n/a
AqD wrote:
stanman wrote:
>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.
If you're using PHP5, you can use parameterized queries in mysqli or
PDO
--
Curtis
Sep 8 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.