Jump to content

You have an error in your SQL syntax ?


balkan7

Recommended Posts

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 />";
		}?>

 

 

Link to comment
Share on other sites

$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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.