Hi,
FYI. I have very very little knowledge of PHP & MYSQL.
i am trying to create a simple webform with insert statement what i am trying to do is that, when i enter a new data into this form this will show the message "1 record is added" and the newly inserted record on the same page. But i am getting error on line "50" in this code that there is something wrong with the SQL insert statement. is there any suggestions??
h1>ADD NEW PRODUCT </h1>
<table width="395" border="0">
<tr>
<td width="167">Unit ass number:</td>
<td width="218"><form method="post" action="add_new_product.php">
<input name="unit_ass_products" type="text" id="unit_ass_products" size="35">
</td>
</tr>
<tr>
<td>Prod Unit number:</td>
<td>
<input name="pu_number_products" type="text" id="pu_number_products" size="35">
</td>
</tr>
<tr>
<td>Product Description</td>
<td>
<input name="pu_description_products" type="text" id="pu_description_products" size="35">
</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Submit"></td>
</tr>
</table>
</form>
<?php
// Enter the server information here...
$host = "localhost";
$user = "root";
$pass = "";
$database_name = "phl";
// create connection to the mysql database...
$con = mysql_connect($host,$user,$pass);
if(!$con)
{
die('Could not connect: ' . mysql_error());
}
// select database
mysql_select_db($database_name,$con);
echo "database connection established...";
// perform insert action
// sql statement
$sql = "insert into products (PU_NUMBER, PU_DESC, UNIT_ASS)
VALUES('$_POST[pu_number_products]', '$_POST[pu_description_products]', '$_POST[unit_ass_products]')";
// show error information if something goes wrong.
if(!mysql_query($sql))
{ die('Error: ' . mysql_error()); }
echo "1 record added";
mysql_close($con);
?>