943,949 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1476
  • PHP RSS
Mar 27th, 2006
0

Need help with the syntax problem

Expand Post »
Hi guys,

A problem occured when i tried to run the php file. The error was;

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\)' at line 1

Plz guys help me to figure out the problem. I've tried many ways, and it seems none of it worked.This is the query;

$query ="SELECT * FROM $SQL_COUNTTABLE WHERE (SC_REFERENCE LIKE \"$REFERENCE\") AND (SC_NAME LIKE \"$COUNTERNAME\") AND (SC_SINCE = \$DELOLDTIME\)";

Hopefully you guys can help me. Thanks in advanced
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chaom79 is offline Offline
14 posts
since Mar 2006
Mar 27th, 2006
0

Re: Need help with the syntax problem

You must wrap string literals within single quotes. You also have some extraneous parenthesis in your query. Try this:

[PHP]$query ="SELECT *"
." FROM ".$SQL_COUNTTABLE
." WHERE SC_REFERENCE LIKE '".$REFERENCE."'"
." AND SC_NAME LIKE '".$COUNTERNAME."'"
." AND SC_SINCE = '".$DELOLDTIME."'";[/PHP]

This query should execute--assuming those are legitimate column names and the variables contain valid values. However, if you really want to do "LIKE", you normally want to surround the value with percent signs. Percent signs are ANSI SQL wildcards.

[PHP]$query ="SELECT *"
." FROM ".$SQL_COUNTTABLE
." WHERE SC_REFERENCE LIKE '%".$REFERENCE."%'"
." AND SC_NAME LIKE '%".$COUNTERNAME."%'"
." AND SC_SINCE = '".$DELOLDTIME."'";[/PHP]
Reputation Points: 36
Solved Threads: 6
Posting Whiz
Troy is offline Offline
354 posts
since Jun 2005
Mar 28th, 2006
0

Re: Need help with the syntax problem

Thank you so much Troy. You really helped me solved the problem. Thanks again!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chaom79 is offline Offline
14 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Looking for A vbulletin Coder
Next Thread in PHP Forum Timeline: Need help in create file php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC