What does You have an error in your SQL syntax near '' at line 1 mean?
You have an error in your SQL syntax near '' at line 1
your sql statement has an error. can you provide your sql statement?
$query = "UPDATE affiliates SET status='Y' WHERE id=$refid[$i]" or die(mysql_error());
you need single quotes around $refid[$i]
hope this helps
im now getting this error Warning: sprintf(): too few arguments
ill post the full script
<?
include "common.php";
include "config.php";
include "header.php";
$insert_count=$delete_count=$ignored_count=0;
$num_rows=count($id);
$link = mysql_connect("$server", "$username", "$password")
or die("Could not connect");
mysql_select_db("$db") or die("Could not select database");
for($i = 0; $i < $num_rows; ++$i){
if($a[$i]=="Add Site"){
$query = "UPDATE affiliates SET status='Y' WHERE 'id=$refid[$i]'" or die(mysql_error());
if (!mysql_query ($query, $link) ){ die (mysql_error());}
$emailinfo .= " \nWebmaster Number: " . sprintf("%03d");
$aemailbody = "Dear ".$afirstname.",\n\nThank you for signing up to our affiliate program.\nYour account details are below:\n\n"
."Username: ".$ausername."\nPassword: ".$apassword."\n\n"
."You can log into your account and view your 'real-time' statistics by going to:\n"
."http://www.sa-webpartner.com/lang/en/2site/login.php\n\n"
."Copy the code below and change the ref=AM(to the Webmaster Number supplied in this email) the bit to replace is the xxxx Once you have done that add it to your webpage.\n\n\n"
."<a href=http://www.adultinfo4u.co.uk/index.php?ref=AMxxxx><img src=http://www.adultinfo4u.co.uk/images/banner_02.gif></a>\n\n\n"
."Thank you once again, and we wish you luck with your profit making!\n\n\n"
."Affiliate Manager\n"
."".$emailinfo."\n\n\n\n";
mail($aemail[$i],"Welcome New Affiliate!",$aemailbody,"From:$emailinfo\nReply-To: $emailinfo\n");
++$insert_count;
}
if($a[$i]=="Reject Site"){
$query = "DELETE from affiliates WHERE id=$refid[$i]" or die (mysql_error());
if (!mysql_query ($query, $link) ){ die (mysql_error());}
$msg = "Sorry $afirstname.\n Your Webmaster Account has been rejected from Adultinfo4u.co.uk.\n Reason: $reason[$i].";
mail($aemail[$i],"Webmaster Account Rejected.",$msg,"From: $emailinfo\nReply-To: $emailinfo");
++$delete_count;
}
}
$ignored_count=$num_rows-$insert_count-$delete_count;
?>
<table align="center" border="0" cellpadding="5" cellspacing="0" width="90%">
<tr>
<td align="center" bgcolor="#eeeeee"><br><table>
<tr>
<td><font face="<? echo $font_face;?>" size="2">
<? echo $insert_count;?> Sites were added.<br><br>
<? echo $delete_count;?> Sites were rejected.<br><br>
<? echo $ignored_count;?> Sites were ignored.<br><br><br>
<a href="validate.php">Click Here to Continue</a>
</font><br><br></td>
</tr>
</table></td>
</tr>
</table>
<?
include "footer.php";
?>
What this is doing is taking data from validate.php which validates data that has been submitted to my database...the sprintf("%03d"); is meant to take the value from the id of the database and make an out put of 001...002...003 and so on.
you have:
WHERE 'id=$refid[$i]'"
it should be:
where id = '$refid[$i]'"
done that still not updating the database...no errors but not updating
hmm,
try:
WHERE id='".$refid[$i]."'
are you checking for updates in mysql monitor? echo your query and try it in mysql monitor.
like slava said, print your query, but I was wondering why you have or die on the statement, and then again on the mysql_query?
$query = "UPDATE affiliates SET status='Y' WHERE 'id=$refid[$i]'" or die(mysql_error());
if (!mysql_query ($query, $link) ){ die (mysql_error());}
As far as I know, you can't put the or die on $query because you're not using mysql_query with it. (also, why do you use an if statement there)
Just change it to
$query = "UPDATE affiliates SET status='Y' WHERE id='" . $refid[$i] . "'";
$result = mysql_query($query) or die(mysql_error());
Do the same for your other queries. If that doesn't work, then just print $query and see what it prints.
Cgraz