1
bb2120
MyDownloads random download block
  • 2005/12/7 20:07

  • 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
gestroud
Re: MyDownloads random download block
  • 2005/12/7 20:26

  • gestroud

  • Home away from home

  • Posts: 1538

  • Since: 2004/12/22


Forget about getting an answer for that problem here. The same question has been asked about this module and the links module more than once and the question continually gets ignored. You'd think that if there is no answer, someone would at least have the common courtesy to say so.

3
bb2120
Re: MyDownloads random download block
  • 2005/12/7 21:13

  • bb2120

  • Not too shy to talk

  • Posts: 179

  • Since: 2005/7/6 1


True, completely true, and thanx for a reply

I admit, I have double posted, but I cleverly (not) managed (both times I posted) to put the thread in the wrong forum.

Can anyone suggest a decent php/mysql coding forum? Trust me, I've looked hard to find one. Anyway, I'm surpised no-one answered this post with the number of people that must have seen it......

I don't actually think that there is an elegant way to do what I'm doing - there's no magic PHP function (I don't think). I think that I might have to find the number of rows in the DB table and choose a rand()integer between 1 and and that number, then return the row as an array.

If I work out how to solve this bloody problem, then I'll be sure to post it many times (yes, many) in these forums and give something back to the community


I'll try and get this answered elsewhere.


Apologies for all these darn posts that I've created!

Login

Who's Online

235 user(s) are online (58 user(s) are browsing Support Forums)


Members: 0


Guests: 235


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