Jump to content

Search the Community

Showing results for tags 'fopen fread fwrite'.

  • 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. Hi, Could I please briefly enquire about reading and writing to a file using php? I'm looking for a way of storing a database's, Name, Username and Password. Then reading it back again. Writing to a file, I've written:- // Write to file. $fp = fopen( dirname(__FILE__).'/sys/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, I've written:- $fp = fopen( dirname(__FILE__).'/sys/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, I'm finding the data is been written in one long string (ie localhostusernamepassworddatabasename). I'd just like to ask if it is possible read the file so that $db_host would hold just hostname, $db_user would hold just the database username and so on? Also (out of interest) is there another way of reading and writing. I've thought about keeping each piece of data in a separate file. Thank You.
×
×
  • Create New...