Jump to content

Search the Community

Showing results for tags 'file read write'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 1 result

  1. Hello. I'd just like to enquire how I would read and write to a file using php please? I'm looking to write a database's, Host, Username, Password, and database Name to a file name on the server, then at a later date. When I load the site, read this information back. At present I'm using the following to write to the file:- // Write to file. $fp = fopen( dirname(__FILE__).'/dbinfo.txt', 'w' ) or die("Couldn't open file:- "); fwrite($fp, $hostname); fwrite($fp, $database); fwrite($fp, $username); fwrite($fp, $password); fclose( $fp ); and to read back:- $fp = fopen( dirname(__FILE__).'/dbinfo.txt', 'r' ) or die("Couldn't open file:- "); $db_host = fread($fp, $hostname); // $db_host $db_user = fread($fp, $username); // $db_user $db_pass = fread($fp, $password); // $db_pass $db_databasename = fread($fp, $database); fclose( $fp ); However, it reads it all in one long string, instead of it been on separate lines. Would anyone know the correct way of writing this code, please? Thank You.
×
×
  • Create New...