<?
$host="";
$dbase="";
$login="";
$passwd="";
$cnx = mysql_connect($host,$login,$passwd);
if (!$cnx) {
print "Error Connecting to MySQL server\n<BR>";
exit(0);
}
else {
mysql_select_db($dbase) or die("Error changing Database");
print "Connected to database!\n<BR>";
}
@mysql_select_db($dbase) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
$query="SELECT * FROM contacts";
$db_list = mysql_list_dbs($link);
while ($row = mysql_fetch_object($db_list)) {
echo $row->Database . "\n";
}
$result=mysql_query($query);
$tbl_list = mysql_list_tables($dbase);
if (!$tbl_list) {
print "Could not list tables";
print 'Mysql said: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($tbl_list)) {
print "tablename: $row[0]<br>";
}
mysql_close();
?>
Ok that is the code i tried and got these messages
Connected to database!
Warning: mysql_list_dbs(): supplied argument is not a valid MySQL-Link resource in d:\jamesdiamond.com\createtable.php on line 19
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in d:\jamesdiamond.com\createtable.php on line 21
tablename: contacts