| View previous topic :: View next topic |
| Author |
Message |
AlbanainRetard Master Cheater
Reputation: 0
Joined: 02 Nov 2008 Posts: 494 Location: Canada eh?
|
Posted: Sat Mar 14, 2009 8:52 pm Post subject: [PHP HELP] Read file is messed |
|
|
Here is my code:
| Code: |
<?php
$fp = fopen('songs.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
while (!feof($fp)) {
$line = fgets($fp, 1024); //use 2048 if very long lines
list ($name, $link) = split ('\|', $line);
if( strpos($name,$_GET["search"]) != FALSE )
{
echo '<p>' . $name . '||' . $link . '</p>';
}
$fp++;
}
fclose($fp);
?>
|
update:
If my file is:
testname||pooman
poopoo||testxd
it only searches the top one, and I also can try to search test, only name...
And it should display all the correct responses but it only works on the first line, and suggestions?
_________________
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Sat Mar 14, 2009 9:24 pm Post subject: |
|
|
FALSE is 0, it will ignore an exact match. "estname" and not "testname". $fp++ is adding to a handle... need I say why that's dumb?
Artists with similar names will appear. "Test my music" and "Test my songs", and it is case sensitive. I recommend using an SQL database, or XML if that is not possible.
| Code: | <?php
$fp = fopen('songs.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
while (!feof($fp)) {
$line = fgets($fp, 1024); //use 2048 if very long lines
list ($name, $link) = split ('\|', $line);
if( strpos($name,$_GET["search"]) > -1 )
{
echo '<p>' . $name . '||' . $link . '</p>';
}
}
fclose($fp);
?> |
|
|
| Back to top |
|
 |
AlbanainRetard Master Cheater
Reputation: 0
Joined: 02 Nov 2008 Posts: 494 Location: Canada eh?
|
Posted: Sat Mar 14, 2009 9:32 pm Post subject: |
|
|
| compactwater wrote: | FALSE is 0, it will ignore an exact match. "estname" and not "testname". $fp++ is adding to a handle... need I say why that's dumb?
Artists with similar names will appear. "Test my music" and "Test my songs", and it is case sensitive. I recommend using an SQL database, or XML if that is not possible.
| Code: | <?php
$fp = fopen('songs.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
while (!feof($fp)) {
$line = fgets($fp, 1024); //use 2048 if very long lines
list ($name, $link) = split ('\|', $line);
if( strpos($name,$_GET["search"]) > -1 )
{
echo '<p>' . $name . '||' . $link . '</p>';
}
}
fclose($fp);
?> |
|
Thanks, I am not the best of PHP developers. My host doesn't allow MySQL, until I rebuy some more hosting. I will rep you in 34XXXX seconds. I may try xml.
_________________
|
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Mar 15, 2009 8:40 am Post subject: |
|
|
Uhh, i would find a new host! I know atleast 5 free hosts that allow MySQL databases.
txt databases are VERY insecure... Though they are usually much faster.
_________________
|
|
| Back to top |
|
 |
AlbanainRetard Master Cheater
Reputation: 0
Joined: 02 Nov 2008 Posts: 494 Location: Canada eh?
|
Posted: Sun Mar 15, 2009 11:40 am Post subject: |
|
|
| localhost wrote: | Uhh, i would find a new host! I know atleast 5 free hosts that allow MySQL databases.
txt databases are VERY insecure... Though they are usually much faster. |
Most that I find have adds , like 007sites, Evo and 7gb have my sql, but their permissions are messed, always giving me a 403.
Oh and time to rep.
_________________
|
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun Mar 15, 2009 11:54 am Post subject: |
|
|
| AlbanainRetard wrote: | | localhost wrote: | Uhh, i would find a new host! I know atleast 5 free hosts that allow MySQL databases.
txt databases are VERY insecure... Though they are usually much faster. |
Most that I find have adds , like 007sites, Evo and 7gb have my sql, but their permissions are messed, always giving me a 403.
Oh and time to rep. |
x10hosting i think it is called. Not much space... But it rocks
_________________
|
|
| Back to top |
|
 |
SXGuy I post too much
Reputation: 0
Joined: 19 Sep 2006 Posts: 3551
|
Posted: Sun Mar 15, 2009 4:50 pm Post subject: |
|
|
http://agilityhoster.com i loved it so much, i actually upgraded to a paid subscription
so many freebies included in the free hosting account you cant go wrong.
Some php functions are disabled as a free host, but then what do u expect.
|
|
| Back to top |
|
 |
AlbanainRetard Master Cheater
Reputation: 0
Joined: 02 Nov 2008 Posts: 494 Location: Canada eh?
|
Posted: Sun Mar 15, 2009 7:59 pm Post subject: |
|
|
Anyone got a host that call have files 5mb+?
_________________
|
|
| Back to top |
|
 |
SXGuy I post too much
Reputation: 0
Joined: 19 Sep 2006 Posts: 3551
|
Posted: Mon Mar 16, 2009 3:19 am Post subject: |
|
|
| agilityhoster.
|
|
| Back to top |
|
 |
|