I used phpmyadmin to help generate some code. When I add:

IF NOT EXISTS `mhinse_counter` it mysql_errors that the error is around:

"IF  NOT  EXISTS  `mhinse_counter` CREATE  TABLE  `mhinse_counter` ( "

Can anyone see clear here?


$server = "localhost";
$user = "user1";
$pass = "******";
$db="jtjohnston";
$table="mhinse_counter";


$query = 'IF NOT EXISTS `mhinse_counter`
CREATE TABLE `mhinse_counter` ( `id` int( 10 ) NOT NULL AUTO_INCREMENT ,'
         . ' `IPAddress` varchar( 100 ) NOT NULL default \'\','
         . ' `RemoteHost` varchar( 100 ) NOT NULL default \'\','
         . ' `Language` text NOT NULL ,'
         . ' `StampDate` date NOT NULL default \'0000-00-00\','
         . ' `StampTime` time NOT NULL default \'00:00:00\','
         . ' `TimeStamp` timestamp( 14 ) NOT NULL ,'
         . ' PRIMARY KEY ( `id` ) ) TYPE = MYISAM AUTO_INCREMENT =1';

$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
mysql_query($query) or die(print mysql_error());



> Tim Van Wassenhove wrote:
> > How can I check if a table exists in a mysql db.
> $query = 'IF NOT EXISTS table CREATE TABLE table (......)';
> mysql_query($query);

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

Reply via email to