User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,143 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,510 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 206 | Replies: 3 | Solved
Reply
Join Date: Dec 2007
Posts: 307
Reputation: OmniX is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
OmniX's Avatar
OmniX OmniX is offline Offline
Posting Whiz

Stupid error!!!

  #1  
May 16th, 2008
"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."

Now this is a really stupid error. (yes that sums up the error S T U P I D)

I am making an update to columns via stored variables.

Eg.
"UPDATE table SET a = a + $a, b = b + $b, c = c + $c, d = d + $d, e = e + $e"

Note: This goes on for at least 10 columns not 5 like I have here

Now as im tryign to debug the error I cut out the C/D variables and it works! (It also works if I just change $c/$d to 0/0)

Anyways this is utterly stupid and dont know why this is happening...
I have been on this for days and days and refused to show anyone this stupid error for fear oh my own stupidity but oh well

Anyways any help?

Thanks, Regards X
Last edited by OmniX : May 16th, 2008 at 8:26 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 227
nav33n's Avatar
nav33n nav33n is online now Online
Posting Sensei

Re: Stupid error!!!

  #2  
May 16th, 2008
Heh.. maybe "c" and "d" are varchar fields and the rest are integer fields ? Simplest way to debug this problem is to print out the query and see what does it have at the runtime. Then execute it in phpmyadmin or mysql console. Doing so, you will know where exactly is the error.
Note: Varchar fields need to be wrapped within single quotes while integer fields dont need single quotes.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Aug 2007
Posts: 4
Reputation: jana36 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
jana36 jana36 is offline Offline
Newbie Poster

Re: Stupid error!!!

  #3  
May 16th, 2008
hey i think u divide the problem into pieces..in the update command there should be the table name ....
print the variable and check shether simple insertion occurs or not. then before u write the query write a=$a+a b=$b+b etc
then simple insert the values a, b

debug it like that...with the help of the manual..
thanks
Reply With Quote  
Join Date: Dec 2007
Posts: 307
Reputation: OmniX is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
OmniX's Avatar
OmniX OmniX is offline Offline
Posting Whiz

Re: Stupid error!!!

  #4  
May 16th, 2008
Field Type Collation Attributes Null Default Extra Action
a int(2) Yes 0

they all have the same structure, thats copied and pasted straight from phpMyAdmin.

But like I said I dont understand why they work on one column and not the other.

Ill test the missing values theory, but I very much doubt that is the problem as if there was no value in $a/b there would be no error.

Solved!

See the missing values theory was wrong, but it lead me to go test the variables throughly and i solved it. Thanks!

In short said the variable had the wrong value (which it did not but anyways...) so I gave them all a default value of 0 at the start and override them with the real value and its working for the time being!
Last edited by OmniX : May 16th, 2008 at 9:11 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:15 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC