Results 1 to 10 of 13
-
6th Aug 2012, 12:24 PM #1OPMember
How can i create a PHP file via php?
FIXED:
This is how i did it.
PHP Code:public function createdatabase($host,$username,$password,$dbname)
{
$File = "../include/database.php";
$Handle = fopen($File, 'w');
$Data = "
<?php
\$MYSQL_HOST = '".$host."';
\$MYSQL_USERNAME = '".$username."';
\$MYSQL_PASSWORD = '".$password."';
\$MYSQL_DATABASE = '".$dbname."';
try {
\$dbh = new PDO('mysql:host='.\$MYSQL_HOST.';dbname='.\$MYSQL_DATABASE,\$MYSQL_USERNAME,\$MYSQL_PASSWORD);
} catch(PDOException \$e){
echo \$e->getMessage();
}
?>
";
fwrite($Handle, $Data);
fclose($Handle);
return "file created";
}
Jordanxifyhosting Reviewed by xifyhosting on . How can i create a PHP file via php? FIXED: This is how i did it. public function createdatabase($host,$username,$password,$dbname) { $File = "../include/database.php"; $Handle = fopen($File, 'w'); $Data = " <?php \$MYSQL_HOST = '".$host."'; Rating: 5
-
6th Aug 2012, 01:18 PM #2You can call me G
in $Data use single quotes instead of double and escape things accordingly. Should work fine then
My Langotiya Yaars (Chaddi buddies): JmZ, humour, Chutad, Esotorisk, l0calhost, Daniel, Mind Freak?, TLK, Amz
-
6th Aug 2012, 01:42 PM #3OPMember
The thing is it's not set as i want it to import as it's seen i want $ to be written in as $
Fixed:
/$ did the trick
-
6th Aug 2012, 03:04 PM #4Respected Member
You used the double quotes instead of single quote in the data expression
$Data = "
The single quote will not do this. It will take everything as written.
$Data = '
-
6th Aug 2012, 03:25 PM #5OPMember
Thats what i wanted i needed the $ to show as $ in the text file.... so i had to use /$ this is sorted now
-
6th Aug 2012, 07:16 PM #6MemberWebsite's:
epicimagehost.comI always use single quotes. Prevents shit like this from happening and makes more sense when looked at.
-
6th Aug 2012, 09:09 PM #7OPMember
That wasn't the trouble. do you read what i put? i wanted to insert the $ symbol into the test file. NOT what it was worth
-
6th Aug 2012, 09:38 PM #8MemberPHP Code:
<?php
class db{
function createdatabase($host,$username,$password,$dbname)
{
$File = "../include/database.php";
$Handle = fopen($File, 'w');
$Data = "
\$MYSQL_HOST = '".$host."';
\$MYSQL_USERNAME = '".$username."';
\$MYSQL_PASSWORD = '".$password."';
\$MYSQL_DATABASE = '".$dbname."';
try {
\$dbh = new PDO('mysql:host='.\$MYSQL_HOST.';dbname='.\$MYSQL_DATABASE,\$MYSQL_USERNAME,\$MYSQL_PASSWORD);
} catch(PDOException \$e){
echo \$e->getMessage();
}
";
fwrite($Handle, $Data);
fclose($Handle);
return "file created";
}
}
$db = new db();
$db->createdatabase('localho','root','test','');
-
6th Aug 2012, 09:45 PM #9OPMember
why do no1 read what i put. It's sorted all i did was add \$
-
6th Aug 2012, 09:46 PM #10Member
We're trying to help you fool. If you don't want help don't bitch when someone tries. Logout and don't come back.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Auto create txt file in each folder
By Ruriko in forum Technical Help Desk SupportReplies: 9Last Post: 18th Oct 2012, 02:41 PM -
Need Help Create File Hosting site like Rapidgator.net
By kamalepatel in forum General DiscussionReplies: 10Last Post: 30th Sep 2012, 11:54 PM -
How to: Create friendly URLs with your .httaccess File!
By Raptile in forum Tutorials and GuidesReplies: 5Last Post: 18th May 2012, 04:53 AM -
how to create same file with different website url in filename
By tamildragon in forum Technical Help Desk SupportReplies: 3Last Post: 26th Nov 2010, 05:13 PM -
create multiple copies of a file
By techdaemon in forum Technical Help Desk SupportReplies: 1Last Post: 10th Nov 2010, 02:17 AM
themaPoster - post to forums and...
Version 5.11 released. Open older version (or...