PDA

View Full Version : Anything wrong (NOT VB-RELATED)


Davey
06-02-2003, 08:35 PM
This install script won't work for the project I'm working on.
When it comes to step 3, writing the file, it comes up as a blank page.
Here is the file.
THIS FILE IS NOT THE VB-INSTALL FILE, IT IS NOTHING TO DO WITH VB I CANNOT STRESS THAT ENOUGH KTHX

Xenon
06-03-2003, 04:53 AM
"is_writable("./config.php")"

this will just be true, if file config.php already exists and php can write into it, but you are in the part of the file_exists("./config.php") - if clause where the file surely isn't created, so this condition can never be true :)

if you replace is_writable("./config.php") with a true, you will see that it'll work then :) (or at least gives you a no permission error if php has no permissions to create files) :)

Davey
06-03-2003, 07:32 AM
I kinda fixed it.
This is part of the code:
} else {
$handle = fopen('config.php','a');
$temp[00] = "" . chr(60) . chr(63) . chr(112) . chr(104) . chr(112) . ""; // < ? p h p line
$temp[01] = "error_reporting(7);";
// chr(36) is '$'
$temp[02] = "" . chr(36) . "mysql[host] = \"" . $_POST['mysqlhost'] . "\";";
$temp[03] = "" . chr(36) . "mysql[user] = \"" . $_POST['mysqluser'] . "\";";
$temp[04] = "" . chr(36) . "mysql[pass] = \"" . $_POST['mysqlpass'] . "\";";
$temp[05] = "" . chr(36) . "mysql[data] = \"" . $_POST['mysqldata'] . "\";";
$temp[06] = "" . chr(36) . "dbset = mysql_connect(" . chr(36) . "mysql[host]," . chr(36) . "mysql[user]," . chr(36) . "mysql[pass]);";
$temp[07] = "mysql_select_db(" . chr(36) . "mysql[data]);";
$temp[08] = "" . chr(36) . "admin[user] = \"" . $_POST['adminuser'] . "\";";
$temp[09] = "" . chr(36) . "admin[pass] = \"" . $_POST['adminpass'] . "\";";
$temp[10] = "" . chr(36) . "admin[email] = \"" . $_POST['adminemail'] . "\";";
$temp[11] = "?" . chr(62) . "";
$temp[12] = "" . $temp[00] . "\n" . $temp[01] . "\n\n" . $temp[02] . "\n" . $temp[03] . "\n" . $temp[04] . "\n" . $temp[05] . "\n\n" . $temp[06] . "\n" . $temp[07] . "\n\n" . $temp[08] . "\n" . $temp[09] . "\n" . $temp[10] . "\n\n" . $temp[11] . "";
fwrite($handle,$temp[12]);
fclose($handle);
The config.php file is written out like this now:
$adminpass = "sdfasdf";
error_reporting(7);

$mysql[host] = "localhost";
$mysql[user] = "username";
$mysql[pass] = "password";
$mysql[data] = "database";

$dbset = mysql_connect($mysql[host],$mysql[user],$mysql[pass]);
mysql_select_db($mysql[data]);

$admin[pass] = "sdfasdf";
$admin[pass] = "sdfasdf";
$admin[email] = "blah@whtevr.com";

?>

Dave.

Xenon
06-03-2003, 07:36 AM
:)
you're welcome :)

Davey
06-03-2003, 08:46 AM
Um lol.
Look at the 2nd [code] tag.
Where's <?php
And why is $admin[pass] in place of <?php and $admin[user]?

Dave.

Xenon
06-03-2003, 09:23 AM
hmm, sorry i didn't see it, and i don't see why it's creating that erros, but why are you doing that in a so complex way?

try this:

} else {
$handle = fopen('config.php','a');
$tempfiledata ='<?php
error_reporting(7);
$mysql[host] = "' . $_POST['mysqlhost'] . '";
$mysql[user] = "' . $_POST['mysqluser'] . '";
...
...
...
?>';
fwrite($handle,$tempfiledata);
fclose($handle);



remember variables are not parsed in ' strings

Davey
06-03-2003, 07:42 PM
I thought they were.

Dave.