Jump to content

unexpected end of file Error, please help


BrainBoxMad

Recommended Posts

Hi everyone i keep getting the error message 
 

Parse error: syntax error, unexpected end of file in E:\website\htdocs\restricted\test\sqltest.php on line 87
 
I am trying to display a form that offers me the functionality to add and delete rows from my database table.
 
all help will be very appreciated : )
 
<?php
 
require_once "config.php";
$dbhandle =mysql_connect($hostname, $username, $password);
 
 
 
 
if (!$dbhandle) die("unable to connect to mysql: " . mysql_error());
 
mysql_select_db("store")
     or die ("unable to connect to databse: " . mysql_error());
 
if (isset($_POST['delete']) && isset($_POST['price']))
{
$price = get_post('price');
$query = "DELETE FROM laptop_products WHERE price = '$price'";
 
if (!mysql_query($query, $dbhandle))
echo "delete failed: $query<br />" .
mysql_error() . "<br /><br />";
}
 
if (isset($_POST["product_id"]) &&
    isset($_POST["product_name"]) &&
    isset($_POST["weight"]) &&
    isset($_POST["stock"]) &&
    isset($_POST["price"]))
   $product_id = get_post("product_id");
   $product_name = get_post("product_name");
   $weight = get_post("weight");
   $stock = get_post("stock");
   $price = get_post("price");
 
 
$query = "INSERT INTO laptop_products VALUES" .
     "('$product_id', '$product_name', '$weight', '$stock', '$price')";
 
if (!mysql_query($query, $dbhandle))
    echo "INSERT failed: $query<br />" .
mysql_error() . "<br /><br />";
 
}
echo <<<_END
<form action="sqltest.php" method"post"><pre>
product_id   <input type="text" name="product_id" />
product_name <input type="text" name="product_name" />
weight       <input type="text" name="weight" />
stock        <input type="text" name="stock" />
price        <input type="text" name="price" />
             <input type="submit" name="ADD RECORD" />
</pre></form>
_END;
 
$query = "SELECT * FROM laptop_products";
$result = mysql_num_rows($query);
 
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
 
for ($j = 0 ; $j < $rows ; ++$j)
{
   $row = mysql_fetch_row($result);
   
   echo <<<_END
   <pre>
   product_id $row[0]
   product_name $row[1]
   weight $row [2]
   stock $row [3]
   price $row [4]
   </pre>
   <form action="sqltest.php" method="post">
   <input type="hidden" name="delete" value="yes" /
   <input type="hidden" name="price" value="$row[4]" />
   <input type="submit" value="DELETE RECORD" /></form>
   _END
}
   mysql_close($dbhandle);
    
   function get_post($var)
   {
   return mysql_real_escape_string($_POST[$var]);
   } 
   
?>
  • 6 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.