Re: Trouble passing mysql table name to php function and using it!



..oO(kennthompson@xxxxxxxxx)

On Feb 27, 10:27 am, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:

What happens if you do the following:

function fms_get_info($tableName)
{
$sql = "select * from $tableName";
[...]

No. That's exactly the way I was trying to do it.

Then it would work, assuming that $tableName contains a proper table
name.

MySQL doesn't accept
a table name passed into a function this way.

It doesn't matter whether the table name is hard-wired or stored in a
variable. The final query string as seen by MySQL will be the same.

There must be some
hidden mysql code that I'm unaware of.

Nope. Just make use of the error reporting features that PHP/MySQL
offer.

Micha
.