Hi all whats wrong with this code,,,i am not getting error......it is showing succesfull ....but not storing data.......


$ser		= $_POST['service'];
$quotep		= $_POST['quote_price'];			
$dscnts		= $_POST['discounts'];		
$sertax		= $_POST['service_tax'];			
$prmtion	= $_POST['promotion'];
$frd		= $_POST['from'];		
$tod		= $_POST['to'];

echo $ser;
echo $quotep;
echo $dscnts;
echo $sertax;
echo $prmtion;
echo $frd;
echo $tod;

$query2 = "insert into autoalto_contractor_quotation(service, quote_price, discounts, service_tax,promotions, from, to) values ('".$ser."', '".$quotep."', '".$dscnts."','".$sertax."', '".$prmtion."', '".$frd."', '".$tod."')";
$result = mysql_query($query2);

$check  = "select * from autoalto_contractor_quotation";

die('Could not connect: ' . mysql_error());

$rcheck = mysql_query($check) or die(mysql_error());
$num    = mysql_num_rows($rcheck);
$rcheck = mysql_fetch_array($rcheck);
if($num == 0)  // if user not found	
$result = mysql_query($query2);		
echo $User = "  Successfully Created.";	
echo $User = " .";						
if (!$result)		
 // header("location:test.php"); // Re-direct to index.php		//header("location: //index.html"); // Re-direct to main.php	 

This is the table structure:

service_id int(10) No auto_increment primary
service varchar(80) latin1_general_ci No
quote_price int(80) No
service_tax int(80) No
promotions varchar(1000) latin1_general_ci No
from date No
to date

echo your insert query....

hi ishlux, i think u have error in sqlquery try like this

$query2 = "insert into autoalto_contractor_quotation(service, quote_price, discounts, service_tax,promotions, from, to) values ('$ser', '$quotep', '$dscnts','$sertax', '$prmtion', '$frd', '$tod')";

First of all check,again, u made the database connection correctly and then spelling may b u mistake .

tell me the correct error if my suggestion is wrong.

i did that echo query its displaying the values .......but not storing into the database, and also i removed those double quote and dot then also its not storing......

On line 22 just do this

$result = mysql_query($query2) or die(mysql_error());

and the error should tell you exactly what's wrong.

execute your echoed query in mysql database...and tel me what error you got there.............

i replace the statement

$result = mysql_query($query2)
with $result = mysql_query($query2) or die(mysql_error());

i am getting this error.

Engine inspection23231522sadasd12/07/200816/07/2008
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from, to) values ('Engine inspection','2323','15','22', 'sadasd','12/07/2008','1' at line 1

to is a keyword try `to`

from is too so you probably want to do `from` also

use `` for your all columns and try it...

Thanks problem solved.......

Yeah that's so impossible to be no error when you have nothing in your desired result. Just check every line of it.

When something like that happens, 90% of the time the sql query will tell you what's wrong.