Jump to content

fezzik

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Everything posted by fezzik

  1. I'm working with a script called Crop Canvas which you can dl at http://php.amnuts.com/. Unfortunately the forums associated with this script are not available due to the creator not having adequate time to respond. I was hoping someone in this community has experience with this script or is knowledgable enough to help with this issue. I've created a simple form that allows users to upload images and save them to the server. Once an image is saved to the server I run the Crop Canvas script to create a 75x75 pixel thumbnail of the image. The lines of code I'm using are as follows:   [code] require('class.cropcanvas.php'); $cc =& new CropCanvas(); if ($cc->loadImage("../uploads/".$rand_name."_t.".$file_ext)) {   $cc->cropToSize('75', '75', ccCENTER);   $cc->saveImage("../uploads/".$rand_name."_sq.".$file_ext);   $cc->flushImages(true); } [/code]llowing url: The above lines check to see if a image exists then run it through the Crop Canvas script. I'm encountering an error when I try to upload images. The error I recieve is: Warning: imagedestroy(): supplied argument is not a valid Image resource in class.cropcanvas.php on line 436 Line 436 is contained in the following function: function flushImages($original = true) {   imagedestroy($this->_imgFinal); // line 436   $this->_imgFinal = null;   if ($original) {     imagedestroy($this->_imgOrig);   $this->_imgOrig = null;   } } I've read the information at http://us3.php.net/imagedestroy but I do not completely understand why I'm encountering this error. The error seems to be associated with specific images I'm tring to upload. Any help is much appreciated. If you need additional information please ask. Best, Fezzik
  2. Death to syntax! Thanks again for posting gmwebs. You motivated me to take another look at CropCanvas. I noticed that I was using incorrect syntax and have corrected the issue. Everything is functioning correctly now. Cheers, Fezzik
  3. Thanks for responding! I have actually been working with the CropCanvas class found at that site. Unfortunately I haven't been able to get the saveImage() or saveFinal() function to work correctly. Both functions are not saving as intended. I noticed other posts on the site's forum about the issue but didn't notice a fix. I should make a post in the site forum about the issue and see if I get a response. Thanks again!
  4. Jamie, Here is some code that I use for a photogallery site: [code] //--------------- end: config.php -------------------- //path where to store images $path_img = "../uploads/"; $extlimit = "yes"; //Do you want to limit the extensions of files uploaded (yes/no) //allowed Extensions $limitedext = array(".gif",".jpg",".png",".jpeg",".bmp"); //check if folders are Writable or not //please CHOMD them 777 if (!is_writeable($path_img)){     die ("Error: The directory <b>($path_img)</b> is NOT writable"); } // --------------- end: config.php -------------------- if ( $_SERVER['REQUEST_METHOD'] == "POST" ) {   // get the post variables   foreach( $_POST as $key=>$value ) {     if ( $value ) {       $$key=htmlentities( trim($value), ENT_QUOTES );     } else {       $$key="";     } //end else loop   } //end foreach loop     $file_type = $_FILES['imgfile']['type'];   $file_name = $_FILES['imgfile']['name'];   $file_size = $_FILES['imgfile']['size'];   $file_tmp = $_FILES['imgfile']['tmp_name'];   //check if you have selected a file.   if(!is_uploaded_file($file_tmp)){     echo "Error: Please select a file to upload!.";     exit(); //exit the script and don't do anything else.   }     //check file extension   $ext = strrchr($file_name,'.');   $ext = strtolower($ext);   if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {     echo "Wrong file extension.";     exit();   }   //get the file extension.   $getExt = explode ('.', $file_name);   $file_ext = $getExt[count($getExt)-1];   //create a random file name   $rand_name = md5(time());   $rand_name= rand(0,999999999)."_".rand(0,999999999);   //upload the image   move_uploaded_file ($file_tmp, "$path_img/$rand_name.$file_ext"); } //end POST loop [/code] At a quick glance it looks like you haven't included a way to copy the file to a directory in your script. I think the following lines might help: //save the image to a writable directory imagejpeg($image_resized,"$path_img/$rand_name.$file_ext"); Here is the link for more information on imagejpeg: http://us3.php.net/imagejpeg Let me know if any of this helps. Cheers, Fezzik
  5. Anyone have a link or an example of a decent code to crop images? I'm looking for a script that will crop an image if the origin is set as the center of the image. Cheers, Fezzik
  6. The ampersand means that the value of the variable is being assigned by reference. I use the same CC function you posted. I also had the same question when I stumbled across the ampersand. Below is the link to my previous post which explains the "assign by reference" and how to use it with this function. In addition, I also posted the link to the php manual that explains variables. my previous post - http://www.phpfreaks.com/forums/index.php/topic,110130.0.html php manual - http://us3.php.net/language.variables Best, Fezzik
  7. You might be experiencing an error with your delete query thus the web announcement is not deleted. You can check to see if there is an error by using mysql_errno(). Your current code will print "The announcement has successfully been removed." for every instance because you do not check for errors. Adding a conditional statement to your code will help in identifying possible issues. $sql = "DELETE FROM web_announcements WHERE id=$id"; $result = mysql_query($sql); // any errors? if ( mysql_errno() ) { echo "There was an error deleting the record from the database"; } else { echo "The announcement has successfully been removed."; } Hope this helps.Cheers!
  8. Hey James! I new to PHP but I think this will do the trick. If I'm incorrect I'm sure there are people in this community that can help. if(file_exists("INCLUDE_HERE")) {   echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0"\><tr><td>";   include ("INCLUDE_HERE");   echo "</td></tr></table>"; } Cheers!
  9. Why can't you use long strings? Try using urlencode() to pass variables to the next page. Here is the PHP manual link for urlencode(): http://us3.php.net/urlencode Cheers!
  10. Some of you might be familiar with web sites that sell cell phones and SIM cards. Usually on these sites there is an option to "reload" your SIM card. I'm trying to create a form that has the same functionality as most reload forms. Basically the form has an option to update quanity and another field that allows you to input your telephone number so they can reload the SIM card. So the form should look similar to: <table>   <form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST">   <tr>     <td colspan="3">Reload Telephone#: <input name="reloadNumber" id="reloadNumber" type="text">   </tr> <input type="hidden" name="product_Reload" value="Reload"> <input type="hidden" name="cost_Reload" value="80.00">   <tr>     <td>Quanity:</td>     <td><input name="qty_Reload" type="text" value="1"></td>     <td><input name="submit" type="submit" value="Add to Basket"></td>   </tr>   </form> </table> Once the form is submitted the data from the form is stored in session variables. Currently I'm able to correctly store this data in the session variables I assign except for the "reload telephone number". The session variable that stores the "reload telephone number" changes value with every form submission. So, the previous stored number is replaced by the new one. I think I need to create an array to hold multiple "reload telephone numbers" associated with this "reload product." How can I use an array and the form above to accomplish this? I'm looking at this from the perspective that a user might want to purchase multiple reloads for multiple numbers. I might be incorrect in my assumption of using an array to acheive this functionality so any advice to alternative methods is much appreciated. If you need additional information please ask. Cheers, Fezzik
  11. In case if anyone was interested I finally figured this out. The function assigns &$errornumber and &$errortext by reference: function checkCreditCard ($cardnumber, $cardname, &$errornumber, &$errortext) {} The below validation is found in the function. It checks to see if the string is null: // Ensure that the user has provided a credit card number   if (strlen($cardnumber) == 0)  {     $errornumber = 1;        $errortext = $ccErrors [$errornumber];     return false;   } So, when we call the function: if (checkCreditCard ($customer_CardNumber, $_SESSION['customer_paymentMethod'], $ccerror, $ccerrortext)) {   $ccerrortext = 'This card has a valid format'; } If the string, $customer_CardNumber, is null the function assigns a value to $errornumber and $errortext and returns false. Since both $errornumber and $errortext are assigned by reference it replaces the value of  $ccerrortext in the call script. You can then print $ccerrortext.
  12. Thanks for responding Crayon! Yes, I'm 100% sure that it is not assigning $errortext to $ccString. I do print $ccString. I have another similiar function which I use the same method and it works but unfortunately with this function it does not. I appreciate any help or feedback.
  13. I gave this method a try and found that I'm not able to recieve the value of this variable. I'm sure my scripting is wrong but here is the delaration I tried to recieve the value: $ccString = checkCreditCard ($customer_CardNumber, $_SESSION['customer_paymentMethod'], $ccerror, $ccerrortext); When I pass an invalid CC number thru the function it recognizes it as invalid but does not assign a value to $ccString. Is the method I use to recieve this value incorrect? If so, can you please show me an example of how to assign the value of $errortext to a variable outside the function. Thanks, Fezzik
  14. Thanks for the response. If I wanted to pass $errortext to the page would this be the correct method: if (strlen($cardnumber) == 0)  {   $errornumber = 1;      $errortext = $ccErrors [$errornumber];   return ($errortext);   } } Cheers, Fezzik
  15. I'm new to PHP. I'm currenty exploring the use of functions. I found a function that validates credit card numbers and was wondering if I could get some help with how to return variables from the function. Here is the function and code I use: function checkCreditCard ($cardnumber, $cardname, &$errornumber, &$errortext) { // validate the cardnumber, cardname... // if the card does not pass validation return false. // the following is an example of a if statement that checks string length $ccErrors [1] = "No card number provided"; if (strlen($cardnumber) == 0)  {   $errornumber = 1;      $errortext = $ccErrors [$errornumber];   return false;   } } if ( !empty( $customer_CardNumber ) ) {   if (checkCreditCard ($customer_CardNumber, $_SESSION['customer_paymentMethod'], $ccerror, $ccerrortext)) {     $ccerrortext = 'This card has a valid format';   } else {     // display $errortext and $errornumber     }   } I noticed that the variables &$errornumber and &$errortext contain a "&" which I have not seen before. From reading a little it looks like this variable is assigned by reference. I'm not sure that this affects what I would like to accomplish but I would like to pass the variables $errornumber and $errortext back to the page. Any suggestions on how to do this? I believe the script should appear where I have "// display $errortext and $errornumber" Any help is much appreciated. Best, Fezzik
  16. I think I wasn't specific enough but I might be still somewhat asleep. If the user is logged in and their session is created. Then they are inactive for the value defined in session.gc_maxlifetime. Instead of ending the session and having the user renew their session by logging in again, is it possible to create a method that prompts the user to either continue the session or close it using a popup window when session.gc_maxlifetime is reached. The session would never actually close until the user selects either close session from this new window or uses a logout method on the site. Best, Fezzik
  17. Hello everyone! Welcome to my 1st post. I'm looking for help with the following: I would like to create a SESSION end notification for users. Is it possible to create a notification that informs users that their SESSION has expired and give them the option to continue the SESSION or close the SESSION? Any help is much appreciated. If you have any additional questions please ask. Best, Fezzik
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.