Dustin013 Posted July 14, 2008 Share Posted July 14, 2008 I am querying a database for a list of directories. The query is simply returning the name of the directory that is stored in the mysql database. For example the query will search for anything starting with the letter B. This would result in returning Brandon Folder1. To see the contents of that folder I am passing information through the URL, script2.php?item=Brandon Folder1. What I need for the script to do is if there is a space in the directory of the folder like above, I need it do, script2.php?item=Brandon%20Folder1... any suggestions? Here is my query $query = "SELECT * FROM `testdb` WHERE `foldername` LIKE CONVERT( _utf8 '".$item."%' USING latin1 ) COLLATE latin1_swedish_ci"; $result = @ mysql_query ($query) or die ("Query '$query' failed with error message: \"" . mysql_error () . '"'); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<a href=\"script2.php?item={$row['foldername']}\" onclick=\"load('script2.php?item={$row['foldername']}','listings');return false;\">{$row['foldername']}</a><br />"; } Link to comment https://forums.phpfreaks.com/topic/114742-solved-how-do-i-get-php-to-put-20-when-there-is-a-space/ Share on other sites More sharing options...
trq Posted July 14, 2008 Share Posted July 14, 2008 urlencode(). Link to comment https://forums.phpfreaks.com/topic/114742-solved-how-do-i-get-php-to-put-20-when-there-is-a-space/#findComment-590015 Share on other sites More sharing options...
Dustin013 Posted July 14, 2008 Author Share Posted July 14, 2008 Awesome! Quick questions about syntax... urlencode($row['showname']); then I echo out $row['showname']; and it still doesn't have %20 or + substituted for the spaces... any suggestions? Link to comment https://forums.phpfreaks.com/topic/114742-solved-how-do-i-get-php-to-put-20-when-there-is-a-space/#findComment-590025 Share on other sites More sharing options...
trq Posted July 14, 2008 Share Posted July 14, 2008 echo urlencode($row['showname']); Link to comment https://forums.phpfreaks.com/topic/114742-solved-how-do-i-get-php-to-put-20-when-there-is-a-space/#findComment-590028 Share on other sites More sharing options...
Dustin013 Posted July 14, 2008 Author Share Posted July 14, 2008 Nevermind... $row['blah'] = urlencode($row['blah']); Thanks! Link to comment https://forums.phpfreaks.com/topic/114742-solved-how-do-i-get-php-to-put-20-when-there-is-a-space/#findComment-590029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.