0
我有這樣的代碼來創建一個config.ini
文件與Zend框架,但我總是從網頁上的Internal Server Error (Error 500)
...Zend_Config_Ini_Writer不工作:錯誤500
<?php
session_start();
$config = new Zend_Config_Ini('config.ini',null,array('skipExtends' => true, 'allowModifications' => true));
// CREATE VALUE
$config->database = array();
$config->base = array();
$config->system = array();
$config->home = array();
$config->other = array();
//DATABASE
$config->database->hostname = $_SESSION['db_hostname'];
$config->database->username = $_SESSION['db_username'];
$config->database->password = $_SESSION['db_password'];
$config->database->port = $_SESSION['db_port'];
$config->database->database = $_SESSION['db_name'];
// BASE
$config->base->base_url = $_SESSION['base_url'];
$config->base->site_name = $_SESSION['site_name'];
$config->base->site_slogan = $_SESSION['site_slogan'];
// SYSTEM
$config->system->license = 'false';
$config->system->cms_type = 'free';
$config->system->system_email = $_SESSION['system_email'];
// HOME
$config->home->homepage_type = 'welcome';
$config->home->blog_limit = 10;
$config->home->homepage_message = 'Welcome to CustomCMS!';
// OTHER
$config->other->copyright_text = 'Copyright &169; 2012 FMarcoux - All rights reserved';
// Write the config file
$writer = new Zend_Config_Writer_Ini(array('config' => $config,'filename' => 'config.ini'));
$writer->write();
// NOW EXECUTE SQL FILE
$sqlErrorText = '';
$sqlErrorCode = 0;
$sqlStmt = '';
$sqlFileToExecute = 'install_query.sql';
$con = mysql_connect($_SESSION['db_hostname'].':'.$_SESSION['db_port'],$_SESSION['db_username'],$_SESSION['db_password']) or die(mysql_error());
mysql_select_db($_SESSION['db_name'], $con) or die();
if ($con)
{
// Load and explode the sql file
$f = fopen($sqlFileToExecute,"r+");
$sqlFile = fread($f,filesize($sqlFileToExecute));
$sqlArray = explode(';',$sqlFile);
//Process the sql file by statements
foreach ($sqlArray as $stmt)
{
if (strlen($stmt) > 3)
{
$result = mysql_query($stmt);
if (!$result)
{
$sqlErrorCode = mysql_errno();
$sqlErrorText = mysql_error();
$sqlStmt = $stmt;
break;
}
}
}
mysql_query("INSERT INTO `users` (`id`, `username`, `password`, `role`, `full_name`, `email`, `avatar`, `avatar_type`, `ip`, `comments`, `bio`, `privacy_level`, `location`, `banned`, `user_slogan`) VALUES (1, 'admin', '".md5($_SESSION['admin_password']."', 3, 'admin', '".$_SESSION['admin_email']."', '', 'none', '127.0.0.1', 0, '', 3, '', 0, '');") or die(mysql_error());
}
if ($sqlErrorCode == 0)
{
echo "<tr><td>Installation was finished succesfully!</td></tr>";
header('Location: done.php');
}
else
{
include('header.php');
?>
<div id="main">
<h1>Writing File...</h1>
<hr />
<?php
echo "<tr><td>An error occured during installation!</td></tr>";
echo "<tr><td>Error code: ".$sqlErrorCode."</td></tr>";
echo "<tr><td>Error text: ".$sqlErrorText."</td></tr>";
echo "<tr><td>Statement:<br/> ".$sqlStmt."</td></tr>";
?>
</div>
<div id="sidebar">
<ol>
<li><strike>Welcome</strike></li>
<li><strike>Database</strike></li>
<li><strike>Admin</strike></li>
<li><strike>Basic Configuration</strike></li>
<li><b>Create 'config.ini'</b></li>
<li>Done</li>
</ol>
</div>
<div id="footer"></div>
對不起長碼!
如果有人可以幫助我解決這個問題,那將是感激!
注意:我所有的$_SESSION[]
已設置。
問題不僅在於此,而且現在它工作得很好...... – 2012-02-10 04:15:33