FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Adding a record to a database
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Adding a record to a database [message #175118 is a reply to message #175116] Tue, 16 August 2011 08:30 Go to previous messageGo to previous message
Charles is currently offline  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*************/

?>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP 4 vs 5 timings
Next Topic: Re: ftp with win-filenames with chr#32 ?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 05:40:51 GMT 2024

Total time taken to generate the page: 0.04247 seconds