Re: [PHP] create if table not exists

2004-05-19 Thread Don Read
On 17-May-2004 John Taylor-Johnston wrote: How can I check if a table exists in a mysql db. function tableexists($tbl) { $res = @mysql_query(SELECT COUNT(*) FROM $tbl); return ($res ? true : false); } Regards, -- Don Read [EMAIL PROTECTED] -- It's

Re: [PHP] create if table not exists

2004-05-17 Thread John Taylor-Johnston
But wouldn't it be easier to create the tables in the first place? Travis, It surely would. But for one situation, I don't/can't have access to phpMyAdmin to install it. At the same time, I wanted to learn how to do it. -- John I'm still learning. But isn't this much more fun than Perl! To

[PHP] create if table not exists

2004-05-16 Thread John Taylor-Johnston
How can I check if a table exists in a mysql db. If it table does not exist, then, $news = mysql_query($sql_create); else $news = mysql_query($sql); Not sure I know where to start? -snip $server = localhost; $user = user1; $pass = ; $db=user1table; $table=comments;

Re: [PHP] create if table not exists

2004-05-16 Thread Travis Low
The manual says: ?php mysql_connect(host); $result = mysql_list_tables(wisconsin); for ($i = 0; $i mysql_num_rows($result); $i++) { $tb_names[$i] = mysql_tablename($result, $i); echo $tb_names[$i] . BR; } ? To paraphrase, just use mysql_list_tables() to get a table list in a result set,