PHP Developers Network
http://forums.devnetwork.net/

You have an error in your SQL syntax; check the manual that
http://forums.devnetwork.net/viewtopic.php?f=1&t=140032
Page 1 of 1

Author:  tem5olufe2007 [ Sun Aug 10, 2014 2:53 pm ]
Post subject:  You have an error in your SQL syntax; check the manual that

Hello, I am working on a MLM referral site where an referral account increased when a new Member is introduced.
But i have this error message:

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

here is my update member code:

Syntax: [ Download ] [ Hide ]
<?php
if(isset($_POST['submit'])){
include('functions/connection.php');
$status=$_POST['publisher'];                           
$select = mysql_query("select * from users WHERE id = $status");
while($row = mysql_fetch_array($select )){
                                $user_id = $row['id'];
                                $pbal = $row['balance'];
                                $lev = $row['level'];
                                $reff = $row['referral'];
 
                                $update2 = mysql_query("UPDATE users SET follower = follower + 1,  balance= balance + 1000 WHERE id=$reff") or die (mysql_error());
                               
                                $seselect = mysql_query("select * from users WHERE id = $reff");
while($serow = mysql_fetch_array($seselect)){
                                $user_id = $serow ['id'];
                                $pbal = $serow ['balance'];
                                $lev = $serow ['level'];
                                $reff2 = $serow ['referral'];
                               
                               
                                        $update3 = mysql_query("UPDATE users SET follower = follower + 1,  balance= balance + 1000 WHERE id=$reff2") or die (mysql_error());
                               
                               
                                $tselect = mysql_query("select * from users WHERE id = $reff2");
while($trow = mysql_fetch_array($tselect)){
                                $user_id = $trow ['id'];
                                $pbal = $trow ['balance'];
                                $lev = $trow ['level'];
                                $reff3 = $trow ['referral'];
                               
                               
                                        $update4 = mysql_query("UPDATE users SET follower = follower + 1 ,  balance= balance + 1000 WHERE id=$reff3") or die (mysql_error());
                               
                                $fselect = mysql_query("select * from users WHERE id = $reff3");
while($frow = mysql_fetch_array($fselect)){
                                $user_id = $frow ['id'];
                                $pbal = $frow ['balance'];
                                $lev = $frow ['level'];
                                $reff4 = $frow ['referral'];
                               
                               
                                        $update5 = mysql_query("UPDATE users SET follower = follower + 1,  balance= balance + 1000 WHERE id=$reff4") or die (mysql_error());
                                       
                                $fiselect = mysql_query("select * from users WHERE id = $reff4");
while($firow = mysql_fetch_array($fiselect)){
                                $user_id = $firow ['id'];
                                $pbal = $firow ['balance'];
                                $lev = $firow ['level'];
                                $reff5 = $firow ['referral'];
                               
                               
                                        $update6 = mysql_query("UPDATE users SET follower = follower + 1 ,  balance= balance + 1000 WHERE id=$reff5") or die (mysql_error());
                                       
                                        $siselect = mysql_query("select * from users WHERE id = $reff5");
while($sirow = mysql_fetch_array($siselect)){
                                $user_id = $sirow ['id'];
                                $pbal = $sirow ['balance'];
                                $lev = $sirow ['level'];
                                $reff6 = $sirow ['referral'];
                               
                               
                                        $update7 = mysql_query("UPDATE users SET follower = follower + 1 ,  balance= balance + 1000 WHERE id=$reff6") or die (mysql_error());
                                       
                                        $sevselect = mysql_query("select * from users WHERE id = $reff6");
while($sevrow = mysql_fetch_array($sevselect)){
                                $user_id = $sevrow ['id'];
                                $pbal = $sevrow ['balance'];
                                $lev = $sevrow ['level'];
                                $reff7 = $sevrow ['referral'];
                               
                               
                                        $update8 = mysql_query("UPDATE users SET follower = follower + 1 ,  balance= balance + 1000 WHERE id=$reff7") or die (mysql_error());
                                       
                                if ($update8){$mesg='<font color="white"> <strong> Member "'.$status.'" is Updated Successfully</strong> </font>'; }
}
        }}}    
        }}}            
}
         ?>

Author:  Christopher [ Mon Aug 11, 2014 10:31 am ]
Post subject:  Re: You have an error in your SQL syntax; check the manual t

You don't identify when query caused the error. My guess is that one of your $ref* variables is not set or not an integer.

PS - this code looks horrible with the 7-8 nested while statements -- all with queries in them. I imagine that you could do all of this with a single or a few queries.

Author:  tem5olufe2007 [ Tue Aug 12, 2014 12:56 am ]
Post subject:  Re: You have an error in your SQL syntax; check the manual t

thank, it works

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/