OAFC_Rob Posted May 3, 2011 Share Posted May 3, 2011 Hey people just been watching a php tutorial that mentions using rawurlencode for the links, ive pretty much followed th tutorial to the later bar using different pages, see coding below. However, it just doesnt work bringing back that object was not found Any ideas whats going wrong or why it isn't working? <?php #retrive from database and do a foreach loop maybe. $urlPage = "loginArea/login.php"; $param1 = "robert"; $url = "http://localhost/duff3/"; $url .= rawurlencode($urlPage); $url .= "?userId=" . urlencode($param1); ?> <ul class="menu"> <li><a href="<?php $_SERVER["DOCUMENT_ROOT"] ?>/duff3/index.php" class="nav_selected"> home </a></li> <li><a href="test.php?id=1" class="nav"> bio</a></li> <li><a href="<?php echo htmlspecialchars($url); ?>" class="nav"> publicity</a></li> <li><a href="" class="nav"> recordings</a></li> <li><a href="" class="nav"> contact </a></li> </ul> Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/ Share on other sites More sharing options...
requinix Posted May 3, 2011 Share Posted May 3, 2011 rawurlencode() will encode slashes. The result is that Apache thinks the link is to a file named "loginArea/login.php" (which is not the same as the "login.php" file in the "loginArea" directory). In the code you've posted there is no need to use rawurlencode() anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1209933 Share on other sites More sharing options...
OAFC_Rob Posted May 3, 2011 Author Share Posted May 3, 2011 So basically it is the direct pathway then? Rather than a pointing to the link Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1209953 Share on other sites More sharing options...
requinix Posted May 3, 2011 Share Posted May 3, 2011 "Direct pathway"? "Pointing to the link"? What? Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1209970 Share on other sites More sharing options...
OAFC_Rob Posted May 3, 2011 Author Share Posted May 3, 2011 As in a pathway that you would use on your computer ie C:/programs/ Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210005 Share on other sites More sharing options...
requinix Posted May 3, 2011 Share Posted May 3, 2011 Um... So basically it is the direct pathway then? Rather than a pointing to the link Yes :-\ Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210032 Share on other sites More sharing options...
OAFC_Rob Posted May 4, 2011 Author Share Posted May 4, 2011 Okay I think I get you know, when / where would be the best place to use rawurlencode? Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210324 Share on other sites More sharing options...
requinix Posted May 4, 2011 Share Posted May 4, 2011 You would use rawurlencode() for paths in a URL, but for the individual names - not an entire chunk of it. Only only if you don't know that the name is valid in that part of a URI. Your path is //localhost/duff3/loginArea/login.php. You know that for sure. Since it's URL-valid (ie, no unusual characters) you don't have to do anything to it. If you didn't know for sure then you might use rawurlencode() for directory and file names. "//localhost/" . rawurlencode($base_directory) . "/" . rawurlencode($sub_directory) . "/" . rawurlencode($submit_filename) With that all said, I have never used rawurlencode() for anything. urlencode, a similar function with a similar use, is much more common. Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210585 Share on other sites More sharing options...
OAFC_Rob Posted May 4, 2011 Author Share Posted May 4, 2011 Thanks for explaining that, I have used urlencode before and thought rawurlencode was for all of it, but I get it now, it is more for something like http://localhost/duff3/new page/ and stuff like that unusual characters and for only bits of it, correct? Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210609 Share on other sites More sharing options...
requinix Posted May 4, 2011 Share Posted May 4, 2011 Right. (But you might as well just type "new%20page" instead of using rawurlencode() for it.) Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210640 Share on other sites More sharing options...
OAFC_Rob Posted May 5, 2011 Author Share Posted May 5, 2011 yep I get it now thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/235430-rawurlencode-issue/#findComment-1210834 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.