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

Syntax error, unexpected t_variable.

P: 5
hi.i have got a problem.

error message:


Parse error: syntax error, unexpected T_VARIABLE in c:\wamp\www\dynamic2.php on line 12


for the line:

Expand|Select|Wrap|Line Numbers
  1. $result=mysql_query("select company from dynamic where id="$id) or  die(mysql_error()); 
if anyone help me,i will be greatful.
Nov 10 '08 #1
Share this Question
Share on Google+
6 Replies


Dormilich
Expert Mod 5K+
P: 8,639
syntax error in function argument
[PHP]// either
mysql_query("sql" . $var)
// or
mysql_query("sql $var")[/PHP]
don't forget to sanitize your input!

regards
Nov 11 '08 #2

nathj
Expert 100+
P: 938
1. Try using code tags next time
2. Try changing the code to:
Expand|Select|Wrap|Line Numbers
  1. $result=mysql_query("select company from dynamic where id=$id") or die(mysql_error()); 
  2.  
I have brought the variable inside the string.

Cheers
nathj
Nov 11 '08 #3

Markus
Expert 5K+
P: 6,050
Mushfiq, to date you have named every thread you have started Dynamic Link. This explains nothing of the problem in this thread. We expect you to provide a meaningful title as it helps others who are searching the forum with the same problem.

Please take note of this as I have already warned you for not using code tags (and you have failed to do so again).

Read Posting Guidelines.

Moderator.
Nov 11 '08 #4

P: 3
change the code to

$result=mysql_query("select company from dynamic where `id`="$id) or die(mysql_error());
Nov 11 '08 #5

Dormilich
Expert Mod 5K+
P: 8,639
@divyac this will result in the same error (for exactly the same reasons) plus the quotation marks are in the wrong place

*sigh*

for some basics on strings read this
Nov 11 '08 #6

Markus
Expert 5K+
P: 6,050
To all concerned it's called 'concatenation'.
Nov 11 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.