嘿,我想寫給我的「config.php」文件,但它不會工作。我正在使用下面的代碼。使用此代碼它不會出現任何錯誤,它只是不寫字符串。寫入.php文件?
$myFile = "config.php";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "<?php\n";
fwrite($fh, $stringData);
$stringData = "$db_user = '{$dbuser}';\n";
fwrite($fh, $stringData);
$stringData = "$db_pass = '{$dbpass}';\n";
fwrite($fh, $stringData);
$stringData = "$db_name = '{$dbname}';\n";
fwrite($fh, $stringData);
$stringData = "$db_host = 'localhost';\n";
fwrite($fh, $stringData);
$stringData = "$db_host = 'mysql_connect($db_host, $db_user, $db_pass) or die(mysq_error());\n";
fwrite($fh, $stringData);
$stringData = "$db_host = 'mysql_select_db($db_name) or die(mysql_error());\n";
fwrite($fh, $stringData);
$stringData = "$db_host = 'function protect($str) {\n";
fwrite($fh, $stringData);
$stringData = "$db_host = ' return mysql_real_escape_string(urldecode($str));\n";
fwrite($fh, $stringData);
$stringData = "$db_host = '}\n";
fwrite($fh, $stringData);
$stringData = "$db_host = '?>\n";
fwrite($fh, $stringData);
fclose($fh);
我在做什麼錯?
權限是否正確?你有任何錯誤?究竟發生了什麼? – Jonathon
請記住這一點:您不應該在沒有告訴我們*錯誤或*如何*不起作用的情況下發布「您遇到錯誤」或「不起作用」。否則我們無法幫助你。 – meagar
它只是不寫信給它。 –