Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...with companys cutting back on training, lack of true support by makers of software, the forums are a great tool in your cyber-toolbox...."

Geography

Where in the world do Tek-Tips members come from?

intermittent error updating databaseHelpful Member! 

max2474 (Programmer)
1 Jun 12 11:44
Hi.

I have this scripts to update my database totals:

CODE --> php

while ($mppaycount <= 8) { $mpref=$_SESSION[refs][$mppaycount]; $mprefpay=$_SESSION[refpay][$mppaycount]; $mppayrefs=mysql_query("UPDATE members SET tottokens = tottokens+$mprefpay, tokens = tokens+$mprefpay, newtokens = newtokens+$mprefpay WHERE userid = '$mpref' LIMIT 1"); $mppayrefs=mysql_query("UPDATE members SET tottokens = tottokens+$mprefpay, tokens = tokens+$mprefpay, newtokens = newtokens+$mprefpay WHERE userid = '1001' LIMIT 1"); paylvlbonus($mpref,$mprefpay); $mppaycount++; } $mpmylo=$_SESSION[myleftovers]; $mpmpb=$_SESSION[misspaymentbonus]; $mpboth=$mpmylo+$mpmpb; $mppayme=mysql_query("UPDATE members SET tottokens = tottokens+$mpmylo, tokens=tokens+$mpmylo, newtokens = newtokens+$mpmylo, bonus = bonus+$mpplancost WHERE userid = '1002' LIMIT 1")or die(mysql_error()); $mppayme=mysql_query("UPDATE members SET tottokens = tottokens+$mpmpb, tokens=tokens+$mpmpb, newtokens = newtokens+$mpmpb WHERE userid = '1003' LIMIT 1"); $mppayme=mysql_query("UPDATE members SET tottokens = tottokens+$mpboth, tokens=tokens+$mpboth, newtokens = newtokens+$mpboth WHERE userid = '1001' LIMIT 1");

everything seemed to be working fine until I deleted the test database and started again. I have noticed that upon the first run ONLY, that the highlighted line wasnt adding the bonus. (bonus = bonus+$mpplancost) yet all else is working fine.

Upon a repeated call, the value $mpplancost does get added.

Adding the "or die(mysql_error()" gives the following error:

Quote (screen)


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 ' tokens=tokens+, newtokens = newtokens+, bonus = bonus+5500 WHERE userid = '1' at line 1

Should I be using ' or ` perhaps? Also, is the "userid = '1' " just how the error reports?

Any pointers would be great!
Helpful Member!  vacunita (Programmer)
1 Jun 12 13:03
It seems to be the fact that your $mpmylo variable is empty, so you get invalid operations.

CODE

tokens=tokens+ , newtokens = newtokens+ , bonus = bonus+5500 WHERE userid = '1' at line 1

Which cause the query to fail. The id of 1 is probably due to the error cutting off the query line at that point.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

max2474 (Programmer)
1 Jun 12 13:21
ahh...lol.

added this :

CODE --> php

$mpmylo="0"; $mpmpb="0"; $mpmylo=$mpmylo+$_SESSION[myleftovers]; $mpmpb=$mpmylo+$_SESSION[misspaymentbonus];
and it seemed to solve it.

Silly things. Was looking a syntax error.

Many thanks!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close