5
Hiya everyone,
I'm trying to create a custom block that allows me display a random download from the mydownloads table in the DB.
I have tried putting the code into a custom block, but that results in errors in the block handler file.
Therefore I have run the following code as a .PHP file (which is why I've used php start and end tags)
When executing it from a browser, I get
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in [server path]
Quote:
[php start tag]
mysql_connect('[host]', '[user]', '[password]');
mysql_select_db('[DB]');
$rand_row = mysql_fetch_assoc(mysql_query('USE [DB] SELECT title, url, logourl FROM [table_prefix]_games_downloads ORDER BY RAND() LIMIT 1'));
print ($rand_row["url"]);
[php end tag]
Can anyone help me out? - this 'simple task' has been irritating me for days!