Haha its been driving me up the wall for the past month.
I shall edit this tommorow at work as the time difference here has made it pretty late. Thank you so much for debugging and taking the time to help. I’ll post results tommorrow
Sorry for the delay.
I noticed the first error “not a directory” it is looking for the image file name as a directory. the image file name in this case is “servicespg.jpg”.
I also noticed that with the code you set up there, that servicespg.jpg is in fact present in the list below.
Im not too sure how this list has been produced though as all my images on the server control panel have disappeared… (nothing inside images/COMPANIES or images/thumbs?) <but that’s not too important really.
Just to try and help simplify the problem i have deleted the folder that had nothing inside it (called images). Just leaving the 2 target folders images/COMPANIES and imges/thumbs. Hope this helps.
This is the error report within the browser:
Warning: opendir(/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/servicespg.jpg) [function.opendir]: failed to open dir: Not a directory in /hermes/bosoraweb023/b109/ipg.removalspacecom/view02.php on line 42
Warning: readdir(): supplied argument is not a valid Directory resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/view02.php on line 44
Warning: closedir(): supplied argument is not a valid Directory resource in /hermes/bosoraweb023/b109/ipg.removalspacecom/view02.php on line 45
Target
Thumb
.
…
index_1.jpg
halyle-self-storage-web-page.png
Med%20van.jpg
logo_storagekings.gif
logo_php_freaks.png
logo1.gif
small removals.jpg
pickfords.jpg
360 logo 2011.jpg
companylogo(5).jpg
staffatstorage.jpeg
0638096001204120140l.jpg
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
Penguins.jpg
theremovals-update1-e1342467838697-300x163 (1).png
emotionheader.jpg
about_156145942.jpg
ryewharflogo.jpg
IMAG0151.jpg
Bannerlogo.jpg
logo_space_maker.jpg
burg.jpg
a_griffin_and_sons.jpg
krgavinpic 008.jpg
planet earth.jpg
smlogo.jpg
homepic2.jpg
banner.png
wpe76dbf3e_06.png
logo_equus.png
pic_0019.jpg
scan0001.jpg
burg.jpeg
mail.jpg
home_moving_house.png
360transportheader2012.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
020.JPG
titlenavbar2_r1_c1.png
logo.png
index_01.jpg
bg-1-273123.jpeg
capital-cargo-couriers-london_r2_c2.gif
bude-self-storage-logo.png
santa’s-arm.png
wpf97a952b_06.png
channelmoving-logo.jpg
blackholestoragelogo.png
logo.gif
Logo.gif
absoluteselfstore.co.uk.jpg
header.jpg
bg-1-25531.jpg
DSCF0216.JPG
360fbcover.jpg
header-martells_logo.jpg
logo_1.jpg
liverpool_removals_service.jpg
logo_liftandshift.png
home.jpg
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
van.png
top_image.jpg
logobournes.jpg
image1.jpg
banner.gif
extraspace.png
banner.jpg
driving_color_0001_logo.png
logo_the_move_team.png
pic_1.jpg
covered_secure_storage.jpg
title.jpg
girl2.jpg
amendheadere.png
logo.jpg
logo.JPG
olivia and drive 004.jpg
bok-services-europeandistribution.jpg
timthumb.jpg
wbh-removals-whitstable-kent-header.png
noImageAvailable.jpg
rc-storage.jpg
main_area_home.jpg
360europe3.jpg
framework_logo.png
bestremoval_logo.png
manwithavan.gif
s_path
.
…
index_1.jpg
halyle-self-storage-web-page.png
Med%20van.jpg
logo_storagekings.gif
logo_php_freaks.png
logo1.gif
small removals.jpg
pickfords.jpg
360 logo 2011.jpg
companylogo(5).jpg
staffatstorage.jpeg
0638096001204120140l.jpg
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
Penguins.jpg
theremovals-update1-e1342467838697-300x163 (1).png
emotionheader.jpg
about_156145942.jpg
ryewharflogo.jpg
IMAG0151.jpg
Bannerlogo.jpg
logo_space_maker.jpg
burg.jpg
a_griffin_and_sons.jpg
krgavinpic 008.jpg
planet earth.jpg
smlogo.jpg
homepic2.jpg
banner.png
wpe76dbf3e_06.png
logo_equus.png
pic_0019.jpg
scan0001.jpg
burg.jpeg
mail.jpg
home_moving_house.png
360transportheader2012.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
020.JPG
titlenavbar2_r1_c1.png
logo.png
index_01.jpg
bg-1-273123.jpeg
capital-cargo-couriers-london_r2_c2.gif
bude-self-storage-logo.png
santa’s-arm.png
wpf97a952b_06.png
channelmoving-logo.jpg
blackholestoragelogo.png
logo.gif
Logo.gif
absoluteselfstore.co.uk.jpg
header.jpg
bg-1-25531.jpg
DSCF0216.JPG
360fbcover.jpg
header-martells_logo.jpg
logo_1.jpg
liverpool_removals_service.jpg
logo_liftandshift.png
home.jpg
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
van.png
top_image.jpg
logobournes.jpg
image1.jpg
banner.gif
extraspace.png
banner.jpg
driving_color_0001_logo.png
logo_the_move_team.png
pic_1.jpg
covered_secure_storage.jpg
title.jpg
girl2.jpg
amendheadere.png
logo.jpg
logo.JPG
olivia and drive 004.jpg
bok-services-europeandistribution.jpg
timthumb.jpg
wbh-removals-whitstable-kent-header.png
noImageAvailable.jpg
rc-storage.jpg
main_area_home.jpg
360europe3.jpg
framework_logo.png
bestremoval_logo.png
manwithavan.gif
o_path
.
…
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
home_moving_house.png
absoluteselfstore.co.uk.jpg
olivia and drive 004.jpg
extraspace.png
logo_the_move_team.png
index_1.jpg
bg-1-25531.jpg
theremovals-update1-e1342467838697-300x163 (1).png
360fbcover.jpg
timthumb.jpg
burg.jpg
banner.jpg
amendheadere.png
rc-storage.jpg
360europe3.jpg
logo_1.jpg
krgavinpic 008.jpg
header-martells_logo.jpg
staffatstorage.jpeg
header.jpg
channelmoving-logo.jpg
top_image.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
banner.gif
santa’s-arm.png
image1.jpg
companylogo(5).jpg
about_156145942.jpg
driving_color_0001_logo.png
bg-1-273123.jpeg
small removals.jpg
wpf97a952b_06.png
girl2.jpg
020.JPG
bestremoval_logo.png
DSCF0216.JPG
pic_1.jpg
noImageAvailable.jpg
title.jpg
logo.png
360transportheader2012.jpg
blackholestoragelogo.png
logo_php_freaks.png
logo_storagekings.gif
mail.jpg
bude-self-storage-logo.png
Bannerlogo.jpg
framework_logo.png
main_area_home.jpg
77.jpg
logo.gif
Logo.gif
halyle-self-storage-web-page.png
capital-cargo-couriers-london_r2_c2.gif
homepic2.jpg
planet earth.jpg
titlenavbar2_r1_c1.png
scan0001.jpg
liverpool_removals_service.jpg
pic_0019.jpg
van.png
smlogo.jpg
1.png
logo_space_maker.jpg
logo1.gif
wpe76dbf3e_06.png
manwithavan.gif
index_01.jpg
banner.png
home.jpg
emotionheader.jpg
0638096001204120140l.jpg
covered_secure_storage.jpg
logo_equus.png
burg.jpeg
logo_liftandshift.png
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
a_griffin_and_sons.jpg
servicespg.jpg
ryewharflogo.jpg
Med%20van.jpg
Penguins.jpg
360mainhead.jpg
logobournes.jpg
bok-services-europeandistribution.jpg
360 logo 2011.jpg
pickfords.jpg
logo.jpg
logo.JPG
IMAG0151.jpg
wbh-removals-whitstable-kent-header.png
OK, I see why you received the error.
See if this stops the error:[php]$dirs = array(‘Target’=>dirname($target),‘Thumb’=>$thumbDir,‘s_path’=>$s_path,‘o_path’=>$o_path);[/php]
Try uploading a new file and see if it appears in the output (you don’t need to post the output).
If it does, lets replace the last code section that we inserted with this one:[php]$dirs = array(‘Target’=>dirname($target),‘Thumb’=>$thumbDir,‘s_path’=>$s_path,‘o_path’=>$o_path);
foreach($dirs as $k=>$v){
echo “$k: “.realpath($v).”
”;
}[/php]
Please post the output from this one.
I think the script is working and I believe the above script will be the final piece of the puzzle. (but don’t bet on it…)
It worked using the first code (present in output). Here’s the output of the 2nd code:
Target: /hermes/bosoraweb023/b109/ipg.removalspacecom/images/COMPANIES
Thumb: /hermes/bosoraweb023/b109/ipg.removalspacecom/images/thumbs
s_path: /hermes/bosoraweb023/b109/ipg.removalspacecom/images/thumbs
o_path: /hermes/bosoraweb023/b109/ipg.removalspacecom/images/COMPANIES
Target
.
…
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
home_moving_house.png
absoluteselfstore.co.uk.jpg
olivia and drive 004.jpg
extraspace.png
logo_the_move_team.png
index_1.jpg
bg-1-25531.jpg
theremovals-update1-e1342467838697-300x163 (1).png
360fbcover.jpg
timthumb.jpg
burg.jpg
banner.jpg
amendheadere.png
rc-storage.jpg
360europe3.jpg
logo_1.jpg
krgavinpic 008.jpg
header-martells_logo.jpg
staffatstorage.jpeg
header.jpg
channelmoving-logo.jpg
top_image.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
banner.gif
santa’s-arm.png
image1.jpg
companylogo(5).jpg
about_156145942.jpg
driving_color_0001_logo.png
bg-1-273123.jpeg
small removals.jpg
wpf97a952b_06.png
girl2.jpg
020.JPG
bestremoval_logo.png
DSCF0216.JPG
pic_1.jpg
Unknown-3.jpeg
noImageAvailable.jpg
title.jpg
logo.png
flags.jpg
360transportheader2012.jpg
blackholestoragelogo.png
logo_php_freaks.png
logo_storagekings.gif
mail.jpg
bude-self-storage-logo.png
Bannerlogo.jpg
framework_logo.png
main_area_home.jpg
77.jpg
logo.gif
Logo.gif
halyle-self-storage-web-page.png
capital-cargo-couriers-london_r2_c2.gif
homepic2.jpg
santa’s-arm2.png
planet earth.jpg
titlenavbar2_r1_c1.png
scan0001.jpg
liverpool_removals_service.jpg
pic_0019.jpg
van.png
smlogo.jpg
1.png
logo_space_maker.jpg
logo1.gif
wpe76dbf3e_06.png
manwithavan.gif
index_01.jpg
banner.png
home.jpg
emotionheader.jpg
0638096001204120140l.jpg
covered_secure_storage.jpg
logo_equus.png
burg.jpeg
logo_liftandshift.png
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
a_griffin_and_sons.jpg
servicespg.jpg
ryewharflogo.jpg
Med%20van.jpg
Penguins.jpg
360mainhead.jpg
logobournes.jpg
bok-services-europeandistribution.jpg
360 logo 2011.jpg
pickfords.jpg
logo.jpg
logo.JPG
IMAG0151.jpg
wbh-removals-whitstable-kent-header.png
Thumb
.
…
index_1.jpg
halyle-self-storage-web-page.png
Med%20van.jpg
logo_storagekings.gif
logo_php_freaks.png
logo1.gif
small removals.jpg
pickfords.jpg
360 logo 2011.jpg
companylogo(5).jpg
staffatstorage.jpeg
0638096001204120140l.jpg
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
Penguins.jpg
theremovals-update1-e1342467838697-300x163 (1).png
emotionheader.jpg
about_156145942.jpg
ryewharflogo.jpg
IMAG0151.jpg
Bannerlogo.jpg
logo_space_maker.jpg
burg.jpg
a_griffin_and_sons.jpg
krgavinpic 008.jpg
planet earth.jpg
smlogo.jpg
homepic2.jpg
banner.png
wpe76dbf3e_06.png
logo_equus.png
pic_0019.jpg
scan0001.jpg
burg.jpeg
mail.jpg
home_moving_house.png
360transportheader2012.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
020.JPG
titlenavbar2_r1_c1.png
logo.png
index_01.jpg
bg-1-273123.jpeg
capital-cargo-couriers-london_r2_c2.gif
bude-self-storage-logo.png
santa’s-arm.png
wpf97a952b_06.png
channelmoving-logo.jpg
blackholestoragelogo.png
logo.gif
Logo.gif
absoluteselfstore.co.uk.jpg
header.jpg
bg-1-25531.jpg
DSCF0216.JPG
360fbcover.jpg
header-martells_logo.jpg
logo_1.jpg
liverpool_removals_service.jpg
logo_liftandshift.png
home.jpg
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
van.png
top_image.jpg
logobournes.jpg
image1.jpg
banner.gif
extraspace.png
banner.jpg
driving_color_0001_logo.png
logo_the_move_team.png
pic_1.jpg
covered_secure_storage.jpg
title.jpg
girl2.jpg
amendheadere.png
logo.jpg
logo.JPG
olivia and drive 004.jpg
bok-services-europeandistribution.jpg
timthumb.jpg
wbh-removals-whitstable-kent-header.png
noImageAvailable.jpg
rc-storage.jpg
main_area_home.jpg
360europe3.jpg
framework_logo.png
bestremoval_logo.png
manwithavan.gif
s_path
.
…
index_1.jpg
halyle-self-storage-web-page.png
Med%20van.jpg
logo_storagekings.gif
logo_php_freaks.png
logo1.gif
small removals.jpg
pickfords.jpg
360 logo 2011.jpg
companylogo(5).jpg
staffatstorage.jpeg
0638096001204120140l.jpg
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
Penguins.jpg
theremovals-update1-e1342467838697-300x163 (1).png
emotionheader.jpg
about_156145942.jpg
ryewharflogo.jpg
IMAG0151.jpg
Bannerlogo.jpg
logo_space_maker.jpg
burg.jpg
a_griffin_and_sons.jpg
krgavinpic 008.jpg
planet earth.jpg
smlogo.jpg
homepic2.jpg
banner.png
wpe76dbf3e_06.png
logo_equus.png
pic_0019.jpg
scan0001.jpg
burg.jpeg
mail.jpg
home_moving_house.png
360transportheader2012.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
020.JPG
titlenavbar2_r1_c1.png
logo.png
index_01.jpg
bg-1-273123.jpeg
capital-cargo-couriers-london_r2_c2.gif
bude-self-storage-logo.png
santa’s-arm.png
wpf97a952b_06.png
channelmoving-logo.jpg
blackholestoragelogo.png
logo.gif
Logo.gif
absoluteselfstore.co.uk.jpg
header.jpg
bg-1-25531.jpg
DSCF0216.JPG
360fbcover.jpg
header-martells_logo.jpg
logo_1.jpg
liverpool_removals_service.jpg
logo_liftandshift.png
home.jpg
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
van.png
top_image.jpg
logobournes.jpg
image1.jpg
banner.gif
extraspace.png
banner.jpg
driving_color_0001_logo.png
logo_the_move_team.png
pic_1.jpg
covered_secure_storage.jpg
title.jpg
girl2.jpg
amendheadere.png
logo.jpg
logo.JPG
olivia and drive 004.jpg
bok-services-europeandistribution.jpg
timthumb.jpg
wbh-removals-whitstable-kent-header.png
noImageAvailable.jpg
rc-storage.jpg
main_area_home.jpg
360europe3.jpg
framework_logo.png
bestremoval_logo.png
manwithavan.gif
o_path
.
…
427172_337249102979201_199109820126464_858495_1404540411_n.jpg
home_moving_house.png
absoluteselfstore.co.uk.jpg
olivia and drive 004.jpg
extraspace.png
logo_the_move_team.png
index_1.jpg
bg-1-25531.jpg
theremovals-update1-e1342467838697-300x163 (1).png
360fbcover.jpg
timthumb.jpg
burg.jpg
banner.jpg
amendheadere.png
rc-storage.jpg
360europe3.jpg
logo_1.jpg
krgavinpic 008.jpg
header-martells_logo.jpg
staffatstorage.jpeg
header.jpg
channelmoving-logo.jpg
top_image.jpg
the-angelic-process-theangelicprocessep(ep)-20120905053947.jpg
banner.gif
santa’s-arm.png
image1.jpg
companylogo(5).jpg
about_156145942.jpg
driving_color_0001_logo.png
bg-1-273123.jpeg
small removals.jpg
wpf97a952b_06.png
girl2.jpg
020.JPG
bestremoval_logo.png
DSCF0216.JPG
pic_1.jpg
Unknown-3.jpeg
noImageAvailable.jpg
title.jpg
logo.png
flags.jpg
360transportheader2012.jpg
blackholestoragelogo.png
logo_php_freaks.png
logo_storagekings.gif
mail.jpg
bude-self-storage-logo.png
Bannerlogo.jpg
framework_logo.png
main_area_home.jpg
77.jpg
logo.gif
Logo.gif
halyle-self-storage-web-page.png
capital-cargo-couriers-london_r2_c2.gif
homepic2.jpg
santa’s-arm2.png
planet earth.jpg
titlenavbar2_r1_c1.png
scan0001.jpg
liverpool_removals_service.jpg
pic_0019.jpg
van.png
smlogo.jpg
1.png
logo_space_maker.jpg
logo1.gif
wpe76dbf3e_06.png
manwithavan.gif
index_01.jpg
banner.png
home.jpg
emotionheader.jpg
0638096001204120140l.jpg
covered_secure_storage.jpg
logo_equus.png
burg.jpeg
logo_liftandshift.png
Zodiac_Sign_Tattoo___Aquarius_by_MPtribe.jpg
a_griffin_and_sons.jpg
servicespg.jpg
ryewharflogo.jpg
Med%20van.jpg
Penguins.jpg
360mainhead.jpg
logobournes.jpg
bok-services-europeandistribution.jpg
360 logo 2011.jpg
pickfords.jpg
logo.jpg
logo.JPG
IMAG0151.jpg
wbh-removals-whitstable-kent-header.png
OK,
Go ahead and remove the testing code.
Am I correct that your uploaded file is appearing in the output list? If so, it looks like everything is working correctly.
Right, i got rid of the testing code. Added the working code to the html. The file is being uploaded but it doesn’t update and i noticed it changes the profile’s id (in this case before uploading it was 81, after upload it is 0. This is not redirecting to the profile with 81 as an id)?
[code]<?php
include (‘php only scripts/db.php’);
$id = intval($_GET[‘id’]); // guarantee it’s a harmless number value
if (isset($_GET[‘website’]) && $_GET[‘website’]) { // does the GET value exists and has it a value ?
$website = mysql_real_escape_string($_GET[‘website’]); // get its value and escape it
$setArray[] = “website = ‘$website’”; // ok to update this field in the query so store it
}
if (isset($_GET[‘phone’]) && $_GET[‘phone’]) {
$phone = mysql_real_escape_string($_GET[‘phone’]);
$setArray[] = “phone = ‘$phone’”;
}
if (isset($_GET[‘phone2’]) && $_GET[‘phone2’]) {
$phone2 = mysql_real_escape_string($_GET[‘phone2’]);
$setArray[] = “phone2 = ‘$phone2’”;
}
if (isset($_GET[‘premiumuser_description’]) && $_GET[‘premiumuser_description’]) {
$premiumuser_description = mysql_real_escape_string($_GET[‘premiumuser_description’]);
$setArray[] = “premiumuser_description = ‘$premiumuser_description’”;
}
if (isset($_GET[‘username’]) && $_GET[‘username’]) {
$username = mysql_real_escape_string($_GET[‘username’]);
$setArray[] = “username = ‘$username’”;
}
if (isset($_GET[‘password’]) && $_GET[‘password’]) { // These are the same so you’d need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET[‘password1’] for another field in your form
$password= mysql_real_escape_string($_GET[‘password’]); // This is fine if the 2 values above are first compared
$setArray[] = “password = SHA(’$password’)”; // If they are compared and validation checks out then just do the query to update the password here…
}
if (isset($_GET[‘upload’]) && $_GET[‘upload’]) {
$upload = mysql_real_escape_string($_GET[‘upload’]);
$setArray[] = “upload = ‘$upload’”;
}
/* check if form was submitted /
if (isset($_POST[‘submit’])){
$error_message = “”;
/ This is the directory where images will be saved /
$target = “/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/”;
if(!is_dir($target)) echo “1. Directory Doesn’t Exist: $target
”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/ include validation script /
// include (‘php only scripts/validation.php’);
$uploadDir = ‘/home/users/web/b109/ipg.removalspacecom/images/COMPANIES’; / main picture folder /
$max_height = 450; / largest height you allowed; 0 means any /
$max_width = 450; / largest width you allowed; 0 means any /
$max_file = 2000000; / set the max file size in bytes /
$image_overwrite = 1; / 0 means overwite; 1 means new name /
/ add or delete allowed image types /
$allowed_type01 = array(“image/gif”, “image/pjpeg”, “image/jpeg”, “image/png”, “image/x-png”, “image/jpg”);
$do_thumb = 1; / 1 make thumbnails; 0 means do NOT make /
$thumbDir = “/home/users/web/b109/ipg.removalspacecom/images/thumbs”; / thumbnail folder /
if(!is_dir($thumbDir)) echo “2. Directory Doesn’t Exist: $thumbDir
”;
$thumb_prefix = “”; / prefix for thumbnails /
$thumb_width = 90; / max thumb width /
$thumb_height = 70; // max thumb height
//Writes the photo to the server
if(move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $target)) {
/ HERE IS WHERE WE WILL DO THE ACTUAL RESIZING /
/ THESE SIX PARAMETERS MAY BE CHANGED TO SUIT YOUR NEEDS /
$upload = $_FILES[‘upload’][‘name’];
$o_path =“images/COMPANIES/”;
if(!is_dir($o_path)) echo “3. Directory Doesn’t Exist: $o_path
”;
$s_path = “images/thumbs/”;
if(!is_dir($s_path)) echo “4. Directory Doesn’t Exist: $s_path
”;
$file = $upload;
$save = $file;
$t_w = 200;
$t_h = 150;
/ DO NOT CHANGE THIS NEXT LINE */
$dirs = array(‘Target’=>dirname($target),‘Thumb’=>$thumbDir,‘s_path’=>$s_path,‘o_path’=>$o_path);
foreach($dirs as $k=>$v){
echo “$k: “.realpath($v).”
”;
}
foreach($dirs as $k=>$v){
$target = opendir($v);
$dir = array();
while($start=readdir($target)) $dir[] = $start;
closedir($target);
echo "$k
";
foreach($dir as $name) echo "$name
";
echo ‘
’;
}
}else{
//Gives and error if its not
$error_message .= “Sorry, there was a problem uploading your file.”;
if (count($setArray) > 0) // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}}
header(“Location: view01.php?id=” . $id);
exit(0);
?>[/code]
We need to make a slight change to the code (a bracket needs to be moved):[php] $error_message .= “Sorry, there was a problem uploading your file.”;
}}
if (count($setArray) > 0) { // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}
header(“Location: view01.php?id=” . $id); [/php]
I will look back through the posts to see about the id issue. Be back with you shortly…
OK, there is an extra bracket in my previous post, we will need to remove it:[php] $error_message .= “Sorry, there was a problem uploading your file.”;
}
if (count($setArray) > 0) { // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}
header(“Location: view01.php?id=” . $id); [/php]
Lets give this a try. We may still have an $id issue to deal with but lets confirm the update issue is resolved.
I wish I had some way of testing this myself, sorry to keep taking baby steps… We are close!
I have set up a test profile if it helps?
http://www.removalspace.com/login00.php
username: phpfreaks
same password.
Taking out that extra curly bracket gave a parse error:
Parse error: syntax error, unexpected $end in /hermes/bosoraweb023/b109/ipg.removalspacecom/view02.php on line 100
OK, can you post the file as you are currently using it. In the version I am using, that bracket needs to go…
Sorry im not sure what you mean?
Heres the view02.php at the moment:
[code]<?php
include (‘php only scripts/db.php’);
$id = intval($_GET[‘id’]); // guarantee it’s a harmless number value
if (isset($_GET[‘website’]) && $_GET[‘website’]) { // does the GET value exists and has it a value ?
$website = mysql_real_escape_string($_GET[‘website’]); // get its value and escape it
$setArray[] = “website = ‘$website’”; // ok to update this field in the query so store it
}
if (isset($_GET[‘phone’]) && $_GET[‘phone’]) {
$phone = mysql_real_escape_string($_GET[‘phone’]);
$setArray[] = “phone = ‘$phone’”;
}
if (isset($_GET[‘phone2’]) && $_GET[‘phone2’]) {
$phone2 = mysql_real_escape_string($_GET[‘phone2’]);
$setArray[] = “phone2 = ‘$phone2’”;
}
if (isset($_GET[‘premiumuser_description’]) && $_GET[‘premiumuser_description’]) {
$premiumuser_description = mysql_real_escape_string($_GET[‘premiumuser_description’]);
$setArray[] = “premiumuser_description = ‘$premiumuser_description’”;
}
if (isset($_GET[‘username’]) && $_GET[‘username’]) {
$username = mysql_real_escape_string($_GET[‘username’]);
$setArray[] = “username = ‘$username’”;
}
if (isset($_GET[‘password’]) && $_GET[‘password’]) { // These are the same so you’d need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET[‘password1’] for another field in your form
$password= mysql_real_escape_string($_GET[‘password’]); // This is fine if the 2 values above are first compared
$setArray[] = “password = SHA(’$password’)”; // If they are compared and validation checks out then just do the query to update the password here…
}
if (isset($_GET[‘upload’]) && $_GET[‘upload’]) {
$upload = mysql_real_escape_string($_GET[‘upload’]);
$setArray[] = “upload = ‘$upload’”;
}
/* check if form was submitted /
if (isset($_POST[‘submit’])){
$error_message = “”;
/ This is the directory where images will be saved /
$target = “/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/”;
if(!is_dir($target)) echo “1. Directory Doesn’t Exist: $target
”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/ include validation script /
// include (‘php only scripts/validation.php’);
$uploadDir = ‘/home/users/web/b109/ipg.removalspacecom/images/COMPANIES’; / main picture folder /
$max_height = 450; / largest height you allowed; 0 means any /
$max_width = 450; / largest width you allowed; 0 means any /
$max_file = 2000000; / set the max file size in bytes /
$image_overwrite = 1; / 0 means overwite; 1 means new name /
/ add or delete allowed image types /
$allowed_type01 = array(“image/gif”, “image/pjpeg”, “image/jpeg”, “image/png”, “image/x-png”, “image/jpg”);
$do_thumb = 1; / 1 make thumbnails; 0 means do NOT make /
$thumbDir = “/home/users/web/b109/ipg.removalspacecom/images/thumbs”; / thumbnail folder /
if(!is_dir($thumbDir)) echo “2. Directory Doesn’t Exist: $thumbDir
”;
$thumb_prefix = “”; / prefix for thumbnails /
$thumb_width = 90; / max thumb width /
$thumb_height = 70; // max thumb height
//Writes the photo to the server
if(move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $target)) {
/ HERE IS WHERE WE WILL DO THE ACTUAL RESIZING /
/ THESE SIX PARAMETERS MAY BE CHANGED TO SUIT YOUR NEEDS /
$upload = $_FILES[‘upload’][‘name’];
$o_path =“images/COMPANIES/”;
if(!is_dir($o_path)) echo “3. Directory Doesn’t Exist: $o_path
”;
$s_path = “images/thumbs/”;
if(!is_dir($s_path)) echo “4. Directory Doesn’t Exist: $s_path
”;
$file = $upload;
$save = $file;
$t_w = 200;
$t_h = 150;
/ DO NOT CHANGE THIS NEXT LINE */
$dirs = array(‘Target’=>dirname($target),‘Thumb’=>$thumbDir,‘s_path’=>$s_path,‘o_path’=>$o_path);
foreach($dirs as $k=>$v){
echo “$k: “.realpath($v).”
”;
}
foreach($dirs as $k=>$v){
$target = opendir($v);
$dir = array();
while($start=readdir($target)) $dir[] = $start;
closedir($target);
echo "$k
";
foreach($dir as $name) echo "$name
";
echo ‘
’;
}
}else{
//Gives and error if its not
$error_message .= “Sorry, there was a problem uploading your file.”;
}
if (count($setArray) > 0) { // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}
header(“Location: view01.php?id=” . $id);
?>
[/code]
OK, it looks like we needed the bracket to be added near the end. See if this runs:[php]include (‘php only scripts/db.php’);
$id = intval($_GET[‘id’]); // guarantee it’s a harmless number value
if (isset($_GET[‘website’]) && $_GET[‘website’]) { // does the GET value exists and has it a value ?
$website = mysql_real_escape_string($_GET[‘website’]); // get its value and escape it
$setArray[] = “website = ‘$website’”; // ok to update this field in the query so store it
}
if (isset($_GET[‘phone’]) && $_GET[‘phone’]) {
$phone = mysql_real_escape_string($_GET[‘phone’]);
$setArray[] = “phone = ‘$phone’”;
}
if (isset($_GET[‘phone2’]) && $_GET[‘phone2’]) {
$phone2 = mysql_real_escape_string($_GET[‘phone2’]);
$setArray[] = “phone2 = ‘$phone2’”;
}
if (isset($_GET[‘premiumuser_description’]) && $_GET[‘premiumuser_description’]) {
$premiumuser_description = mysql_real_escape_string($_GET[‘premiumuser_description’]);
$setArray[] = “premiumuser_description = ‘$premiumuser_description’”;
}
if (isset($_GET[‘username’]) && $_GET[‘username’]) {
$username = mysql_real_escape_string($_GET[‘username’]);
$setArray[] = “username = ‘$username’”;
}
if (isset($_GET[‘password’]) && $_GET[‘password’]) { // These are the same so you’d need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET[‘password1’] for another field in your form
$password= mysql_real_escape_string($_GET[‘password’]); // This is fine if the 2 values above are first compared
$setArray[] = “password = SHA(’$password’)”; // If they are compared and validation checks out then just do the query to update the password here…
}
if (isset($_GET[‘upload’]) && $_GET[‘upload’]) {
$upload = mysql_real_escape_string($_GET[‘upload’]);
$setArray[] = “upload = ‘$upload’”;
}
/* check if form was submitted /
if (isset($_POST[‘submit’])){
$error_message = “”;
/ This is the directory where images will be saved /
$target = “/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/”;
if(!is_dir($target)) echo “1. Directory Doesn’t Exist: $target
”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/ include validation script /
// include (‘php only scripts/validation.php’);
$uploadDir = ‘/home/users/web/b109/ipg.removalspacecom/images/COMPANIES’; / main picture folder /
$max_height = 450; / largest height you allowed; 0 means any /
$max_width = 450; / largest width you allowed; 0 means any /
$max_file = 2000000; / set the max file size in bytes /
$image_overwrite = 1; / 0 means overwite; 1 means new name /
/ add or delete allowed image types /
$allowed_type01 = array(“image/gif”, “image/pjpeg”, “image/jpeg”, “image/png”, “image/x-png”, “image/jpg”);
$do_thumb = 1; / 1 make thumbnails; 0 means do NOT make /
$thumbDir = “/home/users/web/b109/ipg.removalspacecom/images/thumbs”; / thumbnail folder /
if(!is_dir($thumbDir)) echo “2. Directory Doesn’t Exist: $thumbDir
”;
$thumb_prefix = “”; / prefix for thumbnails /
$thumb_width = 90; / max thumb width /
$thumb_height = 70; // max thumb height
//Writes the photo to the server
if(move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $target)) {
/ HERE IS WHERE WE WILL DO THE ACTUAL RESIZING /
/ THESE SIX PARAMETERS MAY BE CHANGED TO SUIT YOUR NEEDS /
$upload = $_FILES[‘upload’][‘name’];
$o_path =“images/COMPANIES/”;
if(!is_dir($o_path)) echo “3. Directory Doesn’t Exist: $o_path
”;
$s_path = “images/thumbs/”;
if(!is_dir($s_path)) echo “4. Directory Doesn’t Exist: $s_path
”;
$file = $upload;
$save = $file;
$t_w = 200;
$t_h = 150;
/ DO NOT CHANGE THIS NEXT LINE */
$dirs = array(‘Target’=>dirname($target),‘Thumb’=>$thumbDir,‘s_path’=>$s_path,‘o_path’=>$o_path);
foreach($dirs as $k=>$v){
echo “$k: “.realpath($v).”
”;
}
foreach($dirs as $k=>$v){
$target = opendir($v);
$dir = array();
while($start=readdir($target)) $dir[] = $start;
closedir($target);
echo "$k
";
foreach($dir as $name) echo "$name
";
echo ‘
’;
}
}else{
//Gives and error if its not
$error_message .= “Sorry, there was a problem uploading your file.”;
}
if (count($setArray) > 0) { // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}
}
header(“Location: view01.php?id=” . $id); [/php]
It runs but the id issue remains.
Seems it’s not looking for ?id=81 on click. Its going to ?id=0 which doesn’t exist.
So in summary; it doesn’t update the image neither does it refresh to the correct page by passing $id.
OK, in the version you posted, the resize is missing and a lot of the testing code was still there. (It’s impossible to try to keep all of this straight!!!)
Lets give this a try:[php]include (‘php only scripts/db.php’);
$id = intval($_GET[‘id’]); // guarantee it’s a harmless number value
if (isset($_GET[‘website’]) && $_GET[‘website’]) { // does the GET value exists and has it a value ?
$website = mysql_real_escape_string($_GET[‘website’]); // get its value and escape it
$setArray[] = “website = ‘$website’”; // ok to update this field in the query so store it
}
if (isset($_GET[‘phone’]) && $_GET[‘phone’]) {
$phone = mysql_real_escape_string($_GET[‘phone’]);
$setArray[] = “phone = ‘$phone’”;
}
if (isset($_GET[‘phone2’]) && $_GET[‘phone2’]) {
$phone2 = mysql_real_escape_string($_GET[‘phone2’]);
$setArray[] = “phone2 = ‘$phone2’”;
}
if (isset($_GET[‘premiumuser_description’]) && $_GET[‘premiumuser_description’]) {
$premiumuser_description = mysql_real_escape_string($_GET[‘premiumuser_description’]);
$setArray[] = “premiumuser_description = ‘$premiumuser_description’”;
}
if (isset($_GET[‘username’]) && $_GET[‘username’]) {
$username = mysql_real_escape_string($_GET[‘username’]);
$setArray[] = “username = ‘$username’”;
}
if (isset($_GET[‘password’]) && $_GET[‘password’]) { // These are the same so you’d need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET[‘password1’] for another field in your form
$password= mysql_real_escape_string($_GET[‘password’]); // This is fine if the 2 values above are first compared
$setArray[] = “password = SHA(’$password’)”; // If they are compared and validation checks out then just do the query to update the password here…
}
if (isset($_GET[‘upload’]) && $_GET[‘upload’]) {
$upload = mysql_real_escape_string($_GET[‘upload’]);
$setArray[] = “upload = ‘$upload’”;
}
/* check if form was submitted /
if (isset($_POST[‘submit’])){
$error_message = “”;
/ This is the directory where images will be saved /
$target = “/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/”;
if(!is_dir($target)) echo “1. Directory Doesn’t Exist: $target
”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/ include validation script /
// include (‘php only scripts/validation.php’);
$uploadDir = ‘/home/users/web/b109/ipg.removalspacecom/images/COMPANIES’; / main picture folder /
$max_height = 450; / largest height you allowed; 0 means any /
$max_width = 450; / largest width you allowed; 0 means any /
$max_file = 2000000; / set the max file size in bytes /
$image_overwrite = 1; / 0 means overwite; 1 means new name /
/ add or delete allowed image types /
$allowed_type01 = array(“image/gif”, “image/pjpeg”, “image/jpeg”, “image/png”, “image/x-png”, “image/jpg”);
$do_thumb = 1; / 1 make thumbnails; 0 means do NOT make /
$thumbDir = “/home/users/web/b109/ipg.removalspacecom/images/thumbs”; / thumbnail folder /
if(!is_dir($thumbDir)) echo “2. Directory Doesn’t Exist: $thumbDir
”;
$thumb_prefix = “”; / prefix for thumbnails /
$thumb_width = 90; / max thumb width /
$thumb_height = 70; // max thumb height
//Writes the photo to the server
if(move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $target)) {
/ HERE IS WHERE WE WILL DO THE ACTUAL RESIZING /
/ THESE SIX PARAMETERS MAY BE CHANGED TO SUIT YOUR NEEDS /
$upload = $_FILES[‘upload’][‘name’];
$o_path =“images/COMPANIES/”;
if(!is_dir($o_path)) echo “3. Directory Doesn’t Exist: $o_path
”;
$s_path = “images/thumbs/”;
if(!is_dir($s_path)) echo “4. Directory Doesn’t Exist: $s_path
”;
$file = $upload;
$save = $file;
$t_w = 200;
$t_h = 150;
/ DO NOT CHANGE THIS NEXT LINE */
Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path);
}
}else{
//Gives and error if its not
$error_message .= “Sorry, there was a problem uploading your file.”;
}
if (count($setArray) > 0) { // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}
}
header(“Location: view01.php?id=” . $id); [/php]
If it doesn’t work, lets add[php]echo ‘
’;
print_r($_POST);
exit;[/php]
… to the very top (right before the include) and let me know what is showing.
Sorry about this, i know it’s a tough cookie but weve come a long way!
The first test run gave me:
“unexpected ‘}’” on line 107, deleted (give gave no syntax error’s in DW).
Then the 2nd test run gave me:
“call to undefined Resize function” so i defined it with include().
3rd run it refreshed to the profile with the id=0.
So then i added the
echo ‘
’;
print_r($_POST);
exit;code before the include and this is what was displayed in the browser:
Array
(
[id] => 81
[website] =>
[phone] =>
[phone2] =>
[premiumuser_description] =>
[submit] => submit
)
OK, here is the deal…
The id is being sent as a post by the form, but on redirect it is a get.
Lets change the following line…[php]$id = intval($_GET[‘id’]);[/php]
to…
[php]if(isset($_REQUEST[‘id’])) $id = $_REQUEST[‘id’]; // guarantee it’s a harmless number value
else
{
echo ‘You cannot access this page directly…’;
exit;
}[/php]
Woo! hoo! it goes through to the correct profile id number.
Unfortunately the image isn’t being changed.
OK,
You are using $_GET for each of the variables. In this case we can use $_POST, since they won’t be passed through the url. Lets try this:[php]include (‘php only scripts/db.php’);
if(isset($_REQUEST[‘id’])) $id = $_REQUEST[‘id’]; // guarantee it’s a harmless number value
else
{
echo ‘You cannot access this page directly…’;
exit;
}
if (isset($_POST[‘website’]) && !empty($_POST[‘website’])) { // does the GET value exists and has it a value ?
$website = mysql_real_escape_string($_POST[‘website’]); // get its value and escape it
$setArray[] = “website = ‘$website’”; // ok to update this field in the query so store it
}
if (isset($_POST[‘phone’]) && !empty($_POST[‘phone’])) {
$phone = mysql_real_escape_string($_POST[‘phone’]);
$setArray[] = “phone = ‘$phone’”;
}
if (isset($_POST[‘phone2’]) && !empty($_POST[‘phone2’])) {
$phone2 = mysql_real_escape_string($_POST[‘phone2’]);
$setArray[] = “phone2 = ‘$phone2’”;
}
if (isset($_POST[‘premiumuser_description’]) && !empty($_POST[‘premiumuser_description’])) {
$premiumuser_description = mysql_real_escape_string($_POST[‘premiumuser_description’]);
$setArray[] = “premiumuser_description = ‘$premiumuser_description’”;
}
if (isset($_POST[‘username’]) && !empty($_POST[‘username’])) {
$username = mysql_real_escape_string($_POST[‘username’]);
$setArray[] = “username = ‘$username’”;
}
if (isset($_POST[‘password’]) && !empty($_POST[‘password’])) { // These are the same so you’d need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET[‘password1’] for another field in your form
$password= mysql_real_escape_string($_POST[‘password’]); // This is fine if the 2 values above are first compared
$setArray[] = “password = SHA(’$password’)”; // If they are compared and validation checks out then just do the query to update the password here…
}
if (isset($_POST[‘upload’]) && !empty($_POST[‘upload’])) {
$upload = mysql_real_escape_string($_POST[‘upload’]);
$setArray[] = “upload = ‘$upload’”;
}
/* check if form was submitted /
if (isset($_POST[‘submit’])){
$error_message = “”;
/ This is the directory where images will be saved /
$target = “/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/”;
if(!is_dir($target)) echo “1. Directory Doesn’t Exist: $target
”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/ include validation script /
// include (‘php only scripts/validation.php’);
$uploadDir = ‘/home/users/web/b109/ipg.removalspacecom/images/COMPANIES’; / main picture folder /
$max_height = 450; / largest height you allowed; 0 means any /
$max_width = 450; / largest width you allowed; 0 means any /
$max_file = 2000000; / set the max file size in bytes /
$image_overwrite = 1; / 0 means overwite; 1 means new name /
/ add or delete allowed image types /
$allowed_type01 = array(“image/gif”, “image/pjpeg”, “image/jpeg”, “image/png”, “image/x-png”, “image/jpg”);
$do_thumb = 1; / 1 make thumbnails; 0 means do NOT make /
$thumbDir = “/home/users/web/b109/ipg.removalspacecom/images/thumbs”; / thumbnail folder /
if(!is_dir($thumbDir)) echo “2. Directory Doesn’t Exist: $thumbDir
”;
$thumb_prefix = “”; / prefix for thumbnails /
$thumb_width = 90; / max thumb width /
$thumb_height = 70; // max thumb height
//Writes the photo to the server
if(move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $target)) {
/ HERE IS WHERE WE WILL DO THE ACTUAL RESIZING /
/ THESE SIX PARAMETERS MAY BE CHANGED TO SUIT YOUR NEEDS /
$upload = $_FILES[‘upload’][‘name’];
$o_path =“images/COMPANIES/”;
if(!is_dir($o_path)) echo “3. Directory Doesn’t Exist: $o_path
”;
$s_path = “images/thumbs/”;
if(!is_dir($s_path)) echo “4. Directory Doesn’t Exist: $s_path
”;
$file = $upload;
$save = $file;
$t_w = 200;
$t_h = 150;
/ DO NOT CHANGE THIS NEXT LINE */
Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path);
}
}else{
//Gives and error if its not
$error_message .= “Sorry, there was a problem uploading your file.”;
}
if (count($setArray) > 0) { // do we have at least on field to update?
$setstr = join (’, ', $setArray); // form a comma separated string of our updates
$query = “UPDATE companies SET $setstr WHERE id = $id”; // update it
echo $query;
mysql_query($query) or die(mysql_error());
}
}
header(“Location: view01.php?id=” . $id);[/php]
This is the latest testing results, it just shows my coding?:
include (‘php only scripts/db.php’); if(isset($_REQUEST[‘id’])) $id = $_REQUEST[‘id’]; // guarantee it’s a harmless number value else { echo ‘You cannot access this page directly…’; exit; } if (isset($_POST[‘website’]) && !empty($_POST[‘website’])) { // does the GET value exists and has it a value ? $website = mysql_real_escape_string($_POST[‘website’]); // get its value and escape it $setArray[] = “website = ‘$website’”; // ok to update this field in the query so store it } if (isset($_POST[‘phone’]) && !empty($_POST[‘phone’])) { $phone = mysql_real_escape_string($_POST[‘phone’]); $setArray[] = “phone = ‘$phone’”; } if (isset($_POST[‘phone2’]) && !empty($_POST[‘phone2’])) { $phone2 = mysql_real_escape_string($_POST[‘phone2’]); $setArray[] = “phone2 = ‘$phone2’”; } if (isset($_POST[‘premiumuser_description’]) && !empty($_POST[‘premiumuser_description’])) { $premiumuser_description = mysql_real_escape_string($_POST[‘premiumuser_description’]); $setArray[] = “premiumuser_description = ‘$premiumuser_description’”; } if (isset($_POST[‘username’]) && !empty($_POST[‘username’])) { $username = mysql_real_escape_string($_POST[‘username’]); $setArray[] = “username = ‘$username’”; } if (isset($_POST[‘password’]) && !empty($_POST[‘password’])) { // These are the same so you’d need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET[‘password1’] for another field in your form $password= mysql_real_escape_string($_POST[‘password’]); // This is fine if the 2 values above are first compared $setArray[] = “password = SHA(’$password’)”; // If they are compared and validation checks out then just do the query to update the password here… } if (isset($_POST[‘upload’]) && !empty($_POST[‘upload’])) { $upload = mysql_real_escape_string($_POST[‘upload’]); $setArray[] = “upload = ‘$upload’”; } /* check if form was submitted / if (isset($_POST[‘submit’])){ $error_message = “”; / This is the directory where images will be saved / $target = “/home/users/web/b109/ipg.removalspacecom/images/COMPANIES/”; if(!is_dir($target)) echo "1. Directory Doesn’t Exist: $target
"; $target = $target . basename( $_FILES[‘upload’][‘name’]); / include validation script / // include (‘php only scripts/validation.php’); $uploadDir = ‘/home/users/web/b109/ipg.removalspacecom/images/COMPANIES’; / main picture folder / $max_height = 450; / largest height you allowed; 0 means any / $max_width = 450; / largest width you allowed; 0 means any / $max_file = 2000000; / set the max file size in bytes / $image_overwrite = 1; / 0 means overwite; 1 means new name / / add or delete allowed image types / $allowed_type01 = array(“image/gif”, “image/pjpeg”, “image/jpeg”, “image/png”, “image/x-png”, “image/jpg”); $do_thumb = 1; / 1 make thumbnails; 0 means do NOT make / $thumbDir = “/home/users/web/b109/ipg.removalspacecom/images/thumbs”; / thumbnail folder / if(!is_dir($thumbDir)) echo "2. Directory Doesn’t Exist: $thumbDir
"; $thumb_prefix = “”; / prefix for thumbnails / $thumb_width = 90; / max thumb width / $thumb_height = 70; // max thumb height //Writes the photo to the server if(move_uploaded_file($_FILES[‘upload’][‘tmp_name’], $target)) { / HERE IS WHERE WE WILL DO THE ACTUAL RESIZING / / THESE SIX PARAMETERS MAY BE CHANGED TO SUIT YOUR NEEDS / $upload = $_FILES[‘upload’][‘name’]; $o_path =“images/COMPANIES/”; if(!is_dir($o_path)) echo "3. Directory Doesn’t Exist: $o_path
"; $s_path = “images/thumbs/”; if(!is_dir($s_path)) echo "4. Directory Doesn’t Exist: $s_path
"; $file = $upload; $save = $file; $t_w = 200; $t_h = 150; / DO NOT CHANGE THIS NEXT LINE */ Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path); } }else{ //Gives and error if its not $error_message .= “Sorry, there was a problem uploading your file.”; } if (count($setArray) > 0) { // do we have at least on field to update? $setstr = join (’, ', $setArray); // form a comma separated string of our updates $query = “UPDATE companies SET $setstr WHERE id = $id”; // update it echo $query; mysql_query($query) or die(mysql_error()); } } header(“Location: view01.php?id=” . $id);
Looks like it is missing the php start and end tags…
Add <?php to the beginning and ?> to the end. Sorry I left them out.