balkan7 Posted January 3, 2008 Share Posted January 3, 2008 hi, i tested my code many times but whitout result where i wrong ? i get this: You have an error in your SQL syntax near 'WHERE banner_id = 18' at line 2 <?php if ($data['banner_type'] == "0"){ $banner_url = addslashes(stripinput($_POST['banner_url'])); $banner_data = addslashes(stripinput($_POST['banner_img'])); $bquery = "banner_url = '$banner_url', banner_img = '$banner_data'"; } else { $banner_data = addslashes(stripinput($_POST['banner_url'])); $bquery = "banner_url = '$banner_data'"; } if ($banner_expire == 1) { $expire = "banner_expire = NOW() + INTERVAL 1 MONTH"; } elseif ($banner_expire == 2){ $expire = "banner_expire = NOW() + INTERVAL 2 MONTH"; } elseif ($banner_expire == 3){ $expire = "banner_expire = NOW() + INTERVAL 3 MONTH"; } elseif ($banner_expire == 4){ $expire = "banner_expire = NOW() + INTERVAL 6 MONTH"; } elseif ($banner_expire == 5){ $expire = "banner_expire = NOW() + INTERVAL 1 YEAR"; } else { $expire = ""; } if ($banner_name == "" || $banner_data == ""){ echo "<center>".$locale['BB_112']."</center><br /><br />"; } else { $update_banner = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_type = '$banner_type', banner_state = '$banner_state', banner_plans = '$banner_plans', client_id = '$client_id', banner_name = '$banner_name', ".$bquery.", ".$expire." WHERE banner_id = ".$banner_id); echo "<center>".$locale['BB_113']."</center><br /><br />"; }?> Quote Link to comment https://forums.phpfreaks.com/topic/84384-you-have-an-error-in-your-sql-syntax/ Share on other sites More sharing options...
revraz Posted January 4, 2008 Share Posted January 4, 2008 What does $bquery & $expire contain in your Query? Chances are something is wrong in there. Quote Link to comment https://forums.phpfreaks.com/topic/84384-you-have-an-error-in-your-sql-syntax/#findComment-429821 Share on other sites More sharing options...
balkan7 Posted January 4, 2008 Author Share Posted January 4, 2008 you got code up for $bquery & $expire Quote Link to comment https://forums.phpfreaks.com/topic/84384-you-have-an-error-in-your-sql-syntax/#findComment-430409 Share on other sites More sharing options...
revraz Posted January 4, 2008 Share Posted January 4, 2008 echo it and see what they actually contain, I'm not going to figure it out based on all those elseif's. Quote Link to comment https://forums.phpfreaks.com/topic/84384-you-have-an-error-in-your-sql-syntax/#findComment-430476 Share on other sites More sharing options...
PFMaBiSmAd Posted January 4, 2008 Share Posted January 4, 2008 $expire looks like it was intended to use one of the date/time functions, but it is just the sum of two terms, which would probably generate a syntax error. However, when $expire is "", this will result in a trailing coma , from the previous term in the query, which will generate a syntax error. Forming your query in a variable, so that it can be echoed to see what it actually contains will certainly help you debug this yourself. Quote Link to comment https://forums.phpfreaks.com/topic/84384-you-have-an-error-in-your-sql-syntax/#findComment-430500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.