arioch
01-27-2007, 11:33 AM
I just ditched a XAMPP installation and went for a classic LAMP through Synaptic. This script used to work, but now it doesn't. Nothing happens. I don't get the errormessage I made if connection with the supplied parameters fail, and I don't get any messages from PHP either, so I can't tell what's wrong. What am I missing here? In case you wanna see the code:
<?php
function form(){
?>
<form id="dblink_params" name="dblink_params" method="post" action="<?php echo $PHP_SELF;?>">
<fieldset class="formfield">
<legend class="hlook1">1). YOUR DATABASE CONNECTION PARAMETERS:</legend>
<label>Database name:</label><input type="text" size="20" name="dbname" /><br />
<label>Database hostname:</label><input type="text" size="20" name="dbhost" /><br />
<label>Database username:</label><input type="text" size="20" name="dbusername" /><br />
<label>Database password:</label><input type="text" size="20" name="dbpassword" />
</fieldset>
<input type="submit" value="submit" name="submit">
</form>
<?php
}
// at first pageview, "submit" button is not set, so display form and halt script with die.
if (!isset($submit)) die (form());
// Variables picked up, and beginning whitespace trimmed away here,
$dbname = trim($_POST['dbname']);
$dbhost = trim($_POST['dbhost']);
$dbusername = trim($_POST['dbusername']);
$dbpassword = trim($_POST['dbpassword']);
// If it is set, continue by trying to connect with the db parameters collected from the form. If connection variables are successfully set (= establishes connection) then create tablevariables and check created tables. If the connection variables do not get set (= fails to establish connection) Die with error message.
if ($dbconnector = mysql_connect($dbhost, $dbusername, $dbpassword) && $dbselector = mysql_select_db($dbname)){
$goods = "CREATE TABLE goods (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
cat TINYTEXT NOT NULL default '',
title TINYTEXT NOT NULL default '',
description VARCHAR(255) NOT NULL default '',
price decimal(3,2) NOT NULL default '0.00',
counter INT default '0'
) TYPE=innodb";
$result = mysql_query($goods) OR die ('creating table "goods" failed. '. mysql_error());
die ('<h3 class="success">Connecting with your supplied parameters succeeded and required tables were created.</h3>');
}
else die('<h3 class="warning">Connection failed.<h3>');
?>
<?php
function form(){
?>
<form id="dblink_params" name="dblink_params" method="post" action="<?php echo $PHP_SELF;?>">
<fieldset class="formfield">
<legend class="hlook1">1). YOUR DATABASE CONNECTION PARAMETERS:</legend>
<label>Database name:</label><input type="text" size="20" name="dbname" /><br />
<label>Database hostname:</label><input type="text" size="20" name="dbhost" /><br />
<label>Database username:</label><input type="text" size="20" name="dbusername" /><br />
<label>Database password:</label><input type="text" size="20" name="dbpassword" />
</fieldset>
<input type="submit" value="submit" name="submit">
</form>
<?php
}
// at first pageview, "submit" button is not set, so display form and halt script with die.
if (!isset($submit)) die (form());
// Variables picked up, and beginning whitespace trimmed away here,
$dbname = trim($_POST['dbname']);
$dbhost = trim($_POST['dbhost']);
$dbusername = trim($_POST['dbusername']);
$dbpassword = trim($_POST['dbpassword']);
// If it is set, continue by trying to connect with the db parameters collected from the form. If connection variables are successfully set (= establishes connection) then create tablevariables and check created tables. If the connection variables do not get set (= fails to establish connection) Die with error message.
if ($dbconnector = mysql_connect($dbhost, $dbusername, $dbpassword) && $dbselector = mysql_select_db($dbname)){
$goods = "CREATE TABLE goods (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
cat TINYTEXT NOT NULL default '',
title TINYTEXT NOT NULL default '',
description VARCHAR(255) NOT NULL default '',
price decimal(3,2) NOT NULL default '0.00',
counter INT default '0'
) TYPE=innodb";
$result = mysql_query($goods) OR die ('creating table "goods" failed. '. mysql_error());
die ('<h3 class="success">Connecting with your supplied parameters succeeded and required tables were created.</h3>');
}
else die('<h3 class="warning">Connection failed.<h3>');
?>