dannymadatgravity Posted June 3, 2010 Share Posted June 3, 2010 Hi I am just starting to learn PHP and I am banging my head against the wall because I get Parse error: syntax error, unexpected $end in C:\web\update_data_test.php on line 94 somewhere in.... <?php require_once 'login.php'; $db_server = mysql_connect ($db_hostname, $db_username, $db_password); if (!$db_server) die("Unable to connect to server, check username in login.php:" .mysql.error()); else echo "Connection to server sucessfull <br>" ; mysql_select_db($db_database, $db_server) or die ("Connection to database failed: " . mysql_error()); if (isset($_POST['author']) && isset($_POST['title']) && isset($_POST['catergory']) && isset($_POST['year']) && isset($_POST['isbn'])) { $author = get_post('author'); $title = get_post('title'); $catergory = get_post('catergory'); $year = get_post('year'); $isbn = get_post('isbn'); if (isset($_POST['delete']) && $isbn !="") { $query = "DELETE FROM danielsbooks WHERE isbn='$isbn'"; if (!mysql_query($query, $db_server)) echo "DELETE failed: $query <br />". mysql_error() . "<br /><br />"; } else { $query ="INSERT INTO danielsbooks VALUES" . "('$author', '$title','$catergory','$year','$isbn')"; if (!mysql_query($query, $db_server)) echo "INSERT failed: $query <br>". mysql_error(). "<br><br>"; } } echo <<<_END <form action="update_data_test.php" method="post"> <pre> Author <input type="text" name="author" /> Title <input type="text" name="title" /> catergory <input type="text" name="catergory" /> year <input type="text" name="year" /> isbn <input type="text" name="isbn" /> <input type="submit" Value="ADD RECORD" > </pre> </form> _END; $query = "SELECT * FROM danielsbooks"; $result = mysql_query($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> Author $row[0] Title $row[1] Catergory $row[2] Year $row[3] isbn $row[4] </pre> <form action "update_data_test.php" method ="post"> <input type="hidden" name="delete" value="yes" /> <input type="hidden" name="isbn" value="$row[4]" /> <input type="submit" value="DELETE RECORD" /> </form> _END; } mysql_close($db_server); function get_post($var) { return mysql_real_escape_string($_POST[$var]); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/203808-help-please-parse-error-syntax-error-unexpected-end-in-cwebupdate_data_t/ Share on other sites More sharing options...
TOA Posted June 3, 2010 Share Posted June 3, 2010 somewhere in.... It tells you where... on line 94 Now, what that means, I'm not sure. Do an internet search and see what pops up and tell us. Quote Link to comment https://forums.phpfreaks.com/topic/203808-help-please-parse-error-syntax-error-unexpected-end-in-cwebupdate_data_t/#findComment-1067437 Share on other sites More sharing options...
dabaR Posted June 4, 2010 Share Posted June 4, 2010 It means you did not close a brace. Can you post the file as an attachment instead of this, please. It is hard to format it this way. Quote Link to comment https://forums.phpfreaks.com/topic/203808-help-please-parse-error-syntax-error-unexpected-end-in-cwebupdate_data_t/#findComment-1067448 Share on other sites More sharing options...
codebyren Posted June 4, 2010 Share Posted June 4, 2010 It looks like it is your heredoc syntax causing the problem. See here: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc I can't recall if you can use the '_' character in the heredoc trigger. Try without it and also make sure there is no whitespace whatsoever before the closing heredoc tag: print <<<EOT your stuff here.. EOT; // notice how there is no space before EOT; Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/203808-help-please-parse-error-syntax-error-unexpected-end-in-cwebupdate_data_t/#findComment-1067453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.