like johnyv said change your query to:
$connection = mysql_connect($DBhost,$DBuser,$DBpass);//connects to mysql db
$sql="SELECT url image FROM $table ORDER BY id RAND";//this is a query you're about to ask
$result = mysql_query($sql,$connection);//ask a query to the db from $connection
and just then use the while loop, like:
while ($row = mysql_fetch_assoc($result)) {
And then when you want to echo the result of your query, inside the loop, do:
echo $row["url"] and echo $row["image"]...
Like the guys said this is the way that it should be done... Have you tried everything that I summed up here?