Re: Trouble passing mysql table name to php function and using it!
- From: Rik <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Wed, 28 Feb 2007 02:31:12 +0100
Tim Streater <timstreater@xxxxxxxxxxxx> 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.
--
Rik Wasmus
.
- Follow-Ups:
- Re: Trouble passing mysql table name to php function and using it!
- From: Tim Streater
- Re: Trouble passing mysql table name to php function and using it!
- References:
- Trouble passing mysql table name to php function and using it!
- From: kennthompson
- Re: Trouble passing mysql table name to php function and using it!
- From: Jerry Stuckle
- Re: Trouble passing mysql table name to php function and using it!
- From: kennthompson
- Re: Trouble passing mysql table name to php function and using it!
- From: Rik
- Re: Trouble passing mysql table name to php function and using it!
- From: Tim Streater
- Trouble passing mysql table name to php function and using it!
- Prev by Date: Re: Has anyone ported Turck MMCache to PHP 5?
- Next by Date: Re: Trouble passing mysql table name to php function and using it!
- Previous by thread: Re: Trouble passing mysql table name to php function and using it!
- Next by thread: Re: Trouble passing mysql table name to php function and using it!
- Index(es):
Relevant Pages
|