View Full Version : Need Help With My Script plz


HeLpM3
08-08-2006, 11:05 AM
ok i keep getting an error and i really dont know what the problem is this is what i keep getting
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1

My Code Here
<?php
//Random Music generator
include("config.php");

$music_select = mysql_query("SELECT * FROM music ORDER BY RAND()");
$get_music = mysql_query($music_select) // querys the music db
or die(mysql_error()); // die error!

$row = mysql_fetch_array($get_music);


$music_src = $row['songsrc'];








print("
<tr><td id=\"musicbg\"><center><embed src=\"$music_src\" width=\"50\" height=\"25\" loop=\"-1\"></embed><br/>");

$music_select2 = "select * from music where songsrc=$music_src"; // selects the requested id from the database
$get_music2 = mysql_query($music_select2)
or die(mysql_error()); // die error!

if (mysql_num_rows($get_music2) == "0") {

echo 'No Music :('; // nothing found error!
exit(); // exit
}
$row = mysql_fetch_array($get_music2) // array
or die(mysql_error()); // error!


$music_title = $row2['songtitle'];


print("<i>$music_title</i></td></tr>");



?>

Douglas
08-08-2006, 04:13 PM
Change this line:

$music_select = mysql_query("SELECT * FROM music ORDER BY RAND()");

To:

$music_select = "SELECT * FROM music ORDER BY RAND()";

HeLpM3
08-09-2006, 12:48 AM
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'music/Unknow.wma' at line 1

ok now i'm getting this error i was wondering if its another way to do it cause i search the internet and i found that alot of people have trouble with this

Douglas
08-09-2006, 01:05 AM
Change this:

$music_select2 = "select * from music where songsrc=$music_src";

To this:


if (!get_magic_quotes_gpc()) {
$music_src = addslashes($music_src);
}
$music_select2 = "SELECT * FROM music WHERE songsrc='{$music_src}'";