Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Script problem

  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Script problem

    PLEASE NOTE: Line 42 = the line with: if ($message==) { - I just didn't include my CSS, which would make if ($message==) { 42.

    My error:

    Parse error: syntax error, unexpected ')' in /home/a5488351/public_html/post.php on line 42

    My code:

    PHP Code:
    <?php

    $con 
    mysql_connect('''''') or die(mysql_errno());
    if (
    function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
    {
        
    $_POST array_map('stripslashes'$_POST);
    }

    $name mysql_real_escape_string($_POST['name']);
    $message mysql_real_escape_string($_POST['message']);

    if (
    $message==) {
        echo 
    "<div class='box'><b><span style='color:red'>You didn't enter a message!</span></b></div>";
    }
    else
    {
     
    //connect
    $connect mysql_connect("","","") or die("Connection failed!");
    mysql_select_db("") or die("Database fail!");

    //write
    $write mysql_query("INSERT INTO posts VALUES ('','$name','$message')") or die(mysql_eror());

    echo 
    "<div class='box'><font face='arial'><b><span style='color:green'>Posted! Your name was:</span> $name</b> - Your message was....<br><br><b>$message - <a href='index.php'>View it!</a></b>";
    }


    ?>
    Last edited by SRBuckey5266; 10-13-2009 at 08:33 PM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Just do this ... (no == )
    if ($message) {

  • #3
    New Coder
    Join Date
    Jan 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    But now when I enter a message, it still shows that box. See: http://www.chataddict.netau.net - WHY?!

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Try ...

    if(strlen($message) < 1){

    EDIT:

    or ...

    if(!$message){


    either one might work.


    .

  • #5
    New Coder
    Join Date
    Jan 2009
    Posts
    45
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Doesn't work.

    Edit: Nope, neither work. :/

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Repost your script, what you currently have now.


  •  

    Posting Permissions

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