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>"; }
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
( ! ) 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 10PHP 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'].""; }
?>
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
1. You never terminated your line containingmysql_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
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
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
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