You have an error in your SQL syntax; check the manual that

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tem5olufe2007
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2014 2:46 pm

You have an error in your SQL syntax; check the manual that

Post by tem5olufe2007 »

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:

Code: Select all

<?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>'; }
}
	}}}	
	}}}		
}
	 ?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: You have an error in your SQL syntax; check the manual t

Post by Christopher »

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)
tem5olufe2007
Forum Newbie
Posts: 5
Joined: Sun Aug 10, 2014 2:46 pm

Re: You have an error in your SQL syntax; check the manual t

Post by tem5olufe2007 »

thank, it works
Post Reply