Go Back   Web Hosting UK Forums | Linux Windows Dedicated Server and cPanel VPS Hosting Forum > Support > MySQL Issues.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-11-2008, 06:11 PM
Senior Member
 
Join Date: Dec 2006
Posts: 547
Send a message via MSN to karimali831
Default Need help with this

Can anyone see anything wrong with this?

Code:
$query = "SELECT id,alias FROM users ORDER by id DESC LIMIT 5"; 
$lastreg = mysql_query($query);
    while(list($id,$alias)=mysql_fetch_row($lastreg)){
        $lastreg=$lastreg."$out[bulletleft] $alias"; 
    }
    if(!$lastreg){
        $lastreg = "$out[bulletleft] No members yet"; //
    }
The limit is set on 5, but only 1 is being displayed. And not sure about this but when the the output is displayed, it will show "Resource id... followed by the output" not sure how to change resource id either
Reply With Quote
  #2 (permalink)  
Old 05-11-2008, 06:13 PM
Senior Member
 
Join Date: Dec 2006
Posts: 547
Send a message via MSN to karimali831
Default

hmm HTML works in [code] tags?
Reply With Quote
  #3 (permalink)  
Old 05-11-2008, 06:27 PM
Senior Member
 
Join Date: Dec 2006
Posts: 547
Send a message via MSN to karimali831
Default

One last thing, if you go to at the top you can see there is an offer running off this script:

Code:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/sites/online/public_html/home.php on line 62
Link 62 =
Code:
while(list($id,$alias)=mysql_fetch_row($lastreg)){
That might help.
Reply With Quote
  #4 (permalink)  
Old 05-12-2008, 07:30 AM
Member
 
Join Date: Nov 2007
Posts: 33
Default

Quote:
Originally Posted by karimali831 View Post
Can anyone see anything wrong with this?

Code:
$query = "SELECT id,alias FROM users ORDER by id DESC LIMIT 5"; 
 // $lastreg is a the resource id
$lastreg = mysql_query($query);
    while(list($id,$alias)=mysql_fetch_row($lastreg)){
 // now you are changing it but you're still in the loop
       $lastreg=$lastreg."$out[bulletleft] $alias"; 
    }
    if(!$lastreg){
        $lastreg = "$out[bulletleft] No members yet"; //
    }
The limit is set on 5, but only 1 is being displayed. And not sure about this but when the the output is displayed, it will show "Resource id... followed by the output" not sure how to change resource id either
Your lastreg string is being changed from an sql resoucre id to a what looks like an output string.

This should work -
Code:
$query = "SELECT id,alias FROM users ORDER by id DESC LIMIT 5"; 
 // $lastreg1 is now the resource id
$lastreg1 = mysql_query($query);
    while(list($id,$alias)=mysql_fetch_row($lastreg1)){
        $lastreg=$lastreg."$out[bulletleft] $alias"; 
    }
    if(!$lastreg){
        $lastreg = "$out[bulletleft] No members yet"; //
    }

Last edited by scottie2212; 05-12-2008 at 07:33 AM.
Reply With Quote
  #5 (permalink)  
Old 05-12-2008, 09:10 AM
Senior Member
 
Join Date: Dec 2006
Posts: 547
Send a message via MSN to karimali831
Default

It worked, thanks soo much!!
Reply With Quote
  #6 (permalink)  
Old 05-12-2008, 12:12 PM
Senior Member
 
Join Date: Dec 2006
Posts: 547
Send a message via MSN to karimali831
Default

Opz, remove this post please.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:17 PM.
Copyright 2002-2007 WebHosting.uk.com. All rights reserved.
Web Hosting UK Forum