Jump to content

Recommended Posts

Hello,

I want your help :)

 

I have this code

case "addads": // 
		$qry = "INSERT INTO 4sale_categories SET catImage1 = '".mysql_real_escape_string(trim($_GET['catImage1']))."' , catImage2 = '".mysql_real_escape_string(trim($_GET['catImage2']))."' , catImage3 = '".mysql_real_escape_string(trim($_GET['catImage3']))."', catImage4 = '".mysql_real_escape_string(trim($_GET['catImage4']))."', catImage5 = '".mysql_real_escape_string(trim($_GET['catImage5']))."', admin_id = '0', phone = '".mysql_real_escape_string(trim($_GET['phone']))."', email = '".mysql_real_escape_string(trim($_GET['email']))."', subcategory = '".mysql_real_escape_string(trim($_GET['subcategoryid']))."', categoryName = '".mysql_real_escape_string(trim($_GET['categoryid']))."', description = '".mysql_real_escape_string(trim($_GET['description']))."', device_token = '".mysql_real_escape_string(trim($_GET['device_token']))."', created = NOW()";
       	$sql = mysql_query($qry);
		

I want to make condition if catImage1 is null insert default value in catimage1 or keep same data :) 

 

 

Thank you 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/284589-please-help-with-insert-data/
Share on other sites

Define your table column to have default value. If the image value is null, exclude that column from the insert query. If no value is inserted in the column then the default will be used.

 

edit: BTW that table needs normalizing.

Edited by Barand
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.