FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Hmm..why doesnt this work?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Hmm..why doesnt this work? [message #176078 is a reply to message #176076] Tue, 22 November 2011 17:24 Go to previous messageGo to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
Tony Mountifield wrote:
> In article <jaghhf$867$1(at)news(dot)albasani(dot)net>,
> The Natural Philosopher <tnp(at)invalid(dot)invalid> wrote:
>>
>> $old=(mysql_fetch_assoc(mysql_query(sprintf(
>> "select login_name from employees where id='%d'",
>> $_POST['id']))))['id'];
>>
>>
>> Bitching about unexpected '['
>>
>> But mysql_fetch_assoc() returns an array so what's wrong with
>>
>> mysql_fetch_assoc()['id'];
>
> Or even (mysql_fetch_assoc())['id'] :-)
>

yes, well exactly

> Firstly, id isn't in the field list. Only login_name is. But that's
> semantic, not syntax.
>

Indeed, and that fixes the bug I was looking at now..thanks :-)


> But you shouldn't dereference the return value of mysql_fetch_assoc()
> without first checking it for success:
>

Yes, but the point is that syntactically I can't it seems.

And in this case, its guaranteed to succeed, because ...select....where
id='$id' has already succeeded...because that's how $_POST['id'] gets
set!!!.. and there's no WAY to delete a record in the programs that
access this database!

I suppose some one with admin privileges MIGHT hack it..but then FFS the
damage that could be dione is not something a simple error check could
repair anyway


The point remains. Why does mysql_fetch_assoc(.....)['name'] return a
SYNTAX error?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to get client mac address in PHP ..?
Next Topic: Thumbnails with PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 12:15:19 GMT 2024

Total time taken to generate the page: 0.04230 seconds