Re: Passing mysql table names to php functions?



kennthompson@xxxxxxxxx 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
.



Relevant Pages

  • Re: KDE 4.2 requires local MySQL Server
    ... If every applications starts its own copy of mysql, ... for example, GDBM, Berkeley DB and SQLite. ... I've read the reason ... One single MySQL instance as central storage for all applications ...
    (Fedora)
  • Re: INSERT statements not INSERTING when using mysql from python
    ... One partial explanation might be that for some reason it is recreating ... a PSP script that makes many calls to populate a database. ... Then I execute many insert statements in various different loops on ... It occured to me that if I could access the mysql query log that might ...
    (comp.lang.python)
  • Re: Using Python for my web site
    ... research from "a few years ago", but ancient research is entirely ... That's exactly the reason why I added this information. ... PostgreSQL, in the past, has certainly had some hurdles ... MySQL, ...
    (comp.lang.python)
  • RE: [PHP] can you give me example of website using postgresql database?
    ... knowing the reason is asinine. ... less clustering. ... should scare you more than Sun's purchase of MySQL. ... Personally I'll stick with Firebird even though switching between engines is ...
    (php.general)
  • Re: MySQL and flock
    ... while the files protect against data issues, ... different versions of mysql. ... If you really, really need copies of the files for some reason, the ... the server, make your copies, and restart the server. ...
    (perl.beginners)