Welcome to WebmasterWorld Guest from 54.162.10.132

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

"SHOW TABLES FROM $database" doesn't work with underscores?workaround?

     
7:41 am on Apr 4, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 21, 2005
posts: 130
votes: 0


SHOW TABLES FROM '".$database_name."' 

I need to test for the existence of a table in the database. This query works fine as long as there are no underscores in the database-name.

Is there a workaround so that this script could deal with underscores in database-names?
11:35 am on Apr 4, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:945
votes: 0


Backticks, not quotes :)

$sql = 'SELECT TABLES FROM `' . $database_name . '`';
12:55 pm on Apr 4, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
posts:945
votes: 0


SHOW TABLES FROM**

Typo sorry, I was a little hung over when I wrote that :)
8:01 am on Apr 7, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Mar 15, 2010
posts:57
votes: 0


Just enter a row into the table assuming it exists, if the row is successfully added then it exists else it does not exist.
8:06 am on Apr 7, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


This is the trouble with duplicates:-

[webmasterworld.com ]

Solved.