Jump to content

Syntax error.. confused?


TeddyKiller

Recommended Posts

                $update = mysql_query("update `sent_messages` set `status`='read' where `to_id`='$user->id' and `id`='$id'");
                if($update){
                    $mail = $user->unread_mail-1;
                    $update2 = mysql_query("update `users` set unread_mail='$mail' where `id`='$user->id'"); `
                }

 

The code works if I remove the if statement, and the contents in it.

Though if I have it there.. for some reason it brings up an error for line 407. Now line 407 is completely different.

Parse error:  syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/jeanie/public_html/mail.php on line 407

echo'<div style="width:400px; float:right; padding:7px 0 7px 0;">Date: '.date('d.m.y H:i', $row['date']).'<br />To: <a href="#">'.ucwords($r['username']).'</a><br />From: <a href="#">'.ucwords($rw['username']).'</a><br />Subject: <a href="#">'.ucwords($row['subject']).'</a><br /></div>';

 

I dont quite understand this?

Link to comment
Share on other sites

When these sorts of "mysterious" errors happen, it's almost always caused by some erroneous quote somewhere (or curly brace, etc.).  What happens is that it causes the interpreter (or compiler -- depending on the language/case) to expect that one particular code construct has begun.  It may be the case that it expects the construct to end on the next line of code, or 15 lines of code later.  Who knows.

 

Take a look at the second line in your if statement.  You appear to have a random backtick at the very end of the line.  There is a semicolon, then a space, and then a backtick:

 

$update2 = mysql_query("update `users` set unread_mail='$mail' where `id`='$user->id'"); `

 

php is probably expecting you to close that backtick at some point in time later and that is why it complains about the seemingly unrelated line.

 

Also, I'm not really sure why you have the backticks around users and id.  I don't think they are necessary are they?  You might want to change that line of code to this:

 

$update2 = mysql_query("update users set unread_mail='$mail' where id='$user->id'");

Link to comment
Share on other sites

Oh I didn't notice that, but that wasn't the problem unfortunately..

if($update){
$mail = $user->unread_mail-1;
$update2 = mysql_query("update users set unread_mail='$mail' where id='$user->id'"); `
}

 

Still same error. Hasn't budged...

 

EDIT:

Ohhhh!!! That backtick is pretty hidden! Wow.. how in earth did I manage to put that there.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.