Re: What's wrong?

From: Date: Tue, 20 Nov 2001 12:26:25 +0000
Subject: Re: What's wrong?
Groups: php.db 
Request: Send a blank email to php-db+get-14458@lists.php.net to get a copy of this message
Hi, the most probable reason is that the file you're reading from was saved in a different filesystem and the $info[2] has some newline characters at the end. You can use the trim() function to remove it. Than your expression will look something like this if(count($info) != 1 && $folder == trim($info[2])) HTH Dobromir Velev -----Original Message----- From: Sergio Augusto Bitencourt Petrovcic <sergio@automacao.eng.br> To: php-db@lists.php.net <php-db@lists.php.net> Date: Tuesday, November 20, 2001 13:58 Subject: [PHP-DB] What's wrong? >Ho there...I really wonder what's wrong with this script. The error is in >this line below: >if((count($info) != 1) && ($folder == $info[2])) echo >"<table><tr><td><a >href=" . $info[1] . ">" . $info[0] . >"</a><br></td></tr></table>"; >The condition ($folder == $info[2]) is not working! >I hope you can help me! >Here's the code: > ><?php > >$link_name = "Tudo sobre automaзгo"; >$link_address = "http://www.automacao.eng.br"; >$link_folder = "faculdade"; >$file = "teste.txt"; > >function write($file,$link_name,$link_address,$link_folder) { > $file=fopen("$file","w"); > fwrite($file,"$link_name|$link_address|$link_folder\n"); > fclose($file); >} > >function read($file,$folder) { > $file=fopen("$file","r"); > while (!feof ($file)) { > $buffer = fgets($file,1024); > $info = explode("|",$buffer); > if((count($info) != 1) && ($folder == $info[2])) echo > "<table><tr><td><a >href=" . $info[1] . ">" . $info[0] . >"</a><br></td></tr></table>"; > } > fclose($file); >} > >write($file,$link_name,$link_address,$link_folder); >read($file,"faculdade"); > >?> > >Thanks! > > >-- >PHP Database Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net >For additional commands, e-mail: php-db-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.db (#14458) next »