question about passing field name in sql statement as variable.
- From: "nephish" <nephish@xxxxxxxxx>
- Date: 30 Aug 2006 14:14:27 -0700
hey there,
can anyone tell me if this is legal php/mysql ?
i am trying to write a simple function to get a single stat from a
single table.
eg..
$field = 'phone_number';
$customer = 'fred';
$query = mysql_query("SELECT `'{$field}'` FROM `customers` WHERE `name`
= '{$fred}' ");
// note the back quotes around $field
or is this an accident waiting to happen ?
thanks.
.
- Follow-Ups:
- Re: question about passing field name in sql statement as variable.
- From: Andy Hassall
- Re: question about passing field name in sql statement as variable.
- Prev by Date: how to Replicate Session in new window?, target _blank
- Next by Date: Re: question about passing field name in sql statement as variable.
- Previous by thread: how to Replicate Session in new window?, target _blank
- Next by thread: Re: question about passing field name in sql statement as variable.
- Index(es):