Re: Adding a record to a database [message #175118 is a reply to message #175116] |
Tue, 16 August 2011 08:30 |
Charles
Messages: 13 Registered: February 2011
Karma:
|
Junior Member |
|
|
Is this better?
I still get one error message - Error: 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 'Ford'', ''Crown Victoria'',
''Taxicab'', ''SEP'', '2010', ''sadfasdfsadfdsf' at line 21
=====================================
<?php
/***Switch statement that controls processing from
value of $_POST(deform)***************/
switch ( $_POST['deform'] )
{
/***Case statement that acts on value of $_POST(deform)******/
CASE $_POST['deform'] = "cab_vehicle_data_entry_add_a_vehicle":
$con = mysql_connect("localhost","root","edward");
if (!$con)
{
die("Could not connect: " . mysql_error());
}
function check_input($value)
{
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
if (!is_numeric($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
$Make = check_input($_POST['Make']);
$Model = check_input($_POST['Model']);
$Edition = check_input($_POST['Edition']);
$Month = check_input($_POST['Month']);
$Year = check_input($_POST['Year']);
$VIN = check_input($_POST['VIN']);
$Registration = check_input($_POST['Registration']);
$reg_exp_month = check_input($_POST['reg_exp_month']);
$reg_exp_year = check_input($_POST['reg_exp_year']);
$pax_capacity = check_input($_POST['pax_capacity']);
$cargo_cubic_feet = check_input($_POST['cargo_cubic_feet']);
$cargo_weight_lbs = check_input($_POST['cargo_weight_lbs']);
mysql_select_db("taxicab", $con);
$sql="INSERT INTO
cab_vehicle (
cab_vehicle_make,
cab_vehicle_model,
cab_vehicle_edition,
cab_vehicle_month,
cab_vehicle_year,
cab_vehicle_VIN,
cab_vehicle_registration_number,
cab_vehicle_reg_exp_month,
cab_vehicle_reg_exp_year,
cab_vehicle_pax_capacity,
cab_vehicle_cubic_feet_cargo,
cab_vehicle_cargo_weight)
VALUES
('$Make',
'$Model',
'$Edition',
'$Month',
'$Year',
'$VIN',
'$Registration',
'$reg_exp_month',
'$reg_exp_year',
'$pax_capacity',
'$cargo_cubic_feet',
'$cargo_weight_lbs')";
if (!mysql_query($sql,$con))
{
die("Error: " . mysql_error());
}
echo "1 record added";
mysql_close($con);
break;
}
/******End of CASE statement start of next one*************/
?>
|
|
|