Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3872
| From | The Natural Philosopher <tnp@invalid.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Hmm..why doesnt this work? |
| Date | 2011-11-22 17:24 +0000 |
| Organization | albasani.net |
| Message-ID | <jaglt2$k0v$1@news.albasani.net> (permalink) |
| References | <jaghhf$867$1@news.albasani.net> <jagi7c$ath$1@softins.clara.co.uk> |
Tony Mountifield wrote: > In article <jaghhf$867$1@news.albasani.net>, > The Natural Philosopher <tnp@invalid.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?
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Hmm..why doesnt this work? The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 16:10 +0000
Re: Hmm..why doesnt this work? The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 16:19 +0000
Re: Hmm..why doesnt this work? tony@mountifield.org (Tony Mountifield) - 2011-11-22 16:22 +0000
Re: Hmm..why doesnt this work? The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 17:24 +0000
Re: Hmm..why doesnt this work? tony@mountifield.org (Tony Mountifield) - 2011-11-22 17:44 +0000
Re: Hmm..why doesnt this work? The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 17:49 +0000
Re: Hmm..why doesnt this work? The Natural Philosopher <tnp@invalid.invalid> - 2011-11-22 17:57 +0000
csiph-web