__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
Last edited by danielwarner; 12-24-2006 at 05:23 PM..
$queryorder = mysql_query("SELECT `order` FROM `images` WHERE ref ='".$imageid."' ORDER BY `order` DESC LIMIT 0,1");
and
PHP Code:
$querysuffix = mysql_query("SELECT `suffix` FROM `images` WHERE ref ='".$imageid."' ORDER BY `suffix` DESC LIMIT 0,1");
Note the ". and ." around $imageid
Dan
Dan
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
Your problem lies with variable scope. It could also lie with $imageid being delineated with apostrophies. If the db table column datatype is numeric, then you need to pass $imageid as a numeric value, not a string.
I edited my code but it still doesnt work. the script tries to echo the variable and wont display anything...im sure this has something to do with the way it is passed into the function. Is the layout of my function correct or is there a reason it isnt being passed?
__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
Could you please tell us what error message you get (or exactly what output you get). Are error messages on? It should be possible to debug your script by e.g. adding some 'var_dump' statements selected places to see where things go wrong. (Much easier than looking at the entire script without running it).
Are you sure $imageid isn't passed to the function??? Find out by putting a var_dump($imageid); in the first line of the function to display its value.
This is the url with the code on it. >>http://www.caravansandtrailertents.co.uk/trialupload.php<< no error message is displayed and i do attempt to echo the variable name and image name. The name should come out to be uploads/100_1.jpg etc etc... but at the moment its just the ..._1 part of the file name that comes out. (which is a problem because the name links to the images id).
The var_dump hasnt shown anything.
I have read the tutorial on Variable scope, which i atchually found very interesting although irrelevent and i did atchually learn something from it which i didnt already know. I do believe i am passing the ID number into the function though (although this is the 3/ 4th time i have ever used a function before so it may be wrong!)
Thanks for showing interest!!
__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
While I see the error when running your live version of the script, I tried to run your script on my own server, setting up a single table in the database too. But I couldn't reproduce the error. I got uploads/100_1.jpg. So I really have no clue what the problem could be?
Quote:
The var_dump hasnt shown anything.
Can you then verify that you get dumped the value NULL? I believe that the var_dump should always outputs something... Did you try:
PHP Code:
function uploadImage($width,$height,$getfrom,$cat,$imageid) {
var_dump($imageid);
// the rest of the function
}
This should definitely tell us whether $imageid is passed to the function or not.
Can you show me a dump of the table you used please....its a long shot but that may have something to do with it i guess...
__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
Adding the following line after your first opening <?php tag might give more information about what is going on (you might also need to turn on display_errors to receive any output) -
PHP Code:
error_reporting(E_ALL);
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
Ok thanks for the help everyone i have got the ID number to display now somehow? My Problem is now that the images that i try to resize all come out at a fixed size and with the same suffix although they should increment.
__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
* Picks up computer and throws it out the window *
Im really sorry for wasting your time. The problem was that the file i was trying to make work was called trialupload.php. This is a cut and paste job of a larger form which made it easier to refresh the image upload system and avoid the sequrity of the larger form. The larger form was called imageupload.php and if you look in the code i posted called trialupload.php the form still pointed to the old file called imageupload.php. This means all the work i was trying to do to fix it wasnt athchually being tested but was sitting in a different file.
I think i can fix it on my own now its just that before i was very unframiliar with the irregular result php was showing me!
Im very sorry for wasting your time and im very greatful that you spent the time to help me fix my script!
__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
Got abit carried away before when i got it to work and now i have got another bug although this one i cant understand at all.
What happened is i managed to get the images to resize, upload to my server, upload to my database, rename them all, fixed a few more bugs along the way untill i finally finished and it worked perfectly. Then it struck me. Because i have 2 of the same image sometimes that are just sized differently i needed a database column to show a link between the two image files. I made this and it worked, but then the images decided not to resize themselves to their correct defined size and all come out small. Not only this i have found that although the images load to the database correctly the suffix seems to be fixed at _10. I dont know whats causing this and i suspect this is the reason all 5 images havnt been uploaded to my server but only 1 of them has (being 72_10.jpg)
Test the code for yourself >>http://www.caravansandtrailertents.co.uk/trialupload.php<<
Infact, after running a few tests, the images all resize to the smallest (or maybe just last) image size that has been defined. Because the Suffix isnt changing this may be the reason why all the images are being shown as smaller. as the page is attempting to load the last image made 5 times when being echo'd.
__________________ Daniel Warner
- - - - - - - - - - GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.
Last edited by danielwarner; 12-26-2006 at 02:28 AM..