Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6

Thread: parser error

  1. #1
    Senior Member solidgold's Avatar
    Join Date
    Jun 2006
    Posts
    766
    Member #
    13373
    unfortunately i'm having a large problem with a guestbook script, for some reason this is the page displayed - http://aesthetic-design.co.uk/shout/guestbook_sign.php
    does anybody know how i can fix it?
    thanks,
    Solidgold
    PHP Code:
    <html>
    <head>
    </head>
    <body>
    <?php
     
    $self 
    $_SERVER ['PHP_SELF'];
    $name $_POST['name'];
    $email $_POST['email'];
    $comments $_POST['comments'];
    $submit $_POST['submit'];
    #the html form
    $form "<form action\"$self\" method=\"post\">";
    $form.= "Name: <input type=\"text\" name=\"name\" ";
    $form.= "size=\"50\" value=\"$name\"> <br>";
    $form.= "Email: <input type=\"text\" name=\"email\" ";
    $form.= "size=\"50\" value=\"$email\"> <br>";
    $form.= "comments:<br>";
    $form.= "<textarea name=\"comments\" cols=\"45\" ";
    $form.= "rows=\"4\">$comments</textarea> <br>";
    $form.= "<input type=\"submit\" name=\"submit\" ";
    $form.= "value=\"Sign\"></form>
    #on first opening display the form
    if ( !
    $submit) { $msg = $form; }
    #or redisplay a message and the form if incomplete
    else if ( !
    $name or !$email or !$comments);
    $msg = "<b>Please complete all fields</b><br><br>";
    $msg.= $form; }
    else
    $conn = @mysql_connect( "host", "data_base", "password" )
    or die( "
    could not connect" );
    $rs = @mysql_select_db( "data_base", $conn )
    or die ( "
    could not select database" );
    if( 
    $name and $comments )
    {
    $sql ="insert into guestbook (nameemailcomments)
    values(\"$name\", \"$email\", \"$comments\")";
    $rs = @mysql_query$sql$conn )
    or die ( 
    "could not execute sql query" ); }
    if(
    $rs)
    $msg "<h3>Thank you, your entry has been saved.";
    $msg.= "<br><a href=\"guestbook.php\">";
    $msg.= "View guestbook</a></h3>"; }
    }
    echo( 
    $msg );
    ?>
    </body>
    </html>
    there are quite a few errors in the code that I havent picked up on - being so rubbish at php - if you could point them out to me it would be great!

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, as you might have noticed from the syntax highlighting in your post, there's an unfinished string -- you forgot a closing " at the end of the last $form .= bit.

  4. #3
    Senior Member solidgold's Avatar
    Join Date
    Jun 2006
    Posts
    766
    Member #
    13373
    i've changed that but still get an error message:
    PHP Code:
    <html>
    <head>
    </head>
    <body>
    <?php
     
    $self 
    $_SERVER ['PHP_SELF'];
    $name $_POST['name'];
    $email $_POST['email'];
    $comments $_POST['comments'];
    $submit $_POST['submit'];
    #the html form
    $form "<form action\"$self\" method=\"post\">";
    $form.= "Name: <input type=\"text\" name=\"name\" ";
    $form.= "size=\"50\" value=\"$name\"> <br>";
    $form.= "Email: <input type=\"text\" name=\"email\" ";
    $form.= "size=\"50\" value=\"$email\"> <br>";
    $form.= "comments:<br>";
    $form.= "<textarea name=\"comments\" cols=\"45\" ";
    $form.= "rows=\"4\">$comments</textarea> <br>";
    $form.= "<input type=\"submit\" name=\"submit\" ";
    $form.= "value=\"Sign\"></form>";
    #on first opening display the form
    if ( !$submit) { $msg $form; }
    #or redisplay a message and the form if incomplete
    else if ( !$name or !$email or !$comments);
    $msg "<b>Please complete all fields</b><br><br>";
    $msg.= $form; }
    #or add the form data to the guestbook database table
    else #otherwise connect to mysql
    $conn = @mysql_connect"host""data_base""password" )
    or die( 
    "could not connect" );
    $rs = @mysql_select_db"data_base"$conn )
    or die ( 
    "could not select database" );
    if( 
    $name and $comments )
    {
    $sql ="insert into guestbook (name, email, comments)
    values(\"
    $name\", \"$email\", \"$comments\")";
    $rs = @mysql_query$sql$conn )
    or die ( 
    "could not execute sql query" ); }
    if(
    $rs)
    $msg "<h3>Thank you, your entry has been saved.";
    $msg.= "<br><a href=\"guestbook.php\">";
    $msg.= "View guestbook</a></h3>"; }
    }
    echo( 
    $msg );
    ?>
    </body>
    </html>

  5. #4
    Senior Member solidgold's Avatar
    Join Date
    Jun 2006
    Posts
    766
    Member #
    13373
    i've sorted it - all it was was a semi-colon in the wrong place, oh well!
    you can have a look at what i made (prior to any styling) here at http://aesthetic-design.co.uk/shout/guestbook_sign.php

    thanks for your help!

  6. #5
    Senior Member Ferro's Avatar
    Join Date
    Oct 2006
    Location
    UK
    Posts
    386
    Member #
    14204
    Liked
    5 times
    Quote Originally Posted by solidgold
    i've sorted it - all it was was a semi-colon in the wrong place, oh well!
    Isn't that always the way ...... :laugh:.

  7. #6
    Senior Member solidgold's Avatar
    Join Date
    Jun 2006
    Posts
    766
    Member #
    13373
    haha yeah


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:41 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com