can anyone help me out with these errors i'm getting please?
and if they can explain why im getting them and how i can avoid them in future
thanks :)
Notice: Undefined index: prod_name in C:\wamp\www\uniwork\update_database.php on line 17
Notice: Undefined index: prod_price in C:\wamp\www\uniwork\update_database.php on line 24
Notice: Undefined index: prod_desc in C:\wamp\www\uniwork\update_database.php on line 31
Notice: Undefined index: prod_colour in C:\wamp\www\uniwork\update_database.php on line 38
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add an Animal with Validation</title>
</head>
<body>
<h2>The action script for adding animal with validation </h2>
<p>Look at the <a href="addAnimalwithValid.phps">source code</a> and notice there is some validation and cleaning of the data. </p>
<?php
// Create a string to collect and report back any errors
$errorString = "";
//See if any info was submitted
$prodname = $_GET['prod_name'];
//Clean data - trim space
$prodname = trim ( $prodname);
//Check its ok - if not then add an error message to the error string
if (empty($prod_id))
$errorString = $errorString."<br>Please supply a product name.";
$prodprice = $_GET['prod_price'];
//Clean data - trim space
$prodprice = trim ( $prodprice);
//Check its ok - if not then add an error message to the error string
if (empty($prodprice))
$errorString = $errorString."<br>Please supply a product price in the £xxx.xx format.";
$proddesc = $_GET['prod_desc'];
//Clean data - trim space
$proddesc = trim ( $proddesc);
//Check its ok - if not then add an error message to the error string
if (empty($proddesc))
$errorString = $errorString."<br>Please supply a product description.";
$prodcolour = $_GET['prod_colour'];
//Clean data - trim space
$prodcolour = trim ( $prodcolour);
//Check its ok - if not then add an error message to the error string
if (empty($prodcolour))
$errorString = $errorString."<br>Please supply the dominant product colour.";
// check if there were any errors
if (!empty($errorString))
{
//If there were, print the error string and exit
print "<b>There were errors</b>.<br>".$errorString;
}
else //There wer No errors. Insert the data
{
include "include/connect.php";
$query = "INSERT INTO symbols (prod_name, prod_price, prod_desc, prod_colour) VALUES ('$prodname', '$prodprice', '$proddesc','$prodcolour')";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
//This function returns the id of the new row in the table
$id = mysql_insert_id();
// print message with ID of inserted record
echo "<br />New record inserted with ID = $id";
//Create a new query to display the new row in a table
$query = "Select * from symbols where id = '$id'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
echo "<table cellpadding=10 border=1>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row['prod_name']."</td>";
echo "<td>".$row['prod_price']."</td>";
echo "<td>".$row['prod_proddesc']."</td>";
echo "<td>".$row['prod_colour']."</td>";
echo "</tr>";
} //End while
echo "</table>";
}// End else - there where no errors
?>
</p>
</body>
</html>