You are here: Re: Passing mysql table names to php functions? « All PHP « IT news, forums, messages
Re: Passing mysql table names to php functions?

Posted by kennthompson on 02/27/07 18:18

On Feb 27, 10:56 am, "J.O. Aho" <u...@example.net> wrote:
> kennthomp...@gmail.com wrote:
> > The name passes -- the echo test works; it just won't work as a mysql
> > table. The variable is getting there, but mysql for some reason does
> > not recognize it. I've read something about prepare and execute in
> > mysql, but not sure this is the answer to my problem.
>
> If your tables has other characters than a-z,A-Z,0-9 and - and _ then
> you should put `` around the variable
>
> $result = mysql_query("select * from `{$tableName}`");
>
> I think you should use a while-loop instead of the for-loop you are using
>
> while($row=mysql_fetch_array($result)) {
> /* do something */
> }
>
> --
>
> //Aho

No. That won't work either. I need to add one more thing. To make the
stable version work I had to identify the old table name as global. I
think this looks simpler than it really is. I thought a simple
variable name could be passed as a table name, but there must be some
mysql code that allows it.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация