Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

How to change to random

Asked Modified Viewed 4,467 times
A
Antonio47
A
For those who believe in God no explanation is Necessary.
For those who do not believe in God no explanation is Possible.
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions
asked
Junior Member

Hi ,

HAPPY NEW YEAR TO ALL.


At last I managed to find a web link panel in which is displacing the last 5 submissions.

and here is the table code:

Quote


$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY weblink_datestamp DESC LIMIT 0,5".....


I would like to display the lat RANDOM 5 site but when I changed the above code with:

Quote

$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY weblink_datestamp RAND() LIMIT 0,5......


I do get the error, aldo I changed the RAND() LIMIT 0,5..... bit into
RAND LIMIT 0,5..... but still no go.

Any help is much appreciated
Edited by Antonio47 on 02-01-2014 13:06,
0 replies

8 posts

M
madison
M
  • Newbie, joined since
  • Contributed 5 posts on the community forums.
answered
Newbie

hello,
try this Code below

$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY RAND() DESC LIMIT 0,5");
0 replies
A
Antonio47
A
For those who believe in God no explanation is Necessary.
For those who do not believe in God no explanation is Possible.
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions
answered
Junior Member

Quote

madison wrote:

hello,
try this Code below

$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY RAND() DESC LIMIT 0,5");


Thanks madison for the code it works fine, infarct now I have a panel with 5 random website links.
But I just noticed when I do click in any of the website link it will take OK to that website but it will create an error on the ErrorLog :

Quote

portal/maincore.php
mysql_num_rows() expects parameter 1 to be resource, boolean given Line: 268


and on line 268 of maincore.php there is :


267 function dbrows($query) {

Quote

268 $result = @mysql_num_rows($query);

269 return $result;

I'm not an expert in php nor in database but I believe the error is caused by an incorrect line code below:

Quote


$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY RAND() DESC LIMIT 0,5");
if (dbrows($result) != 0) {
openside($locale['fwl001']);
while($data = dbarray($result)) {


I thank you in advance for the assistance
0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
answered
Senior Member


$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY RAND() DESC LIMIT 0,5");
if (dbrows($result) != 0) {
    openside("Random Links");
    while($data = dbarray($result)) {
        echo $data['weblink_name'];
    }
    closeside();
} else {
    echo "No links added";
}
0 replies
A
Antonio47
A
For those who believe in God no explanation is Necessary.
For those who do not believe in God no explanation is Possible.
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions
answered
Junior Member

Quote

afaaro wrote:


$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY RAND() DESC LIMIT 0,5");
if (dbrows($result) != 0) {
    openside("Random Links");
    while($data = dbarray($result)) {
        echo $data['weblink_name'];
    }
    closeside();
} else {
    echo "No links added";
}



Many thanks aafaaro, I replaced the code but the error is still there.

Actually your echo $data['weblink_name']; was showing just the website name but it was not hyperlinked so I replaced that line with:

Quote

echo "<div class='welinkspanel'>&#9658 <a href='".BASEDIR."weblinks.php?cat_id=".$data['weblink_id']."&amp;weblink_id=".$data['weblink_id']."' class='side' target='_blank'>";
and worked.

I repaeat the error is still there.
0 replies
A
afaaro
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
answered
Senior Member

I think the error is coming from here cat_id=".$data['weblink_id'] and in your query

try this

$result = dbquery("SELECT weblink_id, weblink_name, weblink_cat, weblink_description, weblink_count FROM ".DB_WEBLINKS." ORDER BY RAND() DESC LIMIT 0,5");
if (dbrows($result) != 0) {
    openside("Random Links");
    while($data = dbarray($result)) {
        echo $data['weblink_name'];
        echo "<div class='welinkspanel'>&#9658 <a href='".BASEDIR."weblinks.php?cat_id=".$data['weblink_cat']."&amp;weblink_id=".$data['weblink_id']."' class='side' target='_blank'>";
    }
    closeside();
} else {
    echo "No links added";
}


if not remove this line [ cat_id=".$data['weblink_cat']."&amp; ]
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Zip and attach your files here. The errors come from no result because dbrows returns.
0 replies
M
madison
M
  • Newbie, joined since
  • Contributed 5 posts on the community forums.
answered
Newbie

Quote

But I just noticed when I do click in any of the website link it will take OK to that website but it will create an error on the ErrorLog :

portal/maincore.php
mysql_num_rows() expects parameter 1 to be resource, boolean given Line: 268


and on line 268 of maincore.php there is :


267 function dbrows($query) {
268 $result = @mysql_num_rows($query);

269 return $result;


I think this Error Log has nothing to do with your new Panel.
take a look in your Errorlog, on which Site this Error was created.

Have you a modifying "weblinks.php" ?

check it, disable your new 5 random Weblinks Panel and delete your Errorlog.
Now open your weblinks.php and click on some Weblinks.
And finally, check your Errorlog again on new entrys.

I have just visited your website and noticed that you have a modified Weblinks.php by Spunk Weblinks with Preview
I use the same modified Weblinks.php from this Author and I get the exact same error message in the error log. But because this error has no impact on the functionality, I simply ignore them. It's just a little Bug. ;)
Edited by madison on 03-01-2014 15:00,
0 replies
A
Antonio47
A
For those who believe in God no explanation is Necessary.
For those who do not believe in God no explanation is Possible.
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions
answered
Junior Member

Quote

madison wrote:

Quote

But I just noticed when I do click in any of the website link it will take OK to that website but it will create an error on the ErrorLog :

portal/maincore.php
mysql_num_rows() expects parameter 1 to be resource, boolean given Line: 268


and on line 268 of maincore.php there is :


267 function dbrows($query) {
268 $result = @mysql_num_rows($query);


Well I tried with different code bu no resolution yet.
I just leave it as it this.
Many thanks for the support


269 return $result;


I think this Error Log has nothing to do with your new Panel.
take a look in your Errorlog, on which Site this Error was created.

Have you a modifying "weblinks.php" ?

check it, disable your new 5 random Weblinks Panel and delete your Errorlog.
Now open your weblinks.php and click on some Weblinks.
And finally, check your Errorlog again on new entrys.

I have just visited your website and noticed that you have a modified Weblinks.php by Spunk Weblinks with Preview
I use the same modified Weblinks.php from this Author and I get the exact same error message in the error log. But because this error has no impact on the functionality, I simply ignore them. It's just a little Bug. ;)
0 replies

Category Forum

Panels and Infusions

Labels

None yet

Statistics

  • Views 0 views
  • Posts 8 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

A
A
afaaro 10
  • Senior Member, joined since
  • Contributed 295 posts on the community forums.
  • Started 68 threads in the forums
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,842 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
M
M
  • Newbie, joined since
  • Contributed 5 posts on the community forums.
A
A
For those who believe in God no explanation is Necessary.
For those who do not believe in God no explanation is Possible.
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 4 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet