Sw0rDz Posted March 1, 2005 Share Posted March 1, 2005 I used this following script to make a review page.. It didn't work and came up with the following error <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php $self = $_POST['PHP_SELF']; $name = $_POST['nick']; $game = $_POST['game']; $review = $_POST['review']; #the html form $form = "<form action=\"self\" methd=\"post\">"; $form.= "Nick: <input type=\"text\" name=\"nick\" "; $form.= "size=\"50\" value=\"name\"> <br>"; $form.= "Game: <input type=\"text\" name=\"game\" "; $form.= "size=\"50\" value=\"game\"> <br>"; $form.= "Review: <br>"; $form.= "textare name=\"review\" cols=\"45\" "; $form.= "rows=\"4\">$review</textarea> <br>"; $form.= "<input type=\"submit\" name=\"submit\" "; $form.= "value=\"add\"> </form>"; #on first opening display the form if( !$submit) { $msg = $form; } #or redisplay a message and the form if incomplete else if( !$nick or !$game or !$review) { $msg = "<b>Please comlete all fields</b><br><br>"; $msg.= $form; } #or add the form data to the review database table else #otherwise connect to mysql { $conn = @mysql_connect( "localhost", "sw0rdz", "Mysecret" ) or die( "could not connect to database"; ); #select the database $rs = @mysql_select_db( "sw0rdz_nintendoplace", $conn ) or die ( "could no select database" ); #create the sql query if( $name and $review ) { $sql ="insert into reviews (nick, game, review) values(\"$nick\",\"#$game\",\"review\")"; $rs = @mysql_query( $sql, $conn ) or die ( "could not execute sql query" ); } #confrim entry and display a link to view review if ($rs) { $msg = "<h3>Thank you - your enty has been saved."; $msg.= "<br><a hred =\"index\">"; $msg.= "Go hom</a></h3>"; } } #write the page echo( $msg ); ?> </body> </html> the error Parse error: parse error, unexpected ';' in /usr/home/sw0rdz/domains/nintendoplace.com/public_html/review.php on line 38 The page is at Review if its not to hard please help.. Quote Link to comment https://forums.phpfreaks.com/topic/2182-php-help/ Share on other sites More sharing options...
nlyman Posted March 2, 2005 Share Posted March 2, 2005 Check your code where: #or add the form data to the review database table else #otherwise connect to mysql { $conn = @mysql_connect( "localhost", "sw0rdz", "Mysecret" ) or die( "could not connect to database"; ); it should be... #or add the form data to the review database table else #otherwise connect to mysql { $conn = @mysql_connect( "localhost", "sw0rdz", "Mysecret" ) or die( "could not connect to database" ); one too many ";"... -Nate I used this following script to make a review page.. It didn't work and came up with the following error <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <body> <?php $self = $_POST['PHP_SELF']; $name = $_POST['nick']; $game = $_POST['game']; $review = $_POST['review']; #the html form $form = "<form action=\"self\" methd=\"post\">"; $form.= "Nick: <input type=\"text\" name=\"nick\" "; $form.= "size=\"50\" value=\"name\"> <br>"; $form.= "Game: <input type=\"text\" name=\"game\" "; $form.= "size=\"50\" value=\"game\"> <br>"; $form.= "Review: <br>"; $form.= "textare name=\"review\" cols=\"45\" "; $form.= "rows=\"4\">$review</textarea> <br>"; $form.= "<input type=\"submit\" name=\"submit\" "; $form.= "value=\"add\"> </form>"; #on first opening display the form if( !$submit) { $msg = $form; } #or redisplay a message and the form if incomplete else if( !$nick or !$game or !$review) { $msg = "<b>Please comlete all fields</b><br><br>"; $msg.= $form; } #or add the form data to the review database table else #otherwise connect to mysql { $conn = @mysql_connect( "localhost", "sw0rdz", "Mysecret" ) or die( "could not connect to database"; ); #select the database $rs = @mysql_select_db( "sw0rdz_nintendoplace", $conn ) or die ( "could no select database" ); #create the sql query if( $name and $review ) { $sql ="insert into reviews (nick, game, review) values(\"$nick\",\"#$game\",\"review\")"; $rs = @mysql_query( $sql, $conn ) or die ( "could not execute sql query" ); } #confrim entry and display a link to view review if ($rs) { $msg = "<h3>Thank you - your enty has been saved."; $msg.= "<br><a hred =\"index\">"; $msg.= "Go hom</a></h3>"; } } #write the page echo( $msg ); ?> </body> </html> the error Parse error: parse error, unexpected ';' in /usr/home/sw0rdz/domains/nintendoplace.com/public_html/review.php on line 38 The page is at Review if its not to hard please help.. 209265[/snapback] Quote Link to comment https://forums.phpfreaks.com/topic/2182-php-help/#findComment-7182 Share on other sites More sharing options...
samuraisam Posted March 8, 2005 Share Posted March 8, 2005 I would add \n (newlines) in your $form so that it doesn't all turn out on one HTML line (very frustrating to look at and debug for validation). -Sam Quote Link to comment https://forums.phpfreaks.com/topic/2182-php-help/#findComment-7205 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.