BrainBoxMad Posted July 2, 2013 Share Posted July 2, 2013 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]); } ?> Link to comment https://forums.phpfreaks.com/topic/279792-unexpected-end-of-file-error-please-help/ Share on other sites More sharing options...
chriscloyd Posted July 2, 2013 Share Posted July 2, 2013 When you use _END there and be no whitespaces before or after and has to be all the way to the left. Link to comment https://forums.phpfreaks.com/topic/279792-unexpected-end-of-file-error-please-help/#findComment-1439070 Share on other sites More sharing options...
normenclature Posted January 17, 2014 Share Posted January 17, 2014 Hi Chris, Would you mind giving me a call? I live in the Phoenix area and have a question for you... Norm Jones 480-567-5007 Link to comment https://forums.phpfreaks.com/topic/279792-unexpected-end-of-file-error-please-help/#findComment-1465517 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.