|
Posted by Tim Streater on 02/28/07 09:50
In article <op.tofqiap6qnv3q9@misant>, Rik <luiheidsgoeroe@hotmail.com>
wrote:
> Tim Streater <timstreater@waitrose.com> wrote:
> >> But here you go:
> >> function fms get info($tableName){
> >> $qry = "SELECT * FROM `{$tableName}`";
> >> $res = mysql query($qry) or die($qry.' failed, mysql
> >> sais:'.mysql error());
> >> }
> >
> > Why does one need the back ticks and { ?? I would have expected one
> > could construct a query with:
>
> Backticks, to make sure it even works when a table has a reserved
> name('order' or something comes to mind). The accolades are just for my
> benefit: I've taken to it to always use them in double quoted strings, it
> doesn't cost anything extra, and you're always sure you haven't forgotten
> when using array values or object properties.
Ah, thanks, that's clear. In fact I don't usually have a variable
tablename when constructing a query so I haven't been hit by that.
But a question to the OP might be - what debugging have you done?
Whenever I get an oddity of this nature I usually spend some time
carefully debugging before posting about it.
-- tim
[Back to original message]
|