• Syntax error, PHP unexpected T_STRING
    15 replies, posted
Now this error happened to me before, it was easy to fix, now I have it again. But it seems totally out of place. The complete error: [code] Parse error: syntax error, unexpected T_STRING in XXX/XXX/XXX/cities.php on line 1 [/code] now the whole file is this: [lua] <?php function GetCityCount() { $count = 0; $query = 'SELECT * FROM cities WHERE id=\''.$uid.'\''; $result = mysql_query($query); $numrows = mysql_num_rows($result); //$count = $numrows; return $numrows; } ?> [/lua] Very misleading, before I got an error about an $end variable on line 1. Could anyone help me?
Try [php] function GetCityCount($uid){ $uid = mysql_real_escape_string($uid); $query = "SELECT * FROM cities WHERE id='".$uid."'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); return $numrows; } [/php]
Nope, same error. And I don't need to escape it. The uid is from a decrypted string from facebook. And the key is secret. [editline]06:31PM[/editline] And thanks for the try! [editline]06:53PM[/editline] I fixed it by adding $_TEST = 'LOL'; at the beginning. Now it works, really strange error + Code
How about the rest of your code and the errors?
I meant that the error is strange, and the error code too. No more errors now! But thanks.
Show whole code
Err.. Sure, as said I just added a variable declaration at the top: [lua] <?php $_TEST = 'LOL'; function GetCityCount($uid){ $uid = mysql_real_escape_string($uid); $query = "SELECT * FROM cities WHERE id='".$uid."'"; $result = mysql_query($query); $numrows = mysql_num_rows($result); return $numrows; } ?> [/lua]
That doesn't make any sense. Why would adding "$_TEST = 'lol'" fix it? It's not used anywhere
It bothers me that 1) this happened at all and 2) that it was fixed in this manner...
Would it be possible that, due to the encoding he used with the file, there were some characters that were not visible in the text editor?
I will try to re-produce it, what encoding should I use? I am using ANSI currently. [editline]04:59PM[/editline] Ok, I can't re-create it, strange...
[QUOTE=Dragory;24634953]Would it be possible that, due to the encoding he used with the file, there were some characters that were not visible in the text editor?[/QUOTE] That is the only possibility I can agree with. That is most likely what happened... @OP Can you re-break the file, and upload it so I (we) can examine it?
[url]http://file-hero.com/?id=09201732703652[/url] THere you go!
Likely that the file wasn't uploaded to the ftp server (through some error, happens to me sometimes) when you fixed the first one (nivek's fix) and when you added $_test = "LOL" and uploaded it it uploaded correctly. May have nothing to do with it.
[QUOTE=supersnail11;24700645]Likely that the file wasn't uploaded to the ftp server (through some error, happens to me sometimes) when you fixed the first one (nivek's fix) and when you added $_test = "LOL" and uploaded it it uploaded correctly. May have nothing to do with it.[/QUOTE] What are you talking about? [editline]10:13PM[/editline] [QUOTE=commander204;24667789][url]http://file-hero.com/?id=09201732703652[/url] THere you go![/QUOTE] Could have just said it's the same as the OP code. Use my code, You aren't defining the $uid var before you use it. Also what is this being combined with, show me the ENTIRE code, show me what you're using this function with.
It is not defined here, cause I define it somewhere else. The point is, when I upload the file in the zip, it errors, I upload another one, WITH the same content, I don't get it. So yeah. Anyway this is fixed.
Sorry, you need to Log In to post a reply to this thread.