SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET versus Apostrophes

    I'm working on a content management system, where $_GET is supposed to equal values in my database that look like this:

    Nevada’s_State_Flower

    However, it appears to be tripping up on the apostrophe. It works if I change both my database value and URL to this:

    PHP Code:
    http://geosymbols/world/Nevadas_State_Flower 
    Otherwise, none of these URL's work with the original database value:

    PHP Code:
    http://geosymbols/world/Nevada's_State_Flower
    http://geosymbols/world/Nevada’s_State_Flower
    http://geosymbols/world/Nevada’s_State_Flower 
    Thanks for any tips.

  2. #2
    Thinking! Lord Brar's Avatar
    Join Date
    Jun 2004
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geosite
    I'm working on a content management system, where $_GET is supposed to equal values in my database that look like this:

    Nevada’s_State_Flower

    However, it appears to be tripping up on the apostrophe. It works if I change both my database value and URL to this:

    PHP Code:
    http://geosymbols/world/Nevadas_State_Flower 
    Otherwise, none of these URL's work with the original database value:

    PHP Code:
    http://geosymbols/world/Nevada's_State_Flower
    http://geosymbols/world/Nevada’s_State_Flower
    http://geosymbols/world/Nevada’s_State_Flower 
    Thanks for any tips.
    You would need to addslashes like addslashes($_GET['url']).

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, I changed this...

    PHP Code:
    $MyName $_GET['area']; 
    to this...

    PHP Code:
    $MyName addslashes($_GET['area']); 
    Is that what you mean? It still doesn't work. I wonder if I need to do something with mod-rewrite as well.

    This was my original mod-rewrite rule:

    PHP Code:
    RewriteRule ^world/([a-zA-Z_]+)/?$ world/index.php?area=$[L
    I just changed it to this, hoping it would recognize the various characters associated with apostrophes, but it doesn't work, either:

    PHP Code:
    RewriteRule ^world/([a-zA-Z_’’]+)/?$ world/index.php?area=$1 [L] 
    Thanks.

  4. #4
    Thinking! Lord Brar's Avatar
    Join Date
    Jun 2004
    Posts
    787
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by geosite
    OK, I changed this...

    PHP Code:
    $MyName $_GET['area']; 
    to this...

    PHP Code:
    $MyName addslashes($_GET['area']); 
    Is that what you mean? It still doesn't work. I wonder if I need to do something with mod-rewrite as well.

    This was my original mod-rewrite rule:

    PHP Code:
    RewriteRule ^world/([a-zA-Z_]+)/?$ world/index.php?area=$[L
    I just changed it to this, hoping it would recognize the various characters associated with apostrophes, but it doesn't work, either:

    PHP Code:
    RewriteRule ^world/([a-zA-Z_’’]+)/?$ world/index.php?area=$1 [L] 
    Thanks.
    Dunno about the mod_rewrite. I would wait for someone else to reply about that... however, you'd have to addslashes to the $_GET['area'] for the simple reason because that's how you store it in the database (someone correct me if I am wrong ) and that's from where you will be selecting it with your sql statement.

    Say your sql statement has something like :

    SELECT * FROM your_table WHERE title='Nevada's_State_Flower' << See the mistake here?

    While adding it to SQL you would have added : Nevada\'s_State_Flower


Bookmarks

Posting Permissions

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