Results 1 to 7 of 7

Thread: Url link problem

  1. #1
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Url link problem

    I run a clip bucket based site, and Im having some trouble with my urls.

    I am using an internal html editor to set text and links on pages.

    The problem is when I place a URl it ads extra "" to my link, which stops them from working.

    Example: http://videotutorworld/contact/

    turns into http://videotutorworld/"contact/"

    Here is a page example with the links

    http://videotutorworld.com/page/3/terms-of-serivce

    You can also see on that page that everywere I have "" it ads a \

    "Terms" turns into \"terms\"

    If you have any idea how to fix this it would help a lot.

    P.S. Im using chrome browser.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That's called "escaping".

    $var = "quotes \"MUST\" be escaped";

    That way, the literal quotes within the string are preserved rather than acting to start/end the string.

    The problem here is in something PHP is doing to the variables, but it's really hard to know what it might be without seeing the code.

    What are these "links"? Are they from a database? Directly coded into the page? Sent from forms?

    The reasons will depend on the method...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I update the site pages threw a comment type section, that supports html, then that updates the html and saves to server.



    Here is the page once viewed.

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    That makes sense. This CMS (content management system) is escaping your URLs.

    The way to fix this entirely depends on the CMS:
    1. Rewrite it's code (last resort).
    2. Enter the URLs differently (is there a "URL" button?)
    3. Change the settings in the admin control panel for the CMS, if that exists.


    I'd suggest asking about this on the help/support site for the CMS if you can't find the answer.



    There's one other possibility: your server may be automatically escaping quotes. This happens with older (<4) versions of PHP.
    It's called "magic quotes" and it's really annoying. It's always best to turn it off (unless you find that some of your pages require it, but then that's just badly designed PHP code, so it should be rewritten anyway rather than relying on a bad standard).
    Here's a search to get you started:
    http://www.google.com/search?q=turn+off+magic+quotes
    Unfortunately turning it off varies depending on what sort of access you have to the server. The best way if you can't turn it off in php.ini is probably to use .htaccess. Using it within the PHP script itself doesn't always work (at least it hasn't been reliable for me, though I haven't had too many problems with this, just a couple chance encounters).
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the help, ill take a look at your suggestions. I do have access to my php.ini so ill give it a look.

  6. #6
    Join Date
    Jun 2010
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Well , i got it fixed, I went to my config.php and added this code


    if (get_magic_quotes_gpc()) {
    function undoMagicQuotes($array, $topLevel=true) {
    $newArray = array();
    foreach($array as $key => $value) {
    if (!$topLevel) {
    $key = stripslashes($key);
    }
    if (is_array($value)) {
    $newArray[$key] = undoMagicQuotes($value, false);
    }
    else {
    $newArray[$key] = stripslashes($value);
    }
    }
    return $newArray;
    }
    $_GET = undoMagicQuotes($_GET);
    $_POST = undoMagicQuotes($_POST);
    $_COOKIE = undoMagicQuotes($_COOKIE);
    $_REQUEST = undoMagicQuotes($_REQUEST);
    }

    Works now. Thanks for your help.

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'd recommend figuring out how to turn it off completely (using at least .htaccess, hopefully php.ini if you can get to it).
    That'll work fine for this but anything else you add on the same host will have the same (potential) problem.


    Note also that the function you are using is only minimally effective: it works on specific input data and may not work as expected in all cases.
    Also, for some particularly annoying reason, the keys (in addition to the values) are escaped like this, so to fully remove it you need to do:
    PHP Code:
    foreach($somearray as $key=>$value) {
    $newarray[undo($key)] = undo($value);
    }
    $somearray $newarray;
    //(pseudo code) 
    In reality this may rarely be an issue, but it'll be very confusing if it ever does occur.

    magic quotes is something that should be banned from use, and in fact most people are trying to remove it, but it's still floating around on enough servers (as a default in php4, etc) that it's a frequent issue.

    Good luck.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. The Following User Says Thank You to djr33 For This Useful Post:

    LordFrz (06-11-2010)

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
  •