1
bb2120
MyDownloads random download
  • 2005/12/3 19:40

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


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!

2
bb2120
Re: MyDownloads random download
  • 2005/12/3 19:43

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


BTW, the reason I have chosen to print $rand_row['url'] is to test that the mysql_fetch_array worked - I will format a proper block with the screenshot etc. later on

3
bb2120
Re: MyDownloads random download
  • 2005/12/3 19:47

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


Oh dear, I've posted this in the wrong forum.........

4
gediminasbyt
Re: MyDownloads random download

Moved to closer match

5
bb2120
Re: MyDownloads random download
  • 2005/12/7 20:05

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


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!

Login

Who's Online

456 user(s) are online (92 user(s) are browsing Support Forums)


Members: 0


Guests: 456


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits