Quotes and PHP need help!!
Results 1 to 9 of 9

Thread: Quotes and PHP need help!!

  1. #1
    Senior Member
    Join Date
    Apr 2003
    Posts
    109

    Quotes and PHP need help!!

    Hi felow mates!!

    Hows the weather, the wife and all?

    Well hers the thing

    http://quotes.assassinscm.com a friend of mine owns that site, and what he has in mind is this:

    for someone to view the quotes has to click on the text link, what he whanted to do was to make a simple PHP code that would get the quotes of the text and display them on the page, being that this way the ppl didnt had to click on the text to view the quotes. He said that he made an Include but they were all mixed up and not "line by line". Basicly the code has to get the quotes of the .txt and display them on the page line by line.

    Can anyone help me out?

    Cheers and thanx alot!
    Owmen

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Posts
    109
    I found a way of doing just what he whanted but i have yet, another problem.

    What i did was the Include again, but this time iv chanded the quote.txt file and made HTML code inside to insert <br><br> after each line so that evrything looks nice and pretty, the damm problem is that the boot has to had after each quote ppl make on the IRC channel <br><br> to the end of the frase automaticly..now this envolves C++ since the bot was "ritten" for UNIX systems but a Windows port was also concidered, i compiled it and works..but i need the piece of code that makes the boot had that to the end of the frases.

    The bot code is here http://darksun.com.pt/mbot/

    Thanx for any help is apreciated!
    Owmen

  3. #3
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Why not code something like:

    Code:
    <?php
    $quote_file = fopen ("quotes.txt","r");
    
    while(!feof($quote_file)) {
      $line = fgets($file,1024);
      print($line."<br>\n");
    }
    fclose($quote_file);
    ?>
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  4. #4
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255
    Originally posted here by Owmen
    I found a way of doing just what he whanted but i have yet, another problem.

    What i did was the Include again, but this time iv chanded the quote.txt file and made HTML code inside to insert <br><br> after each line so that evrything looks nice and pretty, the damm problem is that the boot has to had after each quote ppl make on the IRC channel <br><br> to the end of the frase automaticly.
    You don't need to do that, leave it as newlined file ends.

    PHP Code:
    $quotes=file_get_contents("quotes.txt");
    $arr split(PHP_EOL$quotes);
    for (
    $i=0$i<sizeof($arr); $i++)
    {
      echo 
    $arr[$i]."<br>".PHP_EOL;

    Almost the same, but more portable, and faster than fopen/fgets.
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  5. #5
    Senior Member
    Join Date
    Apr 2003
    Posts
    109
    Thanx ppL!!!! really alot
    Owmen

  6. #6
    Senior Member
    Join Date
    Apr 2003
    Posts
    109
    Damm didnt work has expected http://emuhx.bounceme.net/quote.php
    Owmen

  7. #7
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,255
    Originally posted here by Owmen
    Damm didnt work has expected http://emuhx.bounceme.net/quote.php
    Well, PHP_EOL is new as of PHP 4.3.10, so it's probably not in your install. You can define it with:
    PHP Code:
    define('PHP_EOL''\n'); // Unix end of line 
    or
    PHP Code:
    define('PHP_EOL''\r\n'); // Windows end of line 
    depending on which OS your host runs. Also note once you've built the array, you could randomly pick a quote to display.
    Chris Shepherd
    The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
    \"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
    Is your whole family retarded, or did they just catch it from you?

  8. #8
    Senior Member
    Join Date
    Apr 2003
    Posts
    109
    Itsss aliveee its aliveeeee !!! (mean it works !!)

    Thanx, like... ALOT!!!!!!

    Cheers!!!
    Owmen

  9. #9
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Originally posted here by chsh
    Almost the same, but more portable, and faster than fopen/fgets.
    Ah. Didn't know that. I just coded mine after reading the PHP manual for about 2 minutes (hint...hint...hint.... )
    Oliver's Law:
    Experience is something you don't get until just after you need it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •