TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 11-03-2008, 12:10 PM   #1 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default problem with max()

hey i want choose 5 users whos gain the max points and ive made this code

PHP Code:
          $val mysql_query("SELECT max(point) FROM `points`")or die(mysql_error());
          while(
$able mysql_fetch_array($val))
          {
          echo 
$able['MAX(point)']."<br />";
          } 
BUT IT GIVE IS BLANK PAGE :s
is there any solutions thanks
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 11-03-2008, 12:40 PM   #2 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

I think the problem is that the variables are case sensitive. So changing the first instance to uppercase should fix the problem.

PHP Code:
          $val mysql_query("SELECT MAX(point) FROM `points`")or die(mysql_error());
          while(
$able mysql_fetch_array($val))
          {
          echo 
$able['MAX(point)']."<br />";
          } 
Schroder is offline  
Reply With Quote
Old 11-03-2008, 01:08 PM   #3 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

i used ur code and it douesnt give me the max number :s
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 11-03-2008, 01:17 PM   #4 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

Does it still give you the blank page, or is it giving you the wrong number?

I also wanted to confirm, is 'point' a field in your 'points' table?
Schroder is offline  
Reply With Quote
Old 11-03-2008, 01:18 PM   #5 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

it give me the wrong number

yes point is a field in my points table
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 11-03-2008, 01:25 PM   #6 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

Hmm... are you wanting to show the highest number that's in the point field or something else? If it's something else can you give some more information?

Thanks! =D
Schroder is offline  
Reply With Quote
Old 11-03-2008, 03:57 PM   #7 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

yes im trying to get the highest number on the point field
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 11-03-2008, 05:26 PM   #8 (permalink)
The Contributor
 
DeMo's Avatar
 
Join Date: Jan 2008
Location: Brazil
Posts: 77
Thanks: 14
DeMo is on a distinguished road
Default

POINT is a undocumented (?) data type in MySQL.

Try this:
PHP Code:
$val mysql_query("SELECT MAX(`point`) AS maxpoint FROM `points`");
while (
$able mysql_fetch_array($val))
    echo 
$able['maxpoint'] . "<br />"
Or an alternative would be this query:
PHP Code:
"SELECT `point` AS maxpoint FROM `points` ORDER BY `point` DESC LIMIT 1" 
Send a message via ICQ to DeMo Send a message via MSN to DeMo Send a message via Skype™ to DeMo
DeMo is offline  
Reply With Quote
Old 11-03-2008, 07:10 PM   #9 (permalink)
The Addict
 
webtuto's Avatar
 
Join Date: Dec 2007
Location: morocco
Posts: 221
Thanks: 19
webtuto is on a distinguished road
Default

ive tryied both ways but no results [ blank page ]
__________________
Send a message via MSN to webtuto Send a message via Yahoo to webtuto Send a message via Skype™ to webtuto
webtuto is offline  
Reply With Quote
Old 11-07-2008, 03:03 PM   #10 (permalink)
The Wanderer
 
Schroder's Avatar
 
Join Date: Mar 2008
Posts: 20
Thanks: 0
Schroder is on a distinguished road
Default

Hmmm... wouldn't it return an error if it was trying to use the data type instead of the field name?

Would it be possible to get a SQL dump of what you currently have,or the structure + something that is similar?
Schroder is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 07:02 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design