| | |
Mysql statement is throwing error.. why?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
Hey guys..
I have been trying to debug this mysql statement for the past 2 hours.. here is the statement:
I just can't figure out why this won't work.. it throws the following error:
Its really a vague error.. so i can't tell.. Anyone else know whats wrong??
Thanks in advance,
-Brett
I have been trying to debug this mysql statement for the past 2 hours.. here is the statement:
PHP Syntax (Toggle Plain Text)
$sql1 = "SELECT * FROM cpmip WHERE adid='$a' and ip='$ip'"; $res1 = mysql_query($sql1) or die(mysql_error());
I just can't figure out why this won't work.. it throws the following error:
PHP Syntax (Toggle Plain Text)
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 '* FROM cpmip WHERE ip='127.0.0.1' and adid='6'' at line 1
Its really a vague error.. so i can't tell.. Anyone else know whats wrong??
Thanks in advance,
-Brett
Do you have more than one SQL query?
In an error, MySQL will echo the query, but in the error you posted the ip and adid values are swapped.
I can't see anything wrong with your code there.
In an error, MySQL will echo the query, but in the error you posted the ip and adid values are swapped.
I can't see anything wrong with your code there.
AJAX is not a programming language, scripting language or any other sort of language.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
It is acheived by using JavaScript http functions.
So, AJAX = JavaScript.
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
Yes, there are many queries in this particular file.. BUT none of them have the same syntax as this one.. This is the only line that has adid and ip in it. I have no clue why i am getting this error now.. its really annoying...
Does anyone see something wrong/know what can be happening???
Thanks for the suggestion!
Does anyone see something wrong/know what can be happening???
Thanks for the suggestion!
>I have been trying to debug this mysql statement for the past 2 hours.. here is the statement:
> it throws the following error:
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 '* FROM cpmip WHERE ip='127.0.0.1' and adid='6'' at line 1.
This error message is not belong to the select query you specified. Please post your complete code.
PHP Syntax (Toggle Plain Text)
$sql1 = "SELECT * FROM cpmip WHERE adid='$a' and ip='$ip'"; $res1 = mysql_query($sql1) or die(mysql_error());
> it throws the following error:
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 '* FROM cpmip WHERE ip='127.0.0.1' and adid='6'' at line 1.
This error message is not belong to the select query you specified. Please post your complete code.
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
After further investigation.. i looked at one of my functions and noticed it was actually in there.. however, this is still the same exact query except reversed... i don't see any errors with it.. do you??
Thanks in advance,
-Brett
PHP Syntax (Toggle Plain Text)
$sql = "SELECT * FROM cpmip WHERE ip='$ip' and adid='$a'"; $res = mysql_query($sql) or die(mysql_error());
Thanks in advance,
-Brett
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
Ok.. here is the full function where this query occurs. Sorry for not wanting to post the whole thing, i just don't feel comfortable with that lol.. anyways heres the code.
PHP Syntax (Toggle Plain Text)
function mcheckTime($ip,$a){ $myDb = new myDb; $myDb->connect(); $sql = "SELECT * FROM cpmip WHERE ip='$ip' and adid='$a'"; $res = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($res); $myDb->close(); $time = time(); if($time >= $row['time']){ $myDb->connect(); $sql1 = "DELETE * FROM cpmip WHERE ip='$ip' and adid='$a'"; $res1 = mysql_query($sql1) or die(mysql_error()); $myDb->close(); return true; }elseif($time < $row['time']){ return false; }}
Here is a problem:
$sql1 = "DELETE * FROM cpmip WHERE ip='$ip' and adid='$a'";
$sql1 = "DELETE * FROM cpmip WHERE ip='$ip' and adid='$a'";
PHP Syntax (Toggle Plain Text)
$sql1 = "DELETE FROM cpmip WHERE ip='$ip' and adid='$a'";
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
Thank you.. that fixed that problem!! Now i am just having one problem.. another syntax error i didn't notice. Here is the code for the few lines surrounding it and it is highlighted. Just the same check your syntax error.
PHP Syntax (Toggle Plain Text)
if($num<1){ $time = time() + (1 * 24 * 60 * 60); $sql2 = "INSERT INTO cpmip(adid,ip,time) VALUES('$a','$ip','$time')"; $res2 = mysql_query($sql2) or die(mysql_error()); if($row3['credits']<=0){ $sql3 = "UPDATE cpm SET credits=0, active=0 WHERE id='$a'"; $res3 = mysql_query($sql3) or die(mysql_error()); }else{ $sql4 = "UPDATE cpm SET views=views+1, credits=credits-1 WHERE id='$a'"; $res4 = mysql_query($sql4) or die(mysql_error()); $sql5 = "UPDATE user SET balance=balance+ WHERE userid='$u'"; $res5 = mysql_query($sql5) or die(mysql_error()); }}elseif($num==1){ $a = mcheckTime($ip,$a); if($a==true){ $time = time() + (1 * 24 * 60 * 60); $sql6 = "INSERT INTO cpmip(ip,adid,time) VALUES('$ip','$a','$time')"; $res6 = mysql_query($sql6) or die(mysql_error()); if($row3['credits']<=0){ $sql7 = "UPDATE cpm SET credits=0, active=0 WHERE id='$a'"; $res7 = mysql_query($sql7) or die(mysql_error()); }else{ $sql8 = "UPDATE cpm SET views=views+1, credits=credits-1 WHERE id='$a'"; $res8 = mysql_query($sql8) or die(mysql_error()); $sql9 = "UPDATE user SET balance=balance+0.00007 WHERE userid='$u'"; $res9 = mysql_query($sql9) or die(mysql_error()); }}elseif($a==false){}}
![]() |
Similar Threads
- MySQL num rows error (MySQL)
- login form and MySQL connection/validation error (PHP)
- Switch Statement output error (PHP)
- Question regarding Access database sql. (MS Access and FileMaker Pro)
- MySQL LIKE statement (MySQL)
- MySQL connectivity issue (Java)
- insert values to mysql database (JSP)
- Error message while importing data to Excel from the MySQL db (MySQL)
- error handling in VB6 + + ODBC + MySQL...(Help!!!!) (Visual Basic 4 / 5 / 6)
Other Threads in the PHP Forum
- Previous Thread: delay function
- Next Thread: Including External Files
| Thread Tools | Search this Thread |
5.2.10 action address ajax apache api array auto autoincrement beginner binary broken cakephp checkbox class classes cms code cron curl database date dehasher destroy display domain dynamic echo email error errorlog fatalerror file files folder form forms function functions google href htaccess html if-else image include insert integration ip java javascript joomla limit link load login mail masterthesis menu mlm multiple mysql mysqlquery oop paypal pdf php popup problem query radio random record recursion regex remote script search security server sessions sms soap sockets source space sql syntax system table tutorial update upload url validator variable video web xml youtube






