Need help with the syntax problem

Reply

Join Date: Mar 2006
Posts: 14
Reputation: chaom79 is an unknown quantity at this point 
Solved Threads: 0
chaom79 chaom79 is offline Offline
Newbie Poster

Need help with the syntax problem

 
0
  #1
Mar 27th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Need help with the syntax problem

 
0
  #2
Mar 27th, 2006
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]
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 14
Reputation: chaom79 is an unknown quantity at this point 
Solved Threads: 0
chaom79 chaom79 is offline Offline
Newbie Poster

Re: Need help with the syntax problem

 
0
  #3
Mar 28th, 2006
Thank you so much Troy. You really helped me solved the problem. Thanks again!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC