# PHP urlencode()

**URL:** <https://forum.kirupa.com/t/php-urlencode/253160>\
**Category:** Uncategorized\
**Created:** [February 27, 2008, 7:11pm UTC](https://forum.kirupa.com/t/php-urlencode/253160 "2008-02-27T19:11:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phillyrob817](https://avatars.discourse-cdn.com/v4/letter/p/278dde/32.png) [@phillyrob817](https://forum.kirupa.com/u/phillyrob817)\
**Post date:** [February 27, 2008, 7:11pm UTC](https://forum.kirupa.com/t/php-urlencode/253160/1 "2008-02-27T19:11:08Z")

</div>

I received a partial resolution to this issue but have another question. When I directly add

urlencode() to my php page to post a variable. I can read it and process it with no problem; as in this code. **echo “&yorName=As&”;.** I put this in and have no problems reading playing this song. However when I try to call from mysql, it will call the variable fine, I have it echo so I see it pulling the right variable(song), but it won’t play. Again, using the code above it will play fine, but when I call it from mysql it won’t play. Here is the code I use. I pull from the db fine.

\<?php

include (‘connect\_music.php’);  
//Collect Form Data  
$string = $\_POST[‘artist’];  
$string2 = $\_POST[‘song’];  
$string3 = $\_POST[‘album’];

//Issue SQL SELECT Statement  
$sql2 = “SELECT song,artist,album FROM music WHERE song = ‘$string2’”;  
$rs2 = mysql\_query($sql2, $link);

if(!empty($\_POST))  
{  
while($row2 = mysql\_fetch\_array($rs2))

{

echo “\<strong\>Song Found\</strong\>:”. " ". " ". $row2[‘song’]. “\<br/\>”;

}  
$mysong = $row2[‘song’];  
echo “&yorName=$mysong&”;  
}

?\>

It pulls the variable and shows on the screen, but will not play. Again if I just say **echo “&yorName=As&”;** and manually put the variable in, it loads and plays fine\*\*.\*\*
