View Full Version : Url link problem
LordFrz
06-11-2010, 01:24 AM
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.
djr33
06-11-2010, 02:01 AM
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...
LordFrz
06-11-2010, 02:42 AM
I update the site pages threw a comment type section, that supports html, then that updates the html and saves to server.
http://funigifs.com/host/files/1/public/tos1.jpg
Here is the page once viewed.
http://funigifs.com/host/files/1/public/tos2.jpg
djr33
06-11-2010, 02:48 AM
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).
LordFrz
06-11-2010, 03:20 AM
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.
LordFrz
06-11-2010, 04:08 AM
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.:)
djr33
06-11-2010, 04:29 AM
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:
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.