Please let me know what i am doing wrong here


Hello Friends,

So I am trying to installing a script today. The installation wizard works well for first 2 steps but when it comes to enter the database details page and i enter the correct database details it shows 500 error message. I didn't understand what is going wrong here as according to the script documentation i have also made config.php file writable "777" but still its showing the error. Can you please have a look at the code and may be you can find out any error in this code and what is wrong here.

if(!isset($_SESSION)) session_start();

header("Location: requirements.php");

$host = "";

$username = "";

$password = "";

$database = "";

$error = "";

$config_error = "";

function SplitSQL($file, $delimiter = ';')

$lines = file($file);
// Loop through each line
foreach ($lines as $line)
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')

// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';')
    // Perform the query
    // Reset temp variable to empty
    $templine = '';



$config_error = "../config/config.php is not Writeable Please CHMOD 777";
if(isset($_POST['submit'])) {

	if($_SESSION['csrf'] != $_POST['csrf'])
		$error = "Error Try Again";
	if($error=="") {
	$host = $_POST['host'];
	$username = $_POST['username'];
	$password = $_POST['password'];
	$database = $_POST['database'];
	$connection = mysql_connect($host, $username, $password);
	$error = "Invalid Details : Unable to Connect To Database";
	if($error=="") {
			$connection = mysql_connect($host, $username, $password);
			$sql_filename = "./sql/db.sql";
			$sql_contents = SplitSQL($sql_filename);
			$config_sample_path = '../config/config.sample';
			$data = file_get_contents($config_sample_path);
			$data = str_replace("dbname",$database,$data);
			$data = str_replace("dbhost",$host,$data);
			$data = str_replace("dbuser",$username,$data);
			$data = str_replace("dbpass",$password,$data);
			$config_path = '../config/config.php';
			file_put_contents($config_path, $data);
$key = sha1(microtime());

$_SESSION['csrf'] = $key;
<!DOCTYPE html>
<html lang="en">
		<meta charset="utf-8">
		<title>Database Details - Installation Wizard</title>
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="shortcut icon" href="../style/images/favicon.png">
		<link href="style/css/bootstrap.min.css" rel="stylesheet">
		<link href="style/css/font-awesome.min.css" rel="stylesheet">
		<link href="style/css/style.css" rel="stylesheet">
		<script src="style/js/bootstrap.min.js"></script>

		<div class="hidden-xs">
			<div class="logo">
				<img src="style/images/logo.png">
			<div class="sub-logo">
				Php Web Lists Script
		<div class="visible-xs logo-sm">
			<img src="style/images/logo-sm.png">
		<div class="container">
			<div class="row">
				<div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
					<ul class="list-group">
					  <li class="list-group-item"><i class="fa fa-smile-o"></i> Welcome</li>
					  <li class="list-group-item"><i class="fa fa-cogs"></i> Server Requirements</li>
					  <li class="list-group-item active"><i class="fa fa-list-alt"></i> Database Details</li>
					  <li class="list-group-item"><i class="fa fa-book"></i> Website Details</li>
					  <li class="list-group-item"><i class="fa fa-thumbs-up"></i> Finish</li>
					<div class="hidden-xs hidden-sm">
					  <center>All Rights Reserved <a href=""></center>
				<form action="./database.php" method="post">
					<div class="col-xs-12 col-sm-9 col-md-9 col-lg-9">
						<div class="panel panel-default">
							<div class="panel-heading">
								<strong><i class="fa fa-list-alt"></i> Database Details</strong>
								<div class="pull-right"><span class="badge badge-warning">Step 3</span>
							<div class="panel-body">
								<b>Enter database details below</b>
								<?php if($config_error!="") { ?>
									<div class="alert alert-danger">
										<i class="fa fa-times-circle"></i> 
										<?php echo($config_error) ?>
								<?php }	else if($error && isset($_POST['host'])) { ?>
									<div class="alert alert-danger">
										<i class="fa fa-times-circle"></i> 
										<?php echo($error) ?>
								<?php } else {
									if(isset($_POST['host'])) {	?>
										<div class="alert alert-success">
											<i class="fa fa-check-square"></i> 
											Database Details Added Please Wait ...
										<?php echo ('<META HTTP-EQUIV="Refresh" Content="2; URL=website.php?' . time() . '">'); 
									  <div class="input-group">
										<span class="input-group-addon">Database Server</span>
										<input name="host" type="text" class="form-control" placeholder="eg. localhost" required>
									  <br />
									  <div class="input-group">
										<span class="input-group-addon">Database Name</span>
										<input name="database" type="text" class="form-control" placeholder="Enter Database Name" required>
									  <br />
									  <div class="input-group">
										<span class="input-group-addon">Database Username</span>
										<input name="username" type="text" class="form-control" placeholder="Enter Database Username" required>
									  <br />
									  <div class="input-group">
										<span class="input-group-addon">Password</span>
										<input name="password" type="password" class="form-control" placeholder="Enter Password" required>
								  <input type="hidden" name="csrf" value="<?php echo $key; ?>" />
								  <br />
								  <?php if($config_error=="") { ?>
									<button type="submit" name="submit" class="btn btn-primary btn-lg">Next</button>
								  <?php } else { ?>
									<a class="btn btn-success btn-lg" onClick="window.location.reload()">Refresh</a>
								  <?php } ?>

Please help me in this :slight_smile:


The mysql_* methods no longer exist in current versions of PHP. You should be using mysqli_* or better still PDO. I don't know if this is the problem here, but it something you need to look at.


Hello :slight_smile: So you mean to say i need to change all mysql_ to mysqli_ ?


Mass replacing mysql_* to mysqli_* won't work. You need to understand how mysqli_* works before you start mass replacing mysql_* functions. Simply adding an "i" won't work. You'll probably break it even more. Some mysql_* functions don't exist in mysqli_*.


Unless the file is outside of the root, and even then, you want to not set permissions to 777. Personally, I would not use any script that has that as a requirement even if only temporary before locking it down let alone permanently.

If you do set the permissions as 777 for goodness sake change them back as soon as you can.


You used to use 777 but nower days it can be 755; from memory it depends on the way the server is setup.

Sorry that was folder permissions


Yes I know the issue of 777 i have changed it after testing and its now on 644 again :slight_smile: I just love to test scripts and learn


ohh ok but i just checked another script on the same server it has also mysql and not mysqli but that script was installed without any issue but don't know why this script has this issue.


Try temporarily changing the 0 to -1



Toss this script in the trash. It is dangerous, old code that has been completely removed from Php.


not working i think this script is a garbage :slight_smile: Going to delete it from my server. Anyway thank you for your kind help :slight_smile:


yes you are right going to remove it from my server. :slight_smile:


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.