rhboarder
April 7th, 2010, 09:55 PM
Im having the most frustrating time trying to figure this out, this script runs great on my private (WAMP) server but not on my hosting server (LAMP). The script is pretty simple, creates a database with a table of 6 fields:
<?php
$host = "127.0.0.1";
$username = "my_username";
$pwd = "my_password";
if (mysql_connect($host, $username, $pwd))
{
$query = "CREATE DATABASE IF NOT EXISTS weup";
//execute query
if (mysql_query($query))
{
print "Database created successfully!<br />";
//must select db before creating table
if (@mysql_select_db("weup"))
{
$query = "CREATE TABLE IF NOT EXISTS applications(appname VARCHAR(25),
description VARCHAR(200), applink VARCHAR(50), authname VARCHAR(50), authage INT, authloc VARCHAR(40))";
//create the table
if (mysql_query($query)) print "Table created successfully!";
else print "Error creating table";
}
} else print "Error creating database";
mysql_close();
} else print "Unable to connect to " . $host;
?>
<?php
$host = "127.0.0.1";
$username = "my_username";
$pwd = "my_password";
if (mysql_connect($host, $username, $pwd))
{
$query = "CREATE DATABASE IF NOT EXISTS weup";
//execute query
if (mysql_query($query))
{
print "Database created successfully!<br />";
//must select db before creating table
if (@mysql_select_db("weup"))
{
$query = "CREATE TABLE IF NOT EXISTS applications(appname VARCHAR(25),
description VARCHAR(200), applink VARCHAR(50), authname VARCHAR(50), authage INT, authloc VARCHAR(40))";
//create the table
if (mysql_query($query)) print "Table created successfully!";
else print "Error creating table";
}
} else print "Error creating database";
mysql_close();
} else print "Unable to connect to " . $host;
?>