/    Sign up×
Community /Pin to ProfileBookmark

Writing to a file

How would I write the following code to a file?

[code=php]<?
//MYSQL DB Information
$dbhost = ‘host’;
$dbusername = ‘DB USER’;
$dbpasswd = ‘PASS’;
$database_name = ‘DB NAME’;
//NAME OF YOUR WEBSITE
$website = ‘Name’;
//URL MUST NOT HAVE A TRAILING SLASH!
$url = ‘URL to member system’;
//NAME THAT WILL BE DISPLAYED ON E-MAILS SENT
$emailname = ‘Site Email Name’;
$adminemail = ‘Admin E-mail’;
?>[/code]

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 15.2005 — Not sure if this is what you're asking, but...
[code=php]
<?php
$text = <<<EOD
<?
//MYSQL DB Information
$dbhost = 'host';
$dbusername = 'DB USER';
$dbpasswd = 'PASS';
$database_name = 'DB NAME';
//NAME OF YOUR WEBSITE
$website = 'Name';
//URL MUST NOT HAVE A TRAILING SLASH!
$url = 'URL to member system';
//NAME THAT WILL BE DISPLAYED ON E-MAILS SENT
$emailname = 'Site Email Name';
$adminemail = 'Admin E-mail';
?>
EOD;

$handle = fopen("code.txt", "w+") or die;
fwrite($handle, $text);
fclose($handle);
[/code]
Copy linkTweet thisAlerts:
@JonaFeb 15.2005 — [font=trebuchet ms]If you're using this to store sensetive information, a ".php" extension would be necessary at the very least.[/font]
Copy linkTweet thisAlerts:
@neenach2002authorFeb 15.2005 — I merely needed an example...?

OMG!!!! It's daddy Jona!

*does a dancie and points to title*

Sorry...had to let out the kid in me for a second there...?

It seems as if we've come across a loophole in time...You're younger than me...=/...How does THAT work???? :p
Copy linkTweet thisAlerts:
@JonaFeb 15.2005 — [i]Originally posted by neenach2002 [/i]

[B]It seems as if we've come across a loophole in time...You're younger than me...=/...How does THAT work???? :p [/B][/QUOTE]


[font=trebuchet ms]I like to compare myself to the famous and very talented Mozart. ? [/font]
Copy linkTweet thisAlerts:
@neenach2002authorFeb 15.2005 — Nice.

Mozart = There's no word for what Mozart equals.:p
Copy linkTweet thisAlerts:
@BeachSideFeb 15.2005 — [i]Originally posted by neenach2002 [/i]

[B]Nice.



Mozart = There's no word for what Mozart equals.? [/B]
[/QUOTE]


Mozart == ...I can't think of anything either :p
Copy linkTweet thisAlerts:
@neenach2002authorFeb 19.2005 — Crudness...I can't seem to figure out how to write in a variable in place of 'host' and for all the other variables.

[code=php]
<?
$text = <<<EOD
<?
//MYSQL DB Information
$dbhost = 'host'; ///I want to write the variable here instead of the word 'host'
$dbusername = 'DB USER';
$dbpasswd = 'PASS';
$database_name = 'DB NAME';
//NAME OF YOUR WEBSITE
$website = 'Name';
//URL MUST NOT HAVE A TRAILING SLASH!
$url = 'URL to member system';
//NAME THAT WILL BE DISPLAYED ON E-MAILS SENT
$emailname = 'Site Email Name';
$adminemail = 'Admin E-mail';
?>
EOD;
$handle = fopen("code.txt", "w+") or die;
fwrite($handle, $text);
fclose($handle); ?>[/code]
×

Success!

Help @neenach2002 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...