mysql: how to check if table exists?
Posted: Sun Dec 14, 2003 8:40 pm
hi,
i been at it for a while now, i need to find out if a table exists or not, so far i have tried with
but this ouputs a error whichi dont need
.
also tried
that doest work either.
any ideas?
(i am making a class for site stats
)
i been at it for a while now, i need to find out if a table exists or not, so far i have tried with
Code: Select all
<?php
$sql = mysql_num_rows(mysql_query("select ID from table limit 1"));
if($sql != 1)
{
die("table not found, would youlike to make one?");
}
?>also tried
Code: Select all
<?php
function check_table()
{
$table = $this->stat_table;
$result = mysql_query("EXISTS TABLE $table");
echo $result;//nooutput at all here :/
if($result != 1)
{
echo $this->mysql->error("[red]$table was not found in the database[/font]<b>Would like to make it now?</b><br /><a href="$_SERVER[PHP_SELF]?maketable=1" style="color:blue">Yes!</a>");
}?>any ideas?
(i am making a class for site stats