r14_saj Posted April 11, 2009 Share Posted April 11, 2009 hi i am trying to update a record by a form although no errors come up the data is not altered help please my php code <?php $Registration_Number = $_POST['Registration_Number']; $Year = $_POST['Year']; $Make = $_POST['Make']; $Model = $_POST['Model']; $Mileage = $_POST['Mileage']; $MOT = $_POST['MOT']; $Road_Tax = $_POST['Road_Tax']; $Service_History = $_POST['Service_History']; $Colour = $_POST['Colour']; $No_of_Doors = $_POST['No_of_Doors']; $Engine_Size = $_POST['Engine_Size']; $Type_of_Car = $_POST['Type_of_Car']; $Type_of_Transmission = $_POST['Type_of_Transmission']; $Fuel_Type = $_POST['Fuel_Type']; $PAS = $_POST['PAS']; $No_of_Owners = $_POST['No_of_Owners']; $Condition_of_Car = $_POST['Condition_of_Car']; $Alloy_Wheels = $_POST['Alloy_Wheels']; $Sunroof = $_POST['Sunroof']; $CD_Player = $_POST['CD_Player']; $Electric_Windows = $_POST['Electric_Windows']; $Central_Locking = $_POST['Central_Locking']; $Alarm = $_POST['Alarm']; $Airbags = $_POST['Airbags']; $Other_Extras = $_POST['Other_Extras']; $Buying_Price = $_POST['Buying_Price']; $Car_Sale_Invoice_Number = $_POST['Car_Sale_Invoice_Number']; $Date_of_Purchase = $_POST['Date_of_Purchase']; $Selling_Price = $_POST['Selling_Price']; @mysql_connect("localhost","root","") or die("Error: unable to connect or incorrect user"); @mysql_select_db("saj_car") or die("Error: unable to connect to Database"); $Update = "UPDATE saj_sales_cars SET Registration_Number = '".$Registration_Number."', Year = '".$Year."', Make = '".$Make."', Model = '".$Model."', Mileage = '".$Mileage."', MOT = '".$MOT."', Road_Tax = '".$Road_Tax."', Service_History = '".$Service_History."', Colour = '".$Colour."', No_of_Doors = '".$No_of_Doors."', Engine_Size = '".$Engine_Size."', Type_of_Car = '".$Type_of_Car."', Type_of_Transmission = '".$Type_of_Transmission."', Fuel_Type = '".$Fuel_Type."', PAS = '".$PAS."', No_of_Owners = '".$No_of_Owners."', Condition_of_Car = '".$Condition_of_Car."' , Alloy_Wheels = '".$Alloy_Wheels."', Sunroof = '".$Sunroof."', CD_Player = '".$CD_Player."', Electric_Windows = '".$Electric_Windows."', Central_Locking = '".$Central_Locking."', Alarm = '".$Alarm."', Airbags = '".$Airbags."', Other_Extras = '".$Other_Extras."', Selling_Price ='".$Selling_Price."' WHERE Registration_Number = '".$Registration_Number."' "; // /// VALUES ('".$Registration_Number."','".$Year."','".$Make."','".$Model."','".$Mileage."','".$MOT."','".$Road_Tax."','".$Service_History."','".$Colour."','".$No_of_Doors."','".$Engine_Size."','".$Type_of_Car."','".$Type_of_Transmission."','".$Fuel_Type."','".$PAS."','".$No_of_Owners."','".$Condition_of_Car."','".$Alloy_Wheels."','".$Sunroof."','".$CD_Player."','".$Electric_Windows."','".$Central_Locking."','".$Alarm."','".$Airbags."','".$Other_Extras."','".$Selling_Price."') "; //$Insert2 = "INSERT INTO saj_sales_invoices (Car_Sale_Invoice_Number, Registration_Number, Buying_Price, Date_Of_Purchase) // VALUES ('".$Car_Sale_Invoice_Number."','".$Registration_Number."','".$Buying_Price."','".$Date_of_Purchase."') "; $query= mysql_query($Update); ////$query1= mysql_query($Insert2); echo "Car Updated. Please <a href='private_page.php?username=$Username&password=$Password'>continue</a>."; ?> thanks Link to comment https://forums.phpfreaks.com/topic/153617-help-wkith-updating-record-from-form/ Share on other sites More sharing options...
ToonMariner Posted April 11, 2009 Share Posted April 11, 2009 all this... $Registration_Number = $_POST['Registration_Number']; $Year = $_POST['Year']; $Make = $_POST['Make']; $Model = $_POST['Model']; $Mileage = $_POST['Mileage']; $MOT = $_POST['MOT']; $Road_Tax = $_POST['Road_Tax']; $Service_History = $_POST['Service_History']; $Colour = $_POST['Colour']; $No_of_Doors = $_POST['No_of_Doors']; $Engine_Size = $_POST['Engine_Size']; $Type_of_Car = $_POST['Type_of_Car']; $Type_of_Transmission = $_POST['Type_of_Transmission']; $Fuel_Type = $_POST['Fuel_Type']; $PAS = $_POST['PAS']; $No_of_Owners = $_POST['No_of_Owners']; $Condition_of_Car = $_POST['Condition_of_Car']; $Alloy_Wheels = $_POST['Alloy_Wheels']; $Sunroof = $_POST['Sunroof']; $CD_Player = $_POST['CD_Player']; $Electric_Windows = $_POST['Electric_Windows']; $Central_Locking = $_POST['Central_Locking']; $Alarm = $_POST['Alarm']; $Airbags = $_POST['Airbags']; $Other_Extras = $_POST['Other_Extras']; $Buying_Price = $_POST['Buying_Price']; $Car_Sale_Invoice_Number = $_POST['Car_Sale_Invoice_Number']; $Date_of_Purchase = $_POST['Date_of_Purchase']; $Selling_Price = $_POST['Selling_Price']; can be replaced by: foreach($_POST as $key => $val) { $$key = $val; } just before you execute the query echo out the query string - you can then paset it into your db admin tool (probably phpmyadmin) and see what it says - it may give you some clues. Link to comment https://forums.phpfreaks.com/topic/153617-help-wkith-updating-record-from-form/#findComment-807210 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.