Simple MySql Question!

O

old.Fubs

Guest
When i query the database is there any way of sorting the results. The entries in the database are entered in a random order, but i want them listed in a certain order.

This order is an integer 1-4, and then a name.

all the entries with a 4 are first, sorted in alphabetiacal order,
then all the entries with a 3, etc

if anyone could help it would be great
 
O

old.Fubs

Guest
another PHP Question. I'm trying to write a script to allow you to upload an image to the server, and then veiw it from the members page on the webby.

My code is

Code:
<?php 
        if ($userfile == "none") { 
            print "You must specify a file to upload"; 
        } 
        else { 
        $file_name=$UserLogon;
        copy($userfile, "/images/portraits/$file_name.jpg"); 
        echo "file @ /images/portraits/$file_name.jpg";
//        unlink($file); 
        } 
?>
if i try to upload an image i get this error:

Code:
Warning: SAFE MODE Restriction in effect. The script whose uid is 549 is not allowed to access /tmp/phpCBstGM owned by uid 0 in /home/foghat/public_html/upload.php on line 13
file @ /images/portraits/fubar.jpg

I CHMOD the /images/portraits dir 777, am I correct in thinking that i have write access to the tmp dir but no read?

Any suggestions, the site isnt hosted at BW, but www.unrealtournament.co.uk, will i have to contact one of the sysops?
 
O

old.crazydave

Guest
MySQL sorting

To sort the order of a MySQL query your have to add ORDER BY to it. e.g. SELECT username, email, icq, lastaccessed FROM users ORDER BY lastaccessed DESC;

This would bring back the results sorted by lastaccessed in descending order. If you want the results in ascending order don't add the DESC bit to the end.

Also if you add LIMIT 0,30 to the end you can get it to only return 30 results. Useful for listing stuff across pages as you can use LIMIT 30,60 to give you the next 30 results.

As for your uploading problem, haven't looked at that much but from the error message it gave Barrysworld might have disabled php uploads for security reasons or something.
 
O

old.Fubs

Guest
the site isnt on BW, and i spoke with a UTUK admin, and for security reasons the copy command is disabled.

Is there any way to UL a file directly to my path?
 

Users who are viewing this thread

Top Bottom