Jump to content


Photo

php help


  • Please log in to reply
2 replies to this topic

#1 Sw0rDz

Sw0rDz
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 01 March 2005 - 12:59 AM

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

#2 nlyman

nlyman
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 02 March 2005 - 12:37 AM

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

View Post



#3 samuraisam

samuraisam
  • Members
  • Pip
  • Newbie
  • 3 posts
  • LocationMontucky

Posted 08 March 2005 - 04:58 AM

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
Quality forums for your viewing and posting pleasure! Incomprehensible topics discussed among a close nit community of friends! SamuraiBlog.com! Where internet meets ronin!
SamuraiBlog.com :: SamuraiBlog.com Forums




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users