Hi!Guys,
I need help inserting records into mySQL.This is the code which I have for the form:
<form action="add.php" method="post">
<table width="75%" border="0">
<tr>
<td class="title">ISBN</td>
<td><input name="isbn" type="text"></td>
</tr>
<tr>
<td class="title">Author</td>
<td><input name=author type="text"></td>
</tr>
<tr>
<td class="title">Title</td>
<td><input name=title type="text"></td>
</tr>
<tr>
<td height="22" class="title">Price</td>
<td><input name=price type="text"></td>
</tr>
<tr>
<td class="title"> </td>
<td><input type="submit" name="Submit" value="Add"></td>
</tr>
</table>
</form>
This is the code for adding the records:
<?php
@ $db=mysql_pconnect("localhost","","");
if(!$db)
{
echo "Error:unable to connect to database server";
exit;
}
mysql_select_db("test");
$isbn=$_POST[isbn];
$author=$_POST[author];
$title=$_POST[title];
$price=$_POST[price];
$query="insert into books values('".$isbn."','".$author."','".$title."','".$price."')";
$result=mysql_query($query);
if ($result)
echo mysql_affected_rows()." client inserted into database";
?>
but everytime I post the form I get the following error:
Notice: Use of undefined constant isbn - assumed 'isbn' in C:\Projects\php-site\add.php on line 11
Notice: Use of undefined constant author - assumed 'author' in C:\Projects\php-site\add.php on line 12
Notice: Use of undefined constant title - assumed 'title' in C:\Projects\php-site\add.php on line 13
Notice: Use of undefined constant price - assumed 'price' in C:\Projects\php-site\add.php on line 14
Can anybody help me?
Cheers