View Full Version : Insert into table problem

09-07-2011, 06:03 AM
hi i have question to insert record in to the table

this size is with 12" like this

$sqlstr = "INSERT INTO Cost_Tyre(internal,size,blackatb,blackbmx,whiteatb,whitebmx,ww,reflective,tyre_date,Tyre) VALUES('$internal','$size1','$blackatb','$blackbmx','$whiteatb','$whitebmx','$ww','$reflective','$ty re_date','$Tyre')" ;

echo $sqlstr;

$result1 = mysql_query($sqlstr);

when the print the result it shows

INSERT INTO Cost_Tyre(internal,size,blackatb,blackbmx,whiteatb,whitebmx,ww,reflective,tyre_date,Tyre,tyre_date) VALUES('11','12" ','4.24','','5.20','5.20','4.60','6.04','2011-09-01','2.46','2011-09-01')

hear my problem is data is not inserting to the table

plz help me to slove this problem

plzzzzzzz give me a sample code

09-07-2011, 08:20 AM
Have a look at your quotes and commas. There is a mismatch there.

09-07-2011, 02:16 PM
There might also be a problem in that he's inserting a null value. You have no error reporting here at all for the MySQL. mysql_query() will not return a result for an INSERT query, or update query or basically anything that doesn't expect a result from the table. It will, however, return a true or false depending on whether the query was successful or not. To error report correctly, you should change your line to a static call with an 'or die' statement:

mysql_query($query) or die(mysql_error());

The 'or die()' might not be your desired option, but it will kill the code at that point if there's a problem which makes it favourable (for me anyway) for debugging.