whats wrong

Discussion in 'PHP' started by member1, Jun 4, 2007.

  1. #1
    hi can anyone tell me whats rong with this script becose he dont show anything just like this:
    , , , , ,

    can anyone help me here


    
    <?php //Query to grab that stuff (Change 100 to how many searches to show)
    $query = mysql_query("SELECT * FROM search ORDER BY id DESC LIMIT 0,100");
    
    //Display it
    while($row = mysql_fetch_array($query)) {
    $dumpintheforest = array(":","#","/","'",'"',"(",")","?",",","~","@","<",">");
    $explodingcat = array("<",">","/","'",'"',";");
    $newurl = str_replace($dumpintheforest,"-",$row[query]);
    $new = str_replace($explodingcat,"",$row[query]);
    echo "<a href='ddl/search.php?search=".$newurl."'>".$new."</a>, ";
    }
    
    ?>
    PHP:
     
    member1, Jun 4, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Echo $row[query] and see if it contains the expected content.

    Also, for better performance, defined these arrays outside the loop:
    
    $dumpintheforest = array(":","#","/","'",'"',"(",")","?",",","~","@","<",">");
    $explodingcat = array("<",">","/","'",'"',";");
    
    PHP:
     
    nico_swd, Jun 4, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Are you sure it should return any results?

    Before the while() loop, add:
    echo mysql_num_rows($query);
    PHP:
     
    krt, Jun 4, 2007 IP
  4. champ_rock

    champ_rock Peon

    Messages:
    3,349
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i guess the problem is in the final echo.. try this

    echo '<a href="ddl/search.php?search='.$newurl.'">'.$new.'</a> ';
     
    champ_rock, Jun 4, 2007 IP
  5. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #5
    its not working

    now its not showing anything
     
    member1, Jun 4, 2007 IP
  6. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #6
    that he just show me the number of recent search
     
    member1, Jun 4, 2007 IP
  7. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #7
    If the commas show, then does it mean that it loops through the table. Look at the source code, you'll probably see the <a> tags. My guess is that $row[query] does not contain the expected content. But I'll never know since you seemed to ignore my suggestion. :)
     
    nico_swd, Jun 4, 2007 IP
  8. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #8
    no nico_swd i will never ignore you
    i just dont understaind how to modifed that's it like you now i am not good in php
     
    member1, Jun 4, 2007 IP
  9. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #9
    the source code is of recent search

     
    member1, Jun 4, 2007 IP
  10. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #10
    my be the error is here in this code becose i have to put this code in the top of search.php
    and other in recent.php

     
    member1, Jun 4, 2007 IP
  11. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #11
    Echo $row['query'] in the loop. What does it output?

    Also, on another side note, this:
    
    if(isset($_GET['q'])) {
    $search = $_GET['q'];
    } elseif(isset($_POST['q'])) {
    $search=$_POST["q"];
    }
    
    
    PHP:
    Can be simplified by:
    
    $search = $_REQUEST['q'];
    
    PHP:
     
    nico_swd, Jun 4, 2007 IP
  12. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #12
    i did add the Echo $row['query'] in the loop now he show me like this

    Download accelerater PlusDownload accelerater Plus, Download accelerator plusDownload accelerator plus, systematic chaossystematic chaos, PDFPDF

    and the fierst word without link and the secand with link
    ex: Download accelerater PlusDownload accelerater Plus,
     
    member1, Jun 5, 2007 IP
  13. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #13
    hello there is anyone he can help me here please
     
    member1, Jun 17, 2007 IP
  14. member1

    member1 Active Member

    Messages:
    65
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    68
    #14
    hi nico_swd i add the Echo $row['query'] like you said thene he show me dublicate search eachword he show him twice so i delete this code and find out another error in the link i modifed now he show everthing perfect exepect one thing in the home page

    supose to here whene i include this in the home page
    <?php include "recent.php"; ?>
    PHP:
    he show the recent search but there is nothing
    he dont show nothing

    what i have to do to make it work

    and thanks for help me
     
    member1, Jun 17, 2007 IP