PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Jul 14, 2020 5:47 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Aug 10, 2014 2:53 pm 
Offline
Forum Newbie

Joined: Sun Aug 10, 2014 2:46 pm
Posts: 5
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>'; }
}
        }}}    
        }}}            
}
         ?>


Top
 Profile  
 
PostPosted: Mon Aug 11, 2014 10:31 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13592
Location: New York, NY, US
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.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Tue Aug 12, 2014 12:56 am 
Offline
Forum Newbie

Joined: Sun Aug 10, 2014 2:46 pm
Posts: 5
thank, it works


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 23 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group