Jump to content

Can't get song to play when pulling from database


phillyrob

Recommended Posts

I have an interesting issue. When I manually type a url-encoded song title and echo it, it will play in my flash song player using AS2, but when I pull the song title from the database and echo it in the same format it won't play. The name of the song is "As" by Stevie Wonder. When I manually type it in like this: echo "&title=As&"; It echos to the screen in just that format, and I can pick it up as a variable in Actionscript 2 and play it. But when I do it like this:

 

$string2 = $_POST['Song'];

 

$rs2 = mysql_query("SELECT * FROM mymusic where song = '$string2'");

$row2 = mysql_fetch_array($rs2);

$sng = $row2['Song'];

 

echo "&title=$sng&"

 

it echos to the screen fine, and in the exact format as the manual echo, but it won't play. does anyone have any ideas as to why

test to make sure the mysql query is getting what it needs to. If you have phpmyadmin, run that querty, and insert As where you have $string2 and see if any rows pop up. It could be the format of your data in the database.

 

 

Fake edit: I see your problem. You're saying "Look in my database where the column name is 'song' and find 'As'. And then when you're trying to get the variable after mysql_fetch_array, you're telling it "give me the array variable where the column name is 'Song'. That capital S and lowercase s is the difference maker. Check which case your 'song' column is and make them identical

Thanks, but I have tried it multiple ways including changing upper and lower case. Again it echoes and post from the database to the screen exactly as needed and the exact same as when I manually put it in, but it will not play. Thanks again though.

Can you show us the entire code?  (The entire PHP file)

 

The seems to be somewhere else.

 

 

Also, why are you pulling a column equal to a value?

 

I'm pretty sure MySQL columns are case-insensitive, so why would you pull a column equal to a value and then echo it?

 

$rs2 = mysql_query("SELECT * FROM mymusic where song = '$string2'");

$row2 = mysql_fetch_array($rs2);

$sng = $row2['Song'];

 

Isn't that the same as just doing

 

echo $string2;

 

?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.