Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Messaging system, displaying the messages

  1. #11
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    You need to escape the double quotes.

    PHP Code:
    echo "<h3><i><a href=\"read_message2.php?ID=$row[message_id]\"> ".$row['message_title']."</a></i></h3>"; } 
    - Josh

  2. #12
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    PHP Code:
    <?php

    $id 
    mysql_escape_string($_GET['ID']);

    $query mysql_query("SELECT * FROM messages WHERE message_id='$id'") or 
    die(
    mysql_error());

    $row mysql_fetch_array ($query )

    echo 
    ".$row['message_content'].""; } 

    ?>
    ( ! ) Parse error: syntax error, unexpected T_ECHO in C:\Documents and Settings\Owner\Desktop\canberra amatuer productions\www\Canberra Amatuer Productions\edited pm\New Folder\read_message2.php on line 10


    That one works fine now , thanks JShor. What about this one?
    Last edited by keyboard; 08-26-2011 at 06:31 AM. Reason: Because I can't spell

  3. #13
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    1. You never terminated your line containing mysql_fetch_array() with a semicolon, indicating the statement is incomplete.

    2. You put two double quotes in your echo statement. Actually, you don't need quotes at all since you're just echoing one variable.

    Try this:
    PHP Code:

    $row 
    mysql_fetch_array ($query );

    echo 
    $row['message_content']; } 
    - Josh

  4. #14
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Also, you seem to be making a lot of syntax/logical errors. I recommend using a PHP IDE such as phpDesigner, which will check the syntax live for you. If you don't want to use payware, you could use eclipse. There is a plugin for eclipse for PHP syntax.
    - Josh

  5. #15
    Join Date
    Mar 2011
    Posts
    2,145
    Thanks
    59
    Thanked 116 Times in 113 Posts
    Blog Entries
    4

    Default

    Thanks JShor. One more thing. I've made two accounts on my website and when I login with the other one, (username= bob) I can still view all the messages adrresed to the other user. Any help

  6. #16
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    For that, you'll need to check whether the user that is viewing the message is either the sender or the receiver of the message.

    So if bob didn't send or receive the message they are viewing, then it would return an error like "You can't view this message, bob!".

    Here's a quick example based on your previous code (although I don't quite remember what field you named your sender (for explanation purposes, I named it from_user).

    PHP Code:
    $id mysql_escape_string($_GET['ID']);

    $message mysql_query("SELECT * FROM messages WHERE message_id='$id' AND (to_user = '$userfinal' OR from_user = '$userfinal')") or
    die(
    mysql_error()); 
    - Josh

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
  •