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
Adding a record to a database [message #175100] Mon, 15 August 2011 12:35 Go to previous message
Charles is currently offline  Charles
Messages: 13
Registered: February 2011
Karma:
Junior Member
I'm trying to add a record to a database, and it's not working
properly.

The general thought is to call a data entry form, fill in the form,
and use the $_POST(array) process to pass the data from the form to a
php script that handles adding the record to the database.

The only trick part of the php script is using a hidden field to pass
the name of the data entry form to a SWITCH statement. I'm trying to
keep the site directory uncluttered and the scripting organized, and I
understand this works.

I'm getting Error 500 as I test the script, so I think I have
something coded incorrectly in the script, or I have something
missing. Other php-based web applications wrok fine, so I suspect I
have php correctly installed.

Here's the coding:

=====================

<?php

/* <!-- This starts the switch statement. The variable passed to
control iteration
is the $_Push(switch) variable set in the first (hidden) field in a
data entry form.
The value contained in the variable is the case predicate

*/


switch ($_Push(switch)) {

/*======================================================*/

case "cab_vehicle_data_entry_add_a_vehicle":



$con = mysql_connect("*********","****","******"); <<These are fine
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

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


('$_POST[Make]','$_POST[Model]','$_POST[Edition]','$_POST[Month]','$_POST[y ear]',
'$_POST[VIN]','$_POST[Registration]','$_POST[reg_exp_month]','$_POST[reg_ex p_year]',
'$_POST[pax_capacity]','$_POST[cargo_cubic_feet]','$_POST[cargo_weight_lbs] ') ";

if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";

mysql_close($con)

break;

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/

/*======================================================*/

/* case "whatever"
Next process subroutine
break;
*/


}


?>
[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: Fri Nov 22 22:06:08 GMT 2024

Total time taken to generate the page: 0.05073 seconds