Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Parse error???

  1. #1
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Parse error???

    I wanted to create a shout box,
    I created 4 files: shoutbox.php, connect.php, show_shout.php and box.htm.
    --------------------------------------------------------------------------------------------------------
    shoutbox.php:

    PHP Code:
    <?php
    include("connect.php")
    if(isset(
    $_POST["posted"]))
    {
    $name $_POST["name"];
    $message $_POST["message"];
    $time time();
    $ip $_SERVER["REMOTE_ADDR"]
    $check_name_length strlen($name); // checks length
    $check_message_length strlen($message); // checks length
    If($check_name_length => 30) || if($check_message_length => 250// if statements for length
    {
    echo 
    "Please fill in the textboxes properly.";
    }
    else {
    mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES ("NULL","$ip", "$name", "$time", "$message")") or die ("Failed to add shout");
    }
    }
    ?>
    --------------------------------------------------------------------------------------------------------
    connect.php:

    PHP Code:
    <?php
    $connect 
    mysql_connect("localhost","shachi","thisistest") or die("Failed to connect to host")
    $db mysql_select_db("freemys_shachi") or die("Failed to connect to database");
    ?>
    --------------------------------------------------------------------------------------------------------
    show_shout.php:

    PHP Code:
    <?php
    include("connect.php");
    $query Mysql_query("SELECT * FROM shoutbox DESC id LIMIT 5");
    while(
    $r Mysql_fetch_array($query)
    {
    $time $r["time"];
    $name $r["name"];
    $message $r["message"];
    }

    echo 
    "Shout by $name at $time:";
    echo 
    $message;
    ?>
    --------------------------------------------------------------------------------------------------------
    box.htm:

    HTML Code:
    <html>
    <body>
    <form method="POST" action="shoutbox.php">
    Name: <input type="text" name="name"> <!--//field with the name "name"--><br>
    Message <input type="text" name="message"> <!--//field with the name "message"--><br>
    <input type="hidden" name="posted" value="true"> <!--// hidden form field containing value "true"--><br>
    <input type="submit" value="Shout!">
    </body>
    </html>
    --------------------------------------------------------------------------------------------------------

    When I tried to post from box.htm it shows a parse error:

    Parse error: parse error, unexpected T_IF in /var/www/shoutbox.php on line 3

    I don't know what the problem is, someone plz help.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    PHP Code:
    $ip $_SERVER["REMOTE_ADDR"
    You missed a semicolon.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    It's still saying the same parse error:

    Parse error: parse error, unexpected T_IF in /var/www/shoutbox.php on line 3

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by shachi
    It's still saying the same parse error:
    You did the same thing in connect.php when calling the mysql_connect function.

    Mike

  5. #5
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by mwinter
    You did the same thing in connect.php when calling the mysql_connect function.

    Mike
    I actually didn't get you. Can you make this a little clear for me please?

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    PHP Code:
    include("connect.php"
    You missed one there, too.
    PHP Code:
    $connect mysql_connect("localhost","shachi","thisistest") or die("Failed to connect to host"
    And there.

    PHP Code:
    mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES ("NULL","$ip", "$name", "$time", "$message")") or die ("Failed to add shout"); 
    You need to escape those quotes:
    PHP Code:
    mysql_query("INSERT INTO shoutbox( id, ip, name, time, message) VALUES (\"NULL\",\"$ip\", \"$name\", \"$time\", \"$message\")") or die ("Failed to add shout"); 
    Last edited by Twey; 09-26-2005 at 03:42 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Aug 2005
    Posts
    971
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks Twey but I got another problem there.
    It shows another parse error:


    Parse error: parse error, unexpected T_DOUBLE_ARROW in /var/www/shoutbox.php on line 11

    Line no. 11: If($check_name_length => 30) || if($check_message_length => 250) // if statements for length

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The operator is >=. => means something rather different.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    "The operator is >=. => means something rather different."

    Sad face and happy face, obviously.
    -cr3
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  10. #10
    Join Date
    Oct 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    The operator is >=. => means something rather different.

    Dear Twey, Thanx for being so helpful. U're the man.
    Ok please help me when u finnish with the girl .

    my error is : Parse error: parse error, unexpected $end in C:\Domains\nurusyifa.com\wwwroot\wp-content\themes\wp-andreas01-12\index.php on line 52

    It appear after i make some adjustment on header wordpress ...and such.

    please help me solve this dear mates and forumner. trillion thanxs in advance

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •