Jump to content

My SQL Insert into Sometimes working and sometimes not


Go to solution Solved by durgaprasadcs,

Recommended Posts

Hello ,

 

I have a Query to insert values to database. The Query is working fine sometimes and sometimes not.

 

Here is the Query I have 

 

 $sql = "INSERT INTO snicyposts (MAKE,MODEL,VARIANT,YEAR,COLOUR,FUELTYPE,MILEAGECITY,MILEAGEHIGHWAY,KILOMETERS,TITLE,DESCRIPTION,FEATUES,PRICE,NEGOTIABLE,SCRATCH,OWNERTYPE,CITY,ACCIDENT,TYPE,POSTEDBY,PHONE,POSTEDBYEMAIL,POSTEDON,POSTEDBYUSERNAME,IPADDRESS,POWERSTEERING,POWERWINDOWS,INSURANCEVALIDITY,REGISTRATIONTYPE) 
VALUES ( '$make','$model','$variant','$year','$colour','$fueltype','$citymil','$highmil','$km','$title','$desc','$features','$price','$negotiable','$scratc','$owner','$city','$accidents','$type','$name','$phone','$email','$currenttime','$usernameposted','$ipadd','$powersteering','$powerwindows','isurance','$regtype')";
mysql_query($sql);
 
Please help me to solve this 

Yes I have a column like FEATUES and I have tried echoing,the format and all perfect. Issue is if it is not working entirely I can able to find the root cause, but its sometimes working and sometimes not. That's the problem.
 

Is there any problem with my host ? even I tried with them , but they said there is no problem in their server.

Edited by durgaprasadcs

Have you tried echoing the output from mysql_error() to find the reason?

 

 

If the query fails, check out why!

if (!mysql_query($sql)) die (mysql_error() . "<pre>$sql</pre>");

two possibilities come to mind -

 

1) you have some indexes/unique keys set up and you are tying to insert duplicate values.

 

2) you are not escaping the string data being put into the query and some data contains sql special characters.

  • Solution

Hi

 

Thanks!!! your reply help me to solve the issue. The thing is i didnt escape the string before adding. so whenever users used special characters, its not worked. That's the issue. 

 

Thanks a lot !!!! :happy-04: 
 

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.