| | |
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 |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube





