Jump to content

Archived

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

Sw0rDz

php help

Recommended Posts

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..

Share this post


Link to post
Share on other sites

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]

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

×

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.