NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP Error - Need Help Debugging

IAlsoAgree at stny.rr.com IAlsoAgree at stny.rr.com
Thu Apr 13 23:38:46 EDT 2006


Incorrect.

"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." -Anirudh Zala

This seems a tad insulting for no apparent reason. My choice of using
double quotes may not be neccessary, but makes the code a LOT easier to
read and easier to write.

So $_GET[id] should be $_GET['id']

I'd suggest that you "learn how to write php statements with proper
syntax" before telling me to do so.

For those that don't already know: when you use double quotes in PHP,
you CAN'T include the single quotes for an array unless you put the
array in brackets. Check http://www.php.net/ for further details on
including arrays in double quotes.

Thus, inside of double quotes, you need to do it as I have done (or as
{$_GET['id']}).

The problem was my code was lacking a pair of outer quotation marks
around the entire mathmatical operation. I used a different method to
get rid of the ".expression." I was having, but it still worked.

Thanks anyway though,
-Joe

----- Original Message -----
From: drydell at optonline.net
Date: Thursday, April 13, 2006 0:57 am
Subject: Re: [nycphp-talk] PHP Error - Need Help Debugging
To: NYPHP Talk <talk at lists.nyphp.org>

> the syntax error has to do with $_GET[id] and $_GET[postid]... 
> 
> WHERE posts.postid = \"{$_GET['id']}\" AND  posts.userid = 
> users.userid AND posts.replyto = {$_GET['postid']}  would fix the 
> syntax error
> 
> > 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
> > 
> _______________________________________________
> 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
> 



More information about the talk mailing list