| | |
Need help with the syntax problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2006
Posts: 14
Reputation:
Solved Threads: 0
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
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
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]
[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]
![]() |
Similar Threads
- Syntax problem! (PHP)
- Insert Into Syntax Problem (MS SQL)
- asp redirect help I think it is a syntax issue (Legacy and Other Languages)
- amigious problem with fstream (C++)
- Using Assembly Codes in Bloodshed Dev-CPP (C)
- Problem with moving integers to a single formatted string (C)
Other Threads in the PHP Forum
- Previous Thread: Looking for A vbulletin Coder
- Next Thread: Need help in create file php
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





