RE: [PHP] Using php to insert ' ' in between fields...

From: Date: Tue, 29 Aug 2000 13:25:47 +0000
Subject: RE: [PHP] Using php to insert ' ' in between fields...
Groups: php.general 
Request: Send a blank email to php-general+get-14114@lists.php.net to get a copy of this message
I may be wrong, but I don't see how even the code below would work. Don't you still need to put a "'" at the beginning of each record? It won't get inserted since there is no "," there to be replaced. To do anything to the file you need to use fopen first (see http://www.php.net/manual/function.fopen.php) and then fread (see http://www.php.net/manual/function.fread.php) and then you can use str_replace. Mike -----Original Message----- From: Sam [mailto:Sam@dragoman.co.uk] Sent: Tuesday, August 29, 2000 9:37 AM To: 'php' Cc: 'M.vanderMerwe@expro.shell.co.uk' Subject: RE: [PHP] Using php to insert ' ' in between fields... Thanks for your responses, but please bear with me as I am v. new to php. How can I use the code below... $before = ","; $after = "\',"; $data = str_replace( $before, $after, $data ); With a newly uploaded text file? Do I have to open the text file first, or leave it closed? I.e. a bit more help if you dont mind? Thanks Sam -----Original Message----- From: M.vanderMerwe@expro.shell.co.uk [mailto:M.vanderMerwe@expro.shell.co.uk] Sent: 29 August 2000 13:47 To: Sam@dragoman.co.uk Subject: RE: [PHP] Using php to insert ' ' in between fields... If I understand you correctly, you want to have: 'HQZ','1','HQZ50','1','Quito', etc .... Try: $before = ","; $after = "\',"; $data = str_replace( $before, $after, $data ); Thys -----Original Message----- From: Sam [mailto:Sam@dragoman.co.uk] Sent: 29 August 2000 13:59 To: php-general Cc: Sam Subject: [PHP] Using php to insert ' ' in between fields... Hi all, I have a text file that has been derived from exporting from MS-Access. It will be uploaded to my website via a web page. I have been able to produce out put like this... HQZ,1,HQZ50,1,Quito,00/8/20 00:00:00,La Paz,00/10/1 00:00:00,£2120.00,0, HEP,1,HEP50,1,Quito,00/8/20 00:00:00,Lima,00/9/9 00:00:00,£1095.00,0, This is an example of two records. Is there any way of using PHP to place each field inbetween ' ', so that it can be entered into a mySQL database? Thanks in advance Sam Rose -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#14114) next »