Trouble with Insert
Posted: Sun Oct 05, 2003 9:14 am
Hi,
I'm having trouble inserting a record. I've got lots of Insert pages written and working fine so I think my syntax is ok. But the following code just won't insert a new record. I've shortened the code for legibility but is there any inherent reason why the following won't work? I'm getting no error messages but the code will not process. I've tested the code, building it up line by line with test variable output and it works up to the point of the sql query
property_code is being posted from a form
the variables in the rates table are all decimal values
All values are allowed to be null (for testing anyway)
<?php
// Includes
include("MyGlobalVariableFile.php");
// Set Table Name
$table_name="rates";
// Set up connection
$connection=mysql_connect("$glob_host", "$glob_user", "$glob_pass")
or die(mysql_error());
// Set the database
$db=mysql_select_db($db_name, $connection)
or die(mysql_error());
// Do the SQL for rates
$sql="
INSERT INTO $table_name(rates_id ,property_code, and others...)
VALUES ('', '$_POST[property_code]', and others...)";
$result=(mysql_query($sql,$connection)
or die(mysql_error());
?>
I'm having trouble inserting a record. I've got lots of Insert pages written and working fine so I think my syntax is ok. But the following code just won't insert a new record. I've shortened the code for legibility but is there any inherent reason why the following won't work? I'm getting no error messages but the code will not process. I've tested the code, building it up line by line with test variable output and it works up to the point of the sql query
<?php
// Includes
include("MyGlobalVariableFile.php");
// Set Table Name
$table_name="rates";
// Set up connection
$connection=mysql_connect("$glob_host", "$glob_user", "$glob_pass")
or die(mysql_error());
// Set the database
$db=mysql_select_db($db_name, $connection)
or die(mysql_error());
// Do the SQL for rates
$sql="
INSERT INTO $table_name(rates_id ,property_code, and others...)
VALUES ('', '$_POST[property_code]', and others...)";
$result=(mysql_query($sql,$connection)
or die(mysql_error());
?>