Re: Exporting data from database using fopen

From: Date: Fri, 13 Aug 2004 16:10:32 +0000
Subject: Re: Exporting data from database using fopen
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193712@lists.php.net to get a copy of this message
Hi Vern, Vern wrote:
I'm trying to write data to a file from a Postgres database using the following code
    while (!$rsITEMS->EOF) {
       $fp = fopen("./dump.sql", "w");
       fwrite($fp, "$rsITEMS->Fields('item_id')\n");
    $rsITEMS->MoveNext();
[shortened]
I wouldn't do, if I were you. It doesn't work, right? try: $fp = fopen("dump.sql", "w"); /* make shure, you have the w-bit set on dir for the user who runs php */ if($fp) { while(!$rsITEMS->EOF) { fwrite($fp, $rsITEMS->Fields('item_id')."\n"); $rsITEMS->MoveNext(); } fclose($fp); }else die("EXCPETION fopen(w)"); does it help? riese

« previous php.general (#193712) next »