Using number signs in PHP

Discussion in 'PHP' started by goneinsane, Apr 21, 2010.

  1. #1
    I am calling on some information in a database that has number signs, but I'm getting errors.

    $res = mysql_query("select * from properties where approved=1 and location2 in (1#50#45,1#50#17) order by date_added desc limit ".$start_ad.",".$limit) or die("could not query for ".mysql_error());
    PHP:
    How can I make it so that it will accept those number signs?
     
    goneinsane, Apr 21, 2010 IP
  2. Cloud Computing Forum

    Cloud Computing Forum Guest

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I think you need to encapsulate it in something like back ticks. ``
     
    Cloud Computing Forum, Apr 21, 2010 IP
  3. job0107

    job0107 Peon

    Messages:
    23
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can try one of these for the pound sign.

    & # 35; (without spaces)

    OR

    #

    You probably should have the HTML Entity notation in your query and in your database data.
     
    job0107, Apr 21, 2010 IP
  4. goneinsane

    goneinsane Well-Known Member

    Messages:
    303
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #4
    None of this stuff has worked. It basically stops at the # and won't display the results of the location2 field. There must be a way to have it recognize # as a # only in this case.
     
    goneinsane, Apr 22, 2010 IP
  5. goneinsane

    goneinsane Well-Known Member

    Messages:
    303
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #5
    Here is all of the code. This should help.

    
    
    code removed because problem has been solved
    
    
    PHP:
     
    Last edited: Apr 22, 2010
    goneinsane, Apr 22, 2010 IP
  6. job0107

    job0107 Peon

    Messages:
    23
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I am not exactly sure what this value (1#50#45,1#50#17) is supposed to represent,
    but sense it contains more than numeric characters, it must be treated as a string and quoted in the query.
    
    $res = mysql_query("select * from properties where approved=1 and location2 in ('1#50#45,1#50#17') order by date_added desc limit ".$start_ad.",".$limit) or die("could not query for ".mysql_error());
    
    PHP:
     
    job0107, Apr 22, 2010 IP
  7. goneinsane

    goneinsane Well-Known Member

    Messages:
    303
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    130
    #7
    That worked! Thank you.
    When it was mentioned before by Cloud Computing Forum, I thought he meant 1'#'50'#'45 so they would only be around the number signs.
     
    goneinsane, Apr 22, 2010 IP