mattyd Posted October 19, 2010 Share Posted October 19, 2010 Upon running my code online I receive the following error: Parse error: syntax error, unexpected ';' in /home/a4542527/public_html/create.php on line 13 indicating that the semicolon (to the right of or die(mysql_error())) in the following code is in error: create.php <?php include 'connection.php'; $name= $_Post['inputName']; $descrip= $_Post['inputDesc']; if(!$_Post['submit']){ echo "Please fill out the review"; header('Location: index.php'); } else{ mysql_query("INSERT INTO people (`id`,`name`,`descrip`) VALUES(NULL, '$name', '$descrip')" or die(mysql_error()); echo "Your review has been added"; header('Location: index.php'); } ?> If I remove this semicolon and run the code, I receive this error: Parse error: syntax error, unexpected T_ECHO in /home/a4542527/public_html/create.php on line 14 I'm not sure what I'm doing wrong. (When this script runs it allows for two text boxes to be displayed. After text is entered and submitted, the said text will be displayed on the screen. Below are the two other associated files that I'm using.) index.php <?php include 'connection.php'; $query = "SELECT * FROM people"; $result = mysql_query($query) or die(mysql_error()); while ($person = mysql_fetch_array($result)){ echo $person ['name']; echo $person ['descrip']; } ?> connection.php <?php $dbhost = 'mysql7.000webhost.com'; $dbuser = 'a4542527_root'; $dbpass = '*******'; $db = 'a4542527_test1'; $conn = mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($db); ?> Thank-you in advance for any help or pointer in the right direction. ~Matty Quote Link to comment Share on other sites More sharing options...
Mchl Posted October 19, 2010 Share Posted October 19, 2010 Count your () carefully. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 You're missing a parenthesis '$descrip') )" <-- here Quote Link to comment Share on other sites More sharing options...
mattyd Posted October 19, 2010 Author Share Posted October 19, 2010 Thank-you for everyone's help. I do appreciate it. I added the '$descrip') ) as noted above but am still receiving the error message related to an unexpected ';' Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 Oops. Move the double quote in between the parentheses . . . Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 This is actually one of the reasons I always separate the query string from the query execution. It makes finding these types of errors much easier, and allows you to echo the query string easily when something craters. $query = "SELECT `field` FROM `table`"; $result = mysql_query($query) or die('<br>Query string: ' . $query . '<br>Produced error: ' . mysql_error() . '<br>'); Note however, that echoing all that information shouldn't be done on a live site, only during development. Quote Link to comment Share on other sites More sharing options...
mattyd Posted October 19, 2010 Author Share Posted October 19, 2010 I have adjusted the code now to where the noted error messages do not appear when running the code; The two text boxes appear. I am able to enter text and select the submit button without error. But, now, the problem is the overall functionality: The entered data should be added to the DB and also displayed on the screen. (I am following a tutorial for this and have done everything correctly I believe). Now I just have to figure out why it is not writing to the database and why it is not displaying (*Thank-you for your patience, I am a newbie to PHP/MYSQL) ~Matty Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted October 19, 2010 Share Posted October 19, 2010 There is no such superglobal as $_Post. It's $_POST. Variables are case-sensitive, functions aren't. Quote Link to comment Share on other sites More sharing options...
mattyd Posted October 19, 2010 Author Share Posted October 19, 2010 There is no such superglobal as $_Post. It's $_POST. Variables are case-sensitive, functions aren't. Thank-you so much for your help - that worked perfectly! Very exciting I appreciate it. Quote Link to comment 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.