Hvorfor kan jeg ikke skabe forbindelse til mysql?
Hejsa,Jeg prøver at installere Autoboss 1.0 heletiden... Det underlige ved det er at jeg godt kunne installere det på en hjemmeside med en anden mysql database.. Men det vil simpelthen ikke installere på en hjemmeside som jeg skal installere den på og det er med en anden mysql database.. Jeg har tjekket forbindelse til MySQL'en den fungerer fint, da jeg sagtens kan sætte andre script op og få dem til at fungere korrekt..
Når jeg prøver at køre setup.php filen, med de rigtigs informationer indtastet for jeg konstant af vide:
Connection to host failed
Unable to create database
Unable to create vehicle_config table
Unable to create vehicle_inventory table
Unable to create vehicle_imagelist table
Unable to store configuration information
, men når jeg indtaster informationerne på en andenhjemmeside så virker det!... Er ved at blive skør af det her!!
Her er setup.php filen, som man kører for at installere:
<?
// dummy file code
$dummy = "
<html>
<head>
<title>Access Denied</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
</head>
<body>
You are not authorized to view this directory.
</body>
</html>
";
// function removes the submitted directory if it exists
function remove_dir($dir) {
if(file_exists($dir)) {
if(is_dir($dir)) {
$handle = opendir($dir);
while(false!==($file = readdir($handle))) {
if(!is_dir("$dir/$file")) {
unlink("$dir/$file");
}
}
rmdir($dir);
}
}
}
$success = true; // set success out here so the error log is not shown on initial page entry
// attempt setup if data has been submitted
if(!empty($_POST['dbhost']) && !empty($_POST['dbname']) && !empty($_POST['username']) && !empty($_POST['password']) && $_POST['password'] == $_POST['confirm']) {
$dbvin = 'vehicle_inventory';
$dbimg = 'vehicle_imagelist';
$dbcfg = 'vehicle_config';
// establish link with database
$link = @mysql_connect($dbhost, $dbuser, $dbpass);
if(!$link) { $success = false; $errormsg .= "<tr><td width=50 align='right'><img src='common/red_x.jpg'></td><td class='text' width=550>Connection to host failed</td></tr>\n"; }
// create database if it doesn't exist
if(!@mysql_query("CREATE DATABASE IF NOT EXISTS $dbname", $link)) {
$success = false; $errormsg .= "<tr><td width=50 align='right'><img src='common/red_x.jpg'></td><td class='text' width=550>Unable to create database</td></tr>\n";
}
// create configuration table
@mysql_db_query($dbname, "DROP TABLE IF EXISTS $dbcfg", $link);
$query = "CREATE TABLE $dbcfg (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
username CHAR(20),
password CHAR(20),
installed NUMERIC(10),
dealer CHAR(60),
email CHAR(60),
phone CHAR(15)
)";
if(!@mysql_db_query($dbname, $query, $link)) {
$success = false; $errormsg .= "<tr><td width=50 align='right'><img src='common/red_x.jpg'></td><td class='text' width=550>Unable to create $dbcfg table</td></tr>\n";
}
// create vehicle info table
@mysql_db_query($dbname, "DROP TABLE IF EXISTS $dbvin", $link);
$query = "CREATE TABLE $dbvin (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
ccode NUMERIC(15),
added NUMERIC(10),
updated NUMERIC(10),
viewed NUMERIC(10),
numimages NUMERIC(2),
stock CHAR(20),
vin CHAR(30),
year NUMERIC(4),
make CHAR(20),
model CHAR(30),
condition CHAR(4),
category CHAR(20),
mileage CHAR(9),
price CHAR(15),
exterior CHAR(30),
interior CHAR(30),
body CHAR(20),
doors CHAR(1),
engine CHAR(40),
fuel CHAR(20),
trans CHAR(20),
stereo CHAR(40),
comments TEXT
)";
if(!@mysql_db_query($dbname, $query, $link)) {
$success = false; $errormsg .= "<tr><td width=50 align='right'><img src='common/red_x.jpg'></td><td class='text' width=550>Unable to create $dbvin table</td></tr>\n";
}
// create images table
@mysql_db_query($dbname, "DROP TABLE IF EXISTS $dbimg", $link);
$query = "CREATE TABLE $dbimg (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
ccode NUMERIC(15),
thumb CHAR(23),
image CHAR(23)
)";
if(!@mysql_db_query($dbname, $query, $link)) {
$success = false; $errormsg .= "<tr><td width=50 align='right'><img src='common/red_x.jpg'></td><td class='text' width=550>Unable to create $dbimg table</td></tr>\n";
}
// create directory structure
remove_dir('config');
if(!mkdir('config', 0777)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create config directory</td></tr>\n"; }
remove_dir('images');
if(!mkdir('images', 0777)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create images directory</td></tr>\n"; }
remove_dir('thumbs');
if(!mkdir('thumbs', 0777)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create thumbs directory</td></tr>\n"; }
remove_dir('temp');
if(!mkdir('temp', 0777)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create temp directory</td></tr>\n"; }
// create config datafile
$fp = @fopen('config/config.php', "w+");
$string =
"<?\n".
'$dbhost = ' . "'$dbhost';\n".
'$dbuser = ' . "'$dbuser';\n".
'$dbpass = ' . "'$dbpass';\n".
'$dbname = ' . "'$dbname';\n".
'$dbcfg = ' . "'$dbcfg';\n".
'$dbvin = ' . "'$dbvin';\n".
'$dbimg = ' . "'$dbimg';\n".
"?>";
if(!fwrite($fp, $string)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create configuration file</td></tr>\n"; }
@fclose($fp);
// create dummy index files to prevent access to subfolders
$fp = @fopen('config/index.htm', "w+");
if(!fwrite($fp, $dummy)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create directory block file</td></tr>\n"; }
@fclose($fp);
$fp = @fopen('images/index.htm', "w+");
if(!fwrite($fp, $dummy)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create directory block file</td></tr>\n"; }
@fclose($fp);
$fp = @fopen('thumbs/index.htm', "w+");
if(!fwrite($fp, $dummy)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create directory block file</td></tr>\n"; }
@fclose($fp);
$fp = @fopen('temp/index.htm', "w+");
if(!fwrite($fp, $dummy)) { $success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to create directory block file</td></tr>\n"; }
@fclose($fp);
// store username and password in configuration table
$time = time();
$dealer = addslashes($dealer);
if(!@mysql_db_query($dbname, "INSERT INTO $dbcfg VALUES ('0', '$username', '$password', '$time', '$dealer', '$email', '$phone')", $link)) {
$success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Unable to store configuration information</td></tr>\n";
//echo "$query<br>";
//echo mysql_error($link);
}
//echo mysql_error(); // DEBUG
@mysql_close($link);
// if installation was successful, display message
if($success) {
echo "
<html>
<head>
<title>autoBoss Setup</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<link href='css/default.css' rel='stylesheet' type='text/css'>
</head>
<body>
<table class='trim' width=500 border=0 cellpadding=3 cellspacing=0>
<tr><td class='highlight' align='center' colspan=2><b>autoBoss Setup</b></td></td></tr>
<tr bgcolor='#CCCC99'><td height=1 colspan=2><!-- LINE --></td></tr>
<tr><td height=50 class='text' align='center'>
<b>Congratulations</b> you have successfully installed <b>autoBoss</b>.<br>
<br>
<div align='left'>
<font class='hint'>As a precaution, this file (setup.php) has been removed from your server. This has been done
to prevent re-installation and loss of data. If you need to re-install autoBoss in this directory again simply
re-upload your local copy of setup.php to this directory.</font><br>
</div>
<br>
<center>
<input class='text' type=button value='Continue' onClick=\"window.location='cpanel.php';\"><br><br>
</center>
</td></tr>
</table>
<table width=500 border=0 cellpadding=5 cellspacing=0><tr><td align='center'>
<a href='http://www.go-script.com' class='hint_link' target='_blank'>Powered by autoBoss Version 1.0</a><br>
</td></tr></table>
</body>
</html>
";
// remove this file
unlink('setup.php');
exit();
}
}
// if the passwords entered do not match
if($_POST['password'] != $_POST['confirm']) {
$success = false; $errormsg .= "<tr><td align='right'><img src='common/red_x.jpg'></td><td class='text'>Passwords entered do not match</td></tr>\n";
}
?>
<html>
<head>
<title>autoBoss Setup</title>
<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
<link href="css/default.css" rel="stylesheet" type="text/css">
<script language='JavaScript' src='functions.js'></script>
</head>
<body>
<?
if(!$success) {
echo "
<table class='trim' width=500 border=0 cellpadding=0 cellspacing=5>\n
<tr><td class='highlight' colspan=2><b>Setup Error Log</b></td></tr>\n
<tr bgcolor='#CCCC99'><td height=1 colspan=2><!-- LINE --></td></tr>\n
$errormsg \n
</table>\n
";
}
?>
<form action='<?=$PHP_SELF?>' method=post onSubmit='return checkrequired(this)'>
<table class='trim' width=500 border=0 cellpadding=3 cellspacing=0>
<tr><td class='highlight' align='center' colspan=2><b>Welcome to autoBoss Setup</b></td></td></tr>
<tr class='fill'><td height=1 colspan=2><!-- LINE --></td></tr>
<tr>
<td class='text' colspan=2>
Please use the form below to enter your setup information.<br>
<br>
<font class='hint'>Required items are indicated by an</font> <img src='common/arrow_left.jpg' align='absmiddle'><br>
<br>
</td>
</tr>
<tr><td class='highlight' colspan=2><b>Database Information</b></td></tr>
<tr class='fill'><td height=1 colspan=2><!-- LINE --></td></tr>
<tr><td class='hint' colspan=2>(This information is provided by your ISP.)<br></td></tr>
<tr><td width=225 class='text' align='right'>Host</td><td width=275><input class='text' type=text name='dbhost' value='<?=$dbhost?>' alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='text' align='right'>Database Username</td><td><input class='text' type=text name='dbuser' value='<?=$dbuser?>'></td></tr>
<tr><td class='text' align='right'>Database Password</td><td><input class='text' type=password name='dbpass' value='<?=$dbpass?>'></td></tr>
<tr><td class='text' align='right'>Database Name</td><td><input class='text' type=text name='dbname' value='<?=$dbname?>' alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='highlight' colspan=2><b><br>Control Panel Account Information</b></td></tr>
<tr class='fill'><td height=1 colspan=2><!-- LINE --></td></tr>
<tr><td class='hint' colspan=2>(You will use this information to access the autoBoss control panel.)<br></td></tr>
<tr><td class='text' align='right'>Username</td><td><input class='text' type=text name='username' value='<?=$username?>' maxlength=20 alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='text' align='right'>Password</td><td><input class='text' type=password name='password' value='<?=$password?>' maxlength=20 alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='text' align='right'>Confirm Password</td><td><input class='text' type=password name='confirm' value='<?=$confirm?>' maxlength=20 alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='highlight' colspan=2><b><br>Dealership Contact Information</b></td></tr>
<tr class='fill'><td height=1 colspan=2><!-- LINE --></td></tr>
<tr><td class='hint' colspan=2>(This information will be displayed on the vehicle detail pages.)<br></td></tr>
<tr><td class='text' align='right'>Dealership Name</td><td><input class='text' type=text name='dealer' value='<?=$dealer?>' maxlength=60 alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='text' align='right'>Email Address</td><td><input class='text' type=text name='email' value='<?=$email?>' maxlength=60 alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td class='text' align='right'>Phone Number</td><td><input class='text' type=text name='phone' value='<?=$phone?>' maxlength=15 alt='required'> <img src='common/arrow_left.jpg' align='absmiddle'></td></tr>
<tr><td height=10><!-- SPACER --></td></tr>
<tr class='fill'><td height=1 colspan=2><!-- LINE --></td></tr>
<tr><td height=10><!-- SPACER --></td></tr>
<tr><td></td><td><input class='text' type=submit value='Install'></td></tr>
<tr>
<td class='hint' colspan=2>
<br>
<b>Caution:</b><br>
If you have previously installed autoBoss in the database specified above, all data from the
previous installation will be lost.<br>
<br>
If you have previously installed autoBoss in this directory, all images from the previous
installation will be lost.
<br>
<br>
</td>
</tr>
</table>
<table width=500 border=0 cellpadding=5 cellspacing=0><tr><td align='center'><? require 'footer.php'; ?></td></tr></table>
</form>
</body>
</html>
