NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP Error - Need Help Debugging

Anirudh Zala arzala at gmail.com
Thu Apr 13 00:24:12 EDT 2006


Yes, reason is pretty obvious that you have misused quotes as well your  
didn't close that mathematical expression with parenthesis that determines  
limit part of sql.

I strongly recommend you to first learn how to write php statements with  
proper syntax. For that you must understand what is exact use of " and '  
in writing any statement. " is used to evaluate any given php, in fact in  
most of programming languages, statement while ' used to take given  
statement or part of statement as it is. Same applies to mysql and most of  
databases as well. In your case you have used " everywhere even when it is  
not required at all. So in context of php, your statement could look like  
below.

$checkreplies='SELECT posts.postid, posts.subject, posts.body,
posts.created, users.userid, users.username, users.aim, users.created,
users.admin FROM posts, users WHERE posts.postid='.$_GET['id'].' AND
posts.userid=users.userid AND posts.replyto='.$_GET['postid'].' LIMIT
'.(($pagecount - 1) * 10 - 1).',10';

Some other points to be kept in mind while using arrays is that you should  
always enclose keys of all array by necessary " or ' depending upon same  
rule mentioned above. So $_GET[id] should be $_GET['id'], otherwise if key  
"id" of this array is defined as constant somewhere in your script, GET  
array will use it's value as key and you will get different result than  
what you expect. And of course also try to consider tips given by Chris  
and Lee.

I hope YouAlsoAgree at above suggestions. :)

Thanks
Anirudh Zala

On Thu, 13 Apr 2006 06:25:02 +0530, <IAlsoAgree at stny.rr.com> wrote:

> I'm sure it's going to be something really obvious, but for now I just
> can't seem to figure out what it is.
>
> I'm getting the following error:
> Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
>
> The line of code is:
> $checkreplies = "SELECT posts.postid, posts.subject, posts.body,
> posts.created, users.userid, users.username, users.aim, users.created,
> users.admin FROM posts, users WHERE posts.postid = \"$_GET[id]\" AND
> posts.userid = users.userid AND posts.replyto = $_GET[postid] LIMIT
> ".($pagecount-1)*10-1.", 10";
>
>> From what I can gather, it sounds like I misused a double quote or
> misplaced a peroid. But looking at the code, I can't see where I did
> either wrong.
>
> Anyhelp would be appreciated.
>
> Thanks,
> -Joe
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> New York PHP Conference and Expo 2006
> http://www.nyphpcon.com
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php



-- 
-----------------------------------------------
Anirudh Zala (Project Manager)
ASPL, http://www.aspl.in
Ph: +91 281 245 1894
arzala at gmail.com
-----------------------------------------------



More information about the talk mailing list