You are here: Re: Trouble passing mysql table name to php function and using it! « PHP Programming Language « IT news, forums, messages
Re: Trouble passing mysql table name to php function and using it!

Posted by Rik on 02/28/07 01:31

Tim Streater <timstreater@waitrose.com> wrote:
>> But here you go:
>> function fms get info($tableName){
>> $qry =3D "SELECT * FROM `{$tableName}`";
>> $res =3D 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, i=
t =

doesn't cost anything extra, and you're always sure you haven't forgotte=
n =

when using array values or object properties.
-- =

Rik Wasmus

 

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

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