Little help with php string please

Discussion in 'PHP' started by adityaw, Mar 1, 2008.

  1. #1
    Why this code
    $sql = 'SELECT pagerank FROM {website_pr} WHERE url=%s AND timestamp < %d';
    
    PHP:
    when I debug always shown the value :

    SELECT pagerank FROM {website_pr} WHERE url=%s AND timestamp <
    PHP:
    and throwing away the %d ?!? Is there something I missed?
     
    adityaw, Mar 1, 2008 IP
  2. MakeADifference

    MakeADifference Peon

    Messages:
    476
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this

    $sql = "SELECT pagerank FROM {website_pr} WHERE url='%s' AND timestamp < '%d'"
     
    MakeADifference, Mar 1, 2008 IP
  3. adityaw

    adityaw Peon

    Messages:
    130
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Oopps .. i wrote the wrong code ... it should be :

    $sql = "SELECT pagerank FROM {website_pr} WHERE url='%s' AND timestamp<%d"
    PHP:
     
    adityaw, Mar 1, 2008 IP
  4. smatts9

    smatts9 Active Member

    Messages:
    1,089
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    88
    #4
    Try:
    
    $sql = "SELECT pagerank FROM {website_pr} WHERE url='%s' AND timestamp < '%d'";
    
    PHP:
     
    smatts9, Mar 1, 2008 IP
  5. brunixdi

    brunixdi Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You need the timestamp variable to be in single quotes '%d'
     
    brunixdi, Mar 1, 2008 IP
  6. adityaw

    adityaw Peon

    Messages:
    130
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for the replies, turns out that it's only the debugger that shows the incorrect value. So everything is all good now.
     
    adityaw, Mar 2, 2008 IP
  7. quicksolutions

    quicksolutions Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    which debugger you are using????
     
    quicksolutions, Mar 2, 2008 IP
  8. adityaw

    adityaw Peon

    Messages:
    130
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    zend debugger (eclipse)
     
    adityaw, Mar 2, 2008 IP