Help needed with the image update on form.

Sorry for the delay.

There is a lot going on in the original script and I wanted to trouble shoot it on my testing server. I’ll hopefully have something for you shortly.

OK,

I have temporarily modified view01.php for troubleshooting. Lets try testing it with this one:[php]<?PHP
ini_set(‘display_errors’,1);
error_reporting(E_ALL);

session_start();
/*
if(!isset($_SESSION[‘id’]) || !isset($_SESSION[‘valid_user’]) || $_SESSION[‘valid_user’] != “yes”) {
$_SESSION = array();
session_destroy();
header(“Location: index.php”);
exit();
}

//include (‘php only scripts/db.php’);
$id = $_GET[‘id’];

$query =“SELECT * FROM companies WHERE id = ‘$id’”;
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
*/
?>

Removalspace.com
Logo here
imagesenter your postcode hereimages

 

 

e.g first two letters and number: i.e: AA1 or AA12

Become a fanFollows on TwitterLinked inContact

Search Removals |

Search Storage |

Add Listing |

About |

Contact |

Login

  </tr>
    <tr>
     <td><div class="abox">
  <figure>
  <fcapion>
  <h2>
    <h1>Company Location:</h1>
    <h1><?PHP
        echo $row['street1'] .
        "<br>" . $row['street2'] .
        "<br>" . $row['city'] . "," .  $row['postcode'] ;
        ?>
  </h1></h2>
  <h1></img></h1>
  </fcaption></figure>

Your Logo:

logo

Contact Details:

<?PHP echo "phone: " . $row['phone'] . "
email: " . $row['email'] . "
website: " . $row['website'] ; ?>

<?PHP /* create an email validation function */ function validateEmailAddress($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email); } /** * CALLBACK - determine if the provided postcode is valid. * * @param string $postcode * @return bool TRUE if valid, FALSE otherwise * @author George Edwards */ function is_valid_uk_postcode($postcode) { $pattern = "/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/";
if (preg_match($pattern, $postcode)) {
    return TRUE;
}

$this->validation->set_message('is_valid_uk_postcode', 'That is not a valid %s.');
return FALSE;

}
/* FUNCTION TO CREATE SALT /
function createSalt() {
$string = md5(uniqid(rand(), true));
return substr($string, 0, 3);
}
/
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/”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/
include validation script /
include (‘php only scripts/validation.php’);
$uploadDir = ‘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 = “/images/thumbs”; /
thumbnail folder /
$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/”;
$s_path = “images/thumbs/”;
$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.”;
}
/
PREPARE DATA FOR INSERTION INTO TABLE */
//Writes the information to the database
if(strlen(trim($error_message)) <1){
$salt = createsalt();
$username = trim($_POST[‘username’]);
$password = trim($_POST[‘password’]);
$hash = hash(‘sha256’, $salt, $password);
$approved = 0;
$company_name = mysql_real_escape_string(trim($_POST[‘company_name’]));
$website = mysql_real_escape_string(trim($_POST[‘website’]));
$contact_name = mysql_real_escape_string(trim($_POST[‘contact_name’]));
$location = mysql_real_escape_string(trim($_POST[‘location’]));
$postcode = mysql_real_escape_string(trim($_POST[‘postcode’]));
$street1 = mysql_real_escape_string(trim($_POST[‘street1’]));
$street2 = mysql_real_escape_string(trim($_POST[‘street2’]));
$city = mysql_real_escape_string(trim($_POST[‘city’]));
$phone = mysql_real_escape_string(trim($_POST[‘phone’]));
$phone2 = mysql_real_escape_string(trim($_POST[‘phone2’]));
$email = mysql_real_escape_string(trim($_POST[‘email’]));
$premiumuser_description = mysql_real_escape_string(trim($_POST[‘premiumuser_description’]));
$salt = mysql_real_escape_string($salt);
$upload = mysql_real_escape_string($upload);
$query =“INSERT INTO companies (company_name, what_services, website, contact_name, location, postcode, street1, street2, city, phone,phone2, email, premiumuser_description, username, password, salt, approved, upload) VALUES (’$company_name’, ‘$what_services’, ‘$website’, ‘$contact_name’, ‘$location’, ‘$postcode’, ‘$street1’, ‘$street2’, ‘$city’, ‘$phone’, ‘$phone2’, ‘$email’, ‘$premiumuser_description’, ‘$username’, ‘$hash’, ‘$salt’, ‘$approved’, ‘$upload’)”;
$result = mysql_query($query) or die(mysql_error());
if ($result) {

     }
  
  /* at this point we can send an email to the admin as well as the user.  DO NOT send the user's password to ANYONE!!!! */

}
}//if (isset($_POST[‘submit’]))
?>

<?php if (!empty($error_message)){ echo $error_message; } ?>


Edit Your details

fill out the form with your details...

 

 

Click submit to update...

 

 

 

 

Website:

 

 

Primary Number:

 

 

Secondary Number:

 

 

Company Description:

Write a description of what your company does, the services it offers and any additional information here.

 

Images:

Upload your company image here.

 

 

[/php]

It will really mess up the look of the page, but I want to see if the form posts without the commented out elements (it does for me).

Hi. Thanks for getting back to me with this.

The form returns a white page with this output on:

Array
(
[id] =>

Notice: Undefined variable: row in /hermes/bosoraweb023/b109/ipg.removalspacecom/view01.php on line 273

[website] => 
[phone] => 
[phone2] => 
[premiumuser_description] => 
[submit] => submit

)
Array
(
[upload] => Array
(
[name] => van.gif
[type] => image/gif
[tmp_name] => /tmp/phpHQZCnH
[error] => 0
[size] => 35793
)

)

OK,

We are making progress! I am assuming you didn’t type anything into the boxes for website, etc. If you did, make sure to let me know.

Lets see what we get when we do this:[php]<?PHP
ini_set(‘display_errors’,1);
error_reporting(E_ALL);

session_start();

if(!isset($_SESSION[‘id’]) || !isset($_SESSION[‘valid_user’]) || $_SESSION[‘valid_user’] != “yes”) {
$_SESSION = array();
session_destroy();
header(“Location: index.php”);
exit();
}

include (‘php only scripts/db.php’);
$id = $_GET[‘id’];

$query =“SELECT * FROM companies WHERE id = ‘$id’”;
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
?>

Removalspace.com
Logo here
imagesenter your postcode hereimages

 

 

e.g first two letters and number: i.e: AA1 or AA12

Become a fanFollows on TwitterLinked inContact

Search Removals |

Search Storage |

Add Listing |

About |

Contact |

Login

  </tr>
    <tr>
     <td><div class="abox">
  <figure>
  <fcapion>
  <h2>
    <h1>Company Location:</h1>
    <h1><?PHP
        echo $row['street1'] .
        "<br>" . $row['street2'] .
        "<br>" . $row['city'] . "," .  $row['postcode'] ;
        ?>
  </h1></h2>
  <h1></img></h1>
  </fcaption></figure>

Your Logo:

logo

Contact Details:

<?PHP echo "phone: " . $row['phone'] . "
email: " . $row['email'] . "
website: " . $row['website'] ; ?>

<?PHP /* create an email validation function */ function validateEmailAddress($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email); } /** * CALLBACK - determine if the provided postcode is valid. * * @param string $postcode * @return bool TRUE if valid, FALSE otherwise * @author George Edwards */ function is_valid_uk_postcode($postcode) { $pattern = "/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/";
if (preg_match($pattern, $postcode)) {
    return TRUE;
}

$this->validation->set_message('is_valid_uk_postcode', 'That is not a valid %s.');
return FALSE;

}
/* FUNCTION TO CREATE SALT /
function createSalt() {
$string = md5(uniqid(rand(), true));
return substr($string, 0, 3);
}
/
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/”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/
include validation script /
include (‘php only scripts/validation.php’);
$uploadDir = ‘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 = “/images/thumbs”; /
thumbnail folder /
$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/”;
$s_path = “images/thumbs/”;
$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.”;
}
/
PREPARE DATA FOR INSERTION INTO TABLE */
//Writes the information to the database
if(strlen(trim($error_message)) <1){
$salt = createsalt();
$username = trim($_POST[‘username’]);
$password = trim($_POST[‘password’]);
$hash = hash(‘sha256’, $salt, $password);
$approved = 0;
$company_name = mysql_real_escape_string(trim($_POST[‘company_name’]));
$website = mysql_real_escape_string(trim($_POST[‘website’]));
$contact_name = mysql_real_escape_string(trim($_POST[‘contact_name’]));
$location = mysql_real_escape_string(trim($_POST[‘location’]));
$postcode = mysql_real_escape_string(trim($_POST[‘postcode’]));
$street1 = mysql_real_escape_string(trim($_POST[‘street1’]));
$street2 = mysql_real_escape_string(trim($_POST[‘street2’]));
$city = mysql_real_escape_string(trim($_POST[‘city’]));
$phone = mysql_real_escape_string(trim($_POST[‘phone’]));
$phone2 = mysql_real_escape_string(trim($_POST[‘phone2’]));
$email = mysql_real_escape_string(trim($_POST[‘email’]));
$premiumuser_description = mysql_real_escape_string(trim($_POST[‘premiumuser_description’]));
$salt = mysql_real_escape_string($salt);
$upload = mysql_real_escape_string($upload);
$query =“INSERT INTO companies (company_name, what_services, website, contact_name, location, postcode, street1, street2, city, phone,phone2, email, premiumuser_description, username, password, salt, approved, upload) VALUES (’$company_name’, ‘$what_services’, ‘$website’, ‘$contact_name’, ‘$location’, ‘$postcode’, ‘$street1’, ‘$street2’, ‘$city’, ‘$phone’, ‘$phone2’, ‘$email’, ‘$premiumuser_description’, ‘$username’, ‘$hash’, ‘$salt’, ‘$approved’, ‘$upload’)”;
$result = mysql_query($query) or die(mysql_error());
if ($result) {

     }
  
  /* at this point we can send an email to the admin as well as the user.  DO NOT send the user's password to ANYONE!!!! */

}
}//if (isset($_POST[‘submit’]))
?>

<?php if (!empty($error_message)){ echo $error_message; } ?>


Edit Your details

fill out the form with your details...

 

 

Click submit to update...

 

 

 

 

Website:

 

 

Primary Number:

 

 

Secondary Number:

 

 

Company Description:

Write a description of what your company does, the services it offers and any additional information here.

 

Images:

Upload your company image here.

 

 

[/php]

Sorry to keep doing this - we should be close…

No i didnt type anything into the text fields of my form.

Only chose an image (so it could update)

Here’s what i see when i click submit:

Array
(
[id] =>

Notice: Undefined variable: row in /hermes/bosoraweb023/b109/ipg.removalspacecom/view01.php on line 273

[website] => 
[phone] => 
[phone2] => 
[premiumuser_description] => 
[submit] => submit

)
Array
(
[upload] => Array
(
[name] => santa’s-arm2.png
[type] => image/png
[tmp_name] => /tmp/phpspCPIl
[error] => 0
[size] => 54691
)

)

Excellent!

Now we need to resolve the undefined variable issue…

Lets replace view01.php with this[php]<?PHP
ini_set(‘display_errors’,1);
error_reporting(E_ALL);

session_start();

if(!isset($_SESSION[‘id’]) || !isset($_SESSION[‘valid_user’]) || $_SESSION[‘valid_user’] != “yes”) {
$_SESSION = array();
session_destroy();
header(“Location: index.php”);
exit();
}

include (‘php only scripts/db.php’);
$id = $_GET[‘id’];

$query =“SELECT * FROM companies WHERE id = ‘$id’”;
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result);
echo $query;
echo ‘

’;
print_r($row);
?>[/php]

This should show us the query and the contents of the $row array.

Clever stuff. Im glad the hashed salted password doesn’t show lol. Here’s whats displayed now::

SELECT * FROM companies WHERE id = ‘81’
Array
(
[0] => 81
[id] => 81
[1] => 360 Transport Solutions Ltd
[company_name] => 360 Transport Solutions Ltd
[2] => R
[what_services] => R
[3] => www.360transport.co.uk
[website] => www.360transport.co.uk
[4] => Richard Burgwin
[contact_name] => Richard Burgwin
[5] => West Midlands,
[location] => West Midlands,
[6] => WS12 1BN
[postcode] => WS12 1BN
[7] =>
[basicpackage_description] =>
[8] => The careful movers throughout the UK and Europe… We do house removals and office moves
[premiumuser_description] => The careful movers throughout the UK and Europe… We do house removals and office moves
[9] => trailer.png
[upload] => trailer.png
[10] => 28 Wood Lane,
[street1] => 28 Wood Lane,
[11] => Hednesford,
[street2] => Hednesford,
[12] => Birmingham,
[city] => Birmingham,
[13] => 07535069990
[phone] => 07535069990
[14] => optional
[phone2] => optional
[15] => 360trans
[username] => 360trans
[16] =>
wR—à±ÉnkH4çM’.dÐ7QøO^ì—!®ç¾DY
[password] =>
wR—à±ÉnkH4çM’.dÐ7QøO^ì—!®ç¾DY
[17] => ca4
[salt] => ca4
[18] => [email protected]
[email] => [email protected]
[19] => 3
[approved] => 3
)

OK, lets make the following change…[php]$row = mysql_fetch_assoc($result);[/php]

I agree about the password! I didn’t expect that to be in the results, sorry.

latest results of debugging:

SELECT * FROM companies WHERE id = ‘81’
Array
(
[id] => 81
[company_name] => 360 Transport Solutions Ltd
[what_services] => R
[website] => www.360transport.co.uk
[contact_name] => Richard Burgwin
[location] => West Midlands,
[postcode] => WS12 1BN
[basicpackage_description] =>
[premiumuser_description] => The careful movers throughout the UK and Europe… We do house removals and office moves
[upload] => trailer.png
[street1] => 28 Wood Lane,
[street2] => Hednesford,
[city] => Birmingham,
[phone] => 07535069990
[phone2] => optional
[username] => 360trans
[password] =>
wR—à±ÉnkH4çM’.dÐ7QøO^ì—!®ç¾DY
[salt] => ca4
[email] => [email protected]
[approved] => 3
)

That looks a lot better!

Lets go ahead and try it out with these:[php]<?PHP
ini_set(‘display_errors’,1);
error_reporting(E_ALL);

session_start();

if(!isset($_SESSION[‘id’]) || !isset($_SESSION[‘valid_user’]) || $_SESSION[‘valid_user’] != “yes”) {
$_SESSION = array();
session_destroy();
header(“Location: index.php”);
exit();
}

include (‘php only scripts/db.php’);
$id = $_GET[‘id’];

$query =“SELECT * FROM companies WHERE id = ‘$id’”;
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
?>

Removalspace.com
Logo here
imagesenter your postcode hereimages

 

 

e.g first two letters and number: i.e: AA1 or AA12

Become a fanFollows on TwitterLinked inContact

Search Removals |

Search Storage |

Add Listing |

About |

Contact |

Login

  </tr>
    <tr>
     <td><div class="abox">
  <figure>
  <fcapion>
  <h2>
    <h1>Company Location:</h1>
    <h1><?PHP
        echo $row['street1'] .
        "<br>" . $row['street2'] .
        "<br>" . $row['city'] . "," .  $row['postcode'] ;
        ?>
  </h1></h2>
  <h1></img></h1>
  </fcaption></figure>

Your Logo:

logo

Contact Details:

<?PHP echo "phone: " . $row['phone'] . "
email: " . $row['email'] . "
website: " . $row['website'] ; ?>

<?PHP /* create an email validation function */ function validateEmailAddress($email) { return filter_var($email, FILTER_VALIDATE_EMAIL) && preg_match('/@.+\./', $email); } /** * CALLBACK - determine if the provided postcode is valid. * * @param string $postcode * @return bool TRUE if valid, FALSE otherwise * @author George Edwards */ function is_valid_uk_postcode($postcode) { $pattern = "/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? {1,2}[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/";
if (preg_match($pattern, $postcode)) {
    return TRUE;
}

$this->validation->set_message('is_valid_uk_postcode', 'That is not a valid %s.');
return FALSE;

}
/* FUNCTION TO CREATE SALT /
function createSalt() {
$string = md5(uniqid(rand(), true));
return substr($string, 0, 3);
}
/
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/”;
$target = $target . basename( $_FILES[‘upload’][‘name’]);
/
include validation script /
include (‘php only scripts/validation.php’);
$uploadDir = ‘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 = “/images/thumbs”; /
thumbnail folder /
$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/”;
$s_path = “images/thumbs/”;
$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.”;
}
/
PREPARE DATA FOR INSERTION INTO TABLE */
//Writes the information to the database
if(strlen(trim($error_message)) <1){
$salt = createsalt();
$username = trim($_POST[‘username’]);
$password = trim($_POST[‘password’]);
$hash = hash(‘sha256’, $salt, $password);
$approved = 0;
$company_name = mysql_real_escape_string(trim($_POST[‘company_name’]));
$website = mysql_real_escape_string(trim($_POST[‘website’]));
$contact_name = mysql_real_escape_string(trim($_POST[‘contact_name’]));
$location = mysql_real_escape_string(trim($_POST[‘location’]));
$postcode = mysql_real_escape_string(trim($_POST[‘postcode’]));
$street1 = mysql_real_escape_string(trim($_POST[‘street1’]));
$street2 = mysql_real_escape_string(trim($_POST[‘street2’]));
$city = mysql_real_escape_string(trim($_POST[‘city’]));
$phone = mysql_real_escape_string(trim($_POST[‘phone’]));
$phone2 = mysql_real_escape_string(trim($_POST[‘phone2’]));
$email = mysql_real_escape_string(trim($_POST[‘email’]));
$premiumuser_description = mysql_real_escape_string(trim($_POST[‘premiumuser_description’]));
$salt = mysql_real_escape_string($salt);
$upload = mysql_real_escape_string($upload);
$query =“INSERT INTO companies (company_name, what_services, website, contact_name, location, postcode, street1, street2, city, phone,phone2, email, premiumuser_description, username, password, salt, approved, upload) VALUES (’$company_name’, ‘$what_services’, ‘$website’, ‘$contact_name’, ‘$location’, ‘$postcode’, ‘$street1’, ‘$street2’, ‘$city’, ‘$phone’, ‘$phone2’, ‘$email’, ‘$premiumuser_description’, ‘$username’, ‘$hash’, ‘$salt’, ‘$approved’, ‘$upload’)”;
$result = mysql_query($query) or die(mysql_error());
if ($result) {

     }
  
  /* at this point we can send an email to the admin as well as the user.  DO NOT send the user's password to ANYONE!!!! */

}
}//if (isset($_POST[‘submit’]))
?>

<?php if (!empty($error_message)){ echo $error_message; } ?>


Edit Your details

fill out the form with your details...

 

 

Click submit to update...

 

 

 

 

Website:

 

 

Primary Number:

 

 

Secondary Number:

 

 

Company Description:

Write a description of what your company does, the services it offers and any additional information here.

 

Images:

Upload your company image here.

 

 

[/php]

And[php]<?php
/* 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.”;
}}
exit(0);
?>[/php]

Just a 0 is displayed.

“0”

OK,

I just noticed that your form uses “submit,” but we are checking for “Submit”

Lets use this: [php]if (isset($_POST[‘submit’])){[/php]

Sorry to keep making little changes. I can’t test this so I am going off trying to read the code visually and it’s easy to miss little details…

Thats okay i should have changed that silly “S” on submit before, my fault… Anyway running that code gave this error:

Fatal error: Call to undefined function Resize_Image() in /hermes/bosoraweb023/b109/ipg.removalspacecom/view02.php on line 40

I added this line directly after the php tag like this:

<?php include('php only scripts/resize.php');

and running that gave me this error:

0

OK,

The 0 is coming from a line that we should remove:[php]exit(0);[/php]It is at the end of the script.

Can you check and see if it working now by looking for the resized image in the proper directory.

If it isn’t, find: Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path);
And add the following line just above it:[php]echo ‘WE GOT HERE!’;[/php]

Thanks, I got rid of the 0 after exit.

Tested = 0.

I added “we got here” after Resize_image and in the browser was:

WE GOT HERE!

Did you check in the folder to see if the image is getting there?

If it isn’t, there are two things left:

First, we replace the “WE GOT HERE!” line with the following:[php]echo “save = $save
file = $file
t_w = $t_w
t_h = $t_h
s_path = $s_path
o_path = $o_path
”;[/php]

Based on the output of that, we may need to look at the resize function.

save = 360europe3.jpg
file = 360europe3.jpg
t_w = 200
t_h = 150
s_path = images/thumbs/
o_path = images/COMPANIES/

thats what is outputted changing the WE GOT HERE to suggested.

The image isn’t being moved to any folders.

We are so close! Everything looks right…

Can you confirm for me that in the same directory as your view02.php file, you have a directory (or folder) named “images” (all lower case) and that inside that directory you have a directory named “thumbs” and one named “COMPANIES”

Yes the full structure is this:

site (root) > images (folder)> inside images folder i have:

COMPANIES

thumbs

images <<<< sorry to be confusing but this folder exists and was part of a test. it actually has nothing in it/just and empty folder.

This is really driving me crazy. The fact that we are getting this output means that the script believes everything is working.

Lets try a different check. Lets replace the last line that we added with this:[php]$dirs = array(‘Target’=>$target,‘Thumb’=>$thumbDir,‘s_path’=>$s_path,‘o_path’=>$o_path);
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 ‘



’;
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service