streetrodfanati 0 Light Poster

Hi,

My install file is not creating all the tables- it's only creating the " abuse_report" and not any of the others. Can someone give it a look see? Or can someone tell me how to put the tables int a sql file that I can just upload instead?

<?
if($install_step_1)
{
	$fp = fopen("connect.txt", "r");
    $content = '';
    while(!feof($fp)) {
        $content .= fread($fp, 1024);
    }
    fclose($fp);
    $content = str_replace("{db_host}", $db_host, $content);
	$content = str_replace("{db_user}", $db_user, $content);
	$content = str_replace("{db_pass}", $db_pass, $content);
	$content = str_replace("{db_name}", $db_name, $content);
	$fp = fopen("../includes/.connect.php", "w+");
	fputs ($fp, $content);
	fclose($fp);
	include ('../includes/.connect.php');
	$test_create = mysql_query("CREATE TABLE test (id int(255) primary key NOT NULL,test char(255))");
	if ($test_create)
	{
		$test_insert = mysql_query("INSERT INTO test values ('','test')");
		if ($test_insert)
		{
			$delete_test = mysql_query("DELETE FROM test WHERE test = 'test'");
			if ($delete_test)
			{
				$delete_test_table = mysql_query("DROP TABLE test");
				if ($delete_test_table)
				{
					$message = "good";
				}
				else
				{
					$message = '<div align=center><font color=red>Test connection to the database has failed!</font></div><br>Please ensure database exists and database info is correct<br><a href="javascript:history.back(1)">Go back</a></font></div>';					
				}
			}
			else
			{
				$message = '<div align=center><font color=red>Test connection to the database has failed!</font></div><br>Please ensure database exists and database info is correct<br><a href="javascript:history.back(1)">Go back</a></font></div>';				
			}
		}
		else
		{
			$message = '<div align=center><font color=red>Test connection to the database has failed!</font></div><br>Please ensure database exists and database info is correct<br><a href="javascript:history.back(1)">Go back</a></font></div>';			
		}
	}
	else
	{
		$message = '<div align=center><font color=red>Test connection to the database has failed!</font></div><br>Please ensure database exists and database info is correct<br><a href="javascript:history.back(1)">Go back</a></font></div>';		
	}
	if ($message == "good")
	{
		$action = "step_2";
	}
	else
	{
		echo $message;
		exit;
	}
	$www_location = 'http://' . getenv('HTTP_HOST') . getenv('SCRIPT_NAME');
	$www_location = substr($www_location, 0, strpos($www_location, 'install'));
}
if ($install_step_2)
{
	include ('../includes/.connect.php');
	$create_banner = mysql_query("CREATE TABLE `banners` (
  `id` int(255) NOT NULL auto_increment,
  `user_id` varchar(255) NOT NULL default '',
  `banner_url` varchar(255) NOT NULL default '',
  `forward_url` varchar(255) NOT NULL default '',
  `status` varchar(255) NOT NULL default '',
  `credits` decimal(250,1) NOT NULL default '0.0',
  `views` int(255) NOT NULL default '0',
  `clicks` int(255) NOT NULL default '0',
  `date_added` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1");
	$create_config = mysql_query("CREATE TABLE `config` (
  `id` int(255) NOT NULL default '0',
  `site_name` varchar(255) NOT NULL default '',
  `site_url` varchar(255) NOT NULL default '',
  `admin_email` varchar(255) NOT NULL default '',
  `send_from_email` varchar(255) NOT NULL default '',
  `credit_earn` decimal(250,1) NOT NULL default '0.0',
  `credit_cost` decimal(250,1) NOT NULL default '0.0',
  `timer` int(255) NOT NULL default '0',
  `start_credits` varchar(255) NOT NULL default '',
  `last_banner` int(255) NOT NULL default '0',
  `h_limit` int(255) NOT NULL default '0',
  `w_limit` int(255) NOT NULL default '0',
  `keywords` text NOT NULL,
  `description` text NOT NULL,
  PRIMARY KEY  (`id`)
) TYPE=MyISAM");
	$create_sessions = mysql_query("CREATE TABLE `sessions` (
  `id` int(255) NOT NULL auto_increment,
  `session_id` varchar(255) NOT NULL default '',
  `user_id` varchar(255) NOT NULL default '',
  `user_email` varchar(255) NOT NULL default '',
  `credits_earned` decimal(250,1) NOT NULL default '0.0',
  `cheat` varchar(255) NOT NULL default '',
  `next_view` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1");
	$create_abuse = mysql_query("CREATE TABLE `abuse_report` (
  `id` int(255) NOT NULL auto_increment,
  `user_id` varchar(255) NOT NULL default '',
  `url_id` varchar(255) NOT NULL default '',
  `url_reported` varchar(255) NOT NULL default '',
  `reason` text NOT NULL,
  `date_time` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1");
	$create_urls = mysql_query("CREATE TABLE `urls` (
  `id` int(255) NOT NULL auto_increment,
  `user_id` varchar(255) NOT NULL default '',
  `display` varchar(255) NOT NULL default '',
  `status` varchar(255) NOT NULL default '',
  `credits` decimal(250,1) NOT NULL default '0.0',
  `views` int(255) NOT NULL default '0',
  `date_added` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1");
	$create_users = mysql_query("CREATE TABLE `users` (
  `id` int(255) NOT NULL auto_increment,
  `email` varchar(255) NOT NULL default '',
  `password` varchar(255) NOT NULL default '',
  `contact` varchar(255) NOT NULL default '',
  `status` varchar(255) NOT NULL default '',
  `confirmkey` varchar(255) NOT NULL default '',
  `credits` decimal(250,1) NOT NULL default '0.0',
  `last_banner` int(255) NOT NULL default '0',
  `last_url` int(255) NOT NULL default '0',
  `date_joined` date NOT NULL default '0000-00-00',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=1");
	$add_config = mysql_query("INSERT INTO `config` VALUES (1, 'Test Auto Surf Exchange', '$site_url', 'webmaster@yourdomain.com', 'noreply@yourdomain.com', 0.6, 1.0, 10, '1000', 1, 60, 468, 'autosurf,traffic,excahnge', 'My autosurf traffic exchange')");
	$action = "step_3";
}
if (!is_writable("../includes"))
{
	echo "<div align=center>includes directory is not writable please CHMOD to 777!</div>";
}
else
{
	if ($action == "")
	{
		?>
		<form method="post">
		<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2" bgcolor="#FF0000">Database Info </td>
    </tr>
  <tr>
    <td>Database host </td>
    <td><input name="db_host" type="text" id="db_host"></td>
    </tr>
  <tr>
    <td>Database username </td>
    <td><input name="db_user" type="text" id="db_user"></td>
    </tr>
  <tr>
    <td>Database password </td>
    <td><input name="db_pass" type="text" id="db_pass"></td>
    </tr>
  <tr>
    <td>Database name </td>
    <td><input name="db_name" type="text" id="db_name"></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><input name="install_step_1" type="submit" id="install_step_1" value="Next"></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
<?
}
if ($action == "step_2")
{
?>
<form method="post">
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2">Site Info</td>
  </tr>
  <tr>
    <td>Site URL </td>
    <td><input name="site_url" type="text" id="site_url" value="<? echo $www_location ?>"></td>
  </tr>
  <tr>
    <td><input name="install_step_2" type="submit" id="install_step_2" value="next"></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
<?
}
if ($action == "step_3")
{
	?>
	<div align="center">Install Complete<br><a href="../admin">Click here</a> to go to the admin interface</div>
	<?
}
}
?>

Thank you,
Joseph.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.