[PHP-DB] ? SELECT TABLE Command

2007-09-10 Thread Alec S.
Hi,

I've got a PHP program I wrote a year or so ago with the oddest line of code.  I
know I didn't come up with it myself; I must have adapted it from a book or
something, but I have checked all the books it could have come from and could
not find it in any of them, nor can I find any such command anywhere else.  It
is an SQL query (probably MySQL, but perhaps SQLite or possibly even PGSQL or
mSQL):

$query=SELECT TABLE $tablename;;
if (mysql_query($query, $link)) {
 echo($indent.The table, '$tablename', was successfully opened.br /\n);
}

To make things even stranger, it works fine in the original program that I put
it in (although what, if anything, it does is beyond me), but fails when I try
it in another program (yes, I took care of $tablename).


Does anyone have any idea where this bizarre piece of code came from, what it
does, if it's valid, or why it works even though such a command does not even
seem to exist?  This is has had me baffled for several months now.


Thanks.

-- 
Mike W.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] ? SELECT TABLE Command

2007-09-10 Thread Chris


Please fix your reply-to address.


It
is an SQL query (probably MySQL, but perhaps SQLite or possibly even PGSQL or
mSQL):


The line after $query should tell you what uses it ;)


$query=SELECT TABLE $tablename;;
if (mysql_query($query, $link)) {
 echo($indent.The table, '$tablename', was successfully opened.br /\n);
}

To make things even stranger, it works fine in the original program that I put
it in (although what, if anything, it does is beyond me), but fails when I try
it in another program (yes, I took care of $tablename).


What's the exact query that's run? Maybe $tablename contains more than 
just a table name.


Different mysql version? Maybe it was in an older version of mysql but 
they removed it.


It doesn't work in mysql5 or mysql4.0, maybe it does in an older version 
though.



Looks like you're trying to check that the mysql user you connected as 
has access to that table.


--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] ? SELECT TABLE Command

2007-09-10 Thread Mike W.
Chris wrote (in news:[EMAIL PROTECTED]):

  It is an SQL query (probably MySQL, but perhaps SQLite or possibly even
PGSQL or mSQL):

 The line after $query should tell you what uses it ;)

Sorry, I meant the book may have been about any of those; I was skimming through
a bunch of SQL books at that time and don’t know which one I got it from.

  $query=SELECT TABLE $tablename;;
  if (mysql_query($query, $link)) {
   echo($indent.The table, '$tablename', was successfully opened.br
/\n); }
 
  To make things even stranger, it works fine in the original program that I
  put it in (although what, if anything, it does is beyond me), but fails
  when I try it in another program (yes, I took care of $tablename).

 What's the exact query that's run? Maybe $tablename contains more than just a
table name.

Nope, it’s just

SELECT TABLE lyrics;

 Different mysql version? Maybe it was in an older version of mysql but they
removed it.

 It doesn't work in mysql5 or mysql4.0, maybe it does in an older version
though.

 Looks like you're trying to check that the mysql user you connected as has
access to that table.

It really feels like a command I may have used in the SQLite analyzer or
something.  However, I’m sure I copied it from an example script in a book.  I’
ve put holds on all the books on PHP and (My)SQL at the library and will check
them all.

-- 
Mike W.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php