Jump to content

alemapo

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

About alemapo

  • Birthday 08/31/1964

Profile Information

  • Gender
    Female
  • Location
    Georgia

alemapo's Achievements

Member

Member (2/5)

0

Reputation

  1. The surrounding code is all dreamweaver created. To the best of my knowledge I didn't change any of that. My code was working before but I had another level else in there that was removed. <?php require_once('Connections/Carrollton.php'); ?> <?php include('upload_functions_magick.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } //call upload image function if (isset($_POST['submitted'])) { $image_type = upload_image(); //check to see if image type returned ok if ($image_type == 'ok') { //call move image function $full_path = "/home6/carroll7/public_html/classified_images/"; $short_path = "/classified_images/"; $stored_name = move_image($full_path, $short_path); $_POST['hiddenField'] = $stored_name; echo "Image upload success!"; } else { echo "image wrong type"; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
  2. I had this code working great and then took out one of the "else" because I didn't need it anymore. Now I can't get the } right at the end. I keep getting this error. Parse error: syntax error, unexpected $end in /home6/carroll7/public_html/upload_functions_magick.php on line 45 Then if I move it I get another. Can anyone see it right off? Many thanks in advance. if (isset($_POST['submitted'])) { $image_type = upload_image(); //check to see if image type returned ok if ($image_type == 'ok') { //call move image function $full_path = "/home6/carroll7/public_html/classified_images/"; $short_path = "/classified_images/"; $stored_name = move_image($full_path, $short_path); $_POST['hiddenField'] = $stored_name; echo "Image upload success!"; } else { echo "image wrong type"; } }
  3. Hi, I created my program to upload and move images to the correct folder and it worked great. Then decided to use imagemagick to reduce the size of the image. That also works perfectly through the imagemagick part. Now that I have my reduced image in a variable how do I move that to the correct folder now that I can no longer use move_uploaded_file()? I have 2 functions - the first one uploads the image, checks the type, etc. The 2nd one does the actual move (and now the resize). I'm only showing the second one here that deals with the move. Any help or suggestions would be greatly appreciated! Pamela function move_image($full_path, $short_path) { $original_image = $_FILES['thefile']['tmp_name']; $size = GetImageSize($original_image); $new_image = $_FILES['thefile']['name']; $max_width = "300"; $max_height = "300"; exec("convert -size {$size[0]}x{$size[1]} $original_image -thumbnail $max_widthx$max_height $new_image"); echo "<img src=\"".$new_image."\">"; Note: Where I have the echo of the image used to be my move_uploaded_file() before I put in the imagemagick. But the image I want to move is now in $new_image instead of $_FILES['thefile']['tmp_name'] so I'm not sure how to get that in my folder. Thanks in advance if you can help!
  4. play_ you said: "Keep in mind also that there could be duplicate names with md5 hashed strings as well." I thought of that after I sent the last reply. I changed it to use the md5 hashed string plus the timestamp. Hopefully that will be good enough! Thanks again!
  5. Hi, I am creating an external function to do upload and move of images on my web pages so that I can call the same function from multiple screens. I need to pass the $_FILES array to the function but can not figure out the syntax. I have tried everything I can think of and get syntax errors. My function name is upload_image and I need to pass the entire $_FILES array to the function so that all the error checking and actual move can be done in the function. I need help with the function declaration line with the array and the call to the function line for the array. I have tried everything I can think of. For the declaration I have tried: function upload_image takes_array($_FILES) { (or) function upload_image($_FILES) { For the call to the function I have tried: upload_image($_FILES['upload']['type']); (Or) upload_image($_FILES); No variation I try works. I know you can send an array to the function but do I need to do something different since this is $_FILES? Any help would be greatly appreciated. Thanks! Pamela
  6. Thanks play_. This solution worked. I just had to add in the "." as below: $tempname = 'C:/Users/Pamela/Desktop/put_here/'.md5($_FILES['thefile']['name']) . '.' .$ext; I don't think I will have a problem retrieving them since the names will be stored in a database - it doesn't really matter what they are named. Also, using the timestamp is a little risky since it is a multi-user system and will allow for multiple image uploads at one time it is quite feasible to have duplicates (which would actually write over another image). I think this will work for me. Thanks so much for your help!
  7. Hi, I have code which works for image upload and am trying to rename with random name during the move. I am using md5 to create the new name. Without md5 everything works fine but with md5 I get my new name and it moves correctly but I lose the file extension on the name. Can you see what my problem is as to why I am losing the file extension using md5? I am open to other suggestions to rename the image other than using md5 if necessary. Thanks in advance, Pamela <?php //function to upload photo function upload_photo() { //set the file location $tempname = 'C:/Users/Pamela/Desktop/put_here/'.md5($_FILES['thefile']['name']); //try to move the uploaded file if(move_uploaded_file($_FILES['thefile']['tmp_name'], $tempname)) { print '<p> Your file has been uploaded. </p>'; } else { print '<p> Your file was NOT uploaded. </p>'; print ($_FILES['thefile']['error']); } } ?>
  8. Thanks! The sprintf was throwing me. It worked! Pamela
  9. This is a follow up to a previous question. My previous questions was answered by MatthewJ and it worked but now I have another issue. The initial question was formatting data from MySQL type timestamp and set to CURRENT_TIMESTAMP. I wanted format mm-dd-yyyy. MatthewJ's answer to use the following worked. SELECT DATE_FORMAT(yourdatefield, '%m-%d-%Y') FROM yourtable However, in another program which uses sprintf it gives me an error. I am using PHP/Dreamweaver and I'm a newbie. My first sample where it was a straight select worked fine as below: $query_Recordset1 = "SELECT cls_id, DATE_FORMAT(cls_entry_date, '%m-%d-%Y') as display_date, cls_type FROM classifieds"; The new page which Dreamweaver uses sprintf - I assume because now there is a URL variable involved - the DATE_FORMAT gives an error. The code I am trying is: $query_Recordset1 = sprintf("SELECT cls_id, cls_mem_id, DATE_FORMAT(cls_entry_date, '%m-%d-%Y') as display_date, cls_type, cls_item, cls_description, cls_price, cls_contact, cls_email, cls_phone, cls_type_service, cls_lost_found FROM classifieds WHERE cls_type = %s", GetSQLValueString($colname_Recordset1, "text")); I get the following error on the sprintf: Warning: sprintf() [function.sprintf]: Too few arguments in C:\www\vhosts\localhost\_\masterdatesprintf.php on line 48 Do I need to change the syntax of the DATE_FORMAT inside the sprintf? Or will it not work there like it did in the straight select statement? I hope that wasn't confusing. Please let me know if you need more info. THANKS! Pamela
  10. Thank you so much MatthewJ. That worked!
  11. Hi, I apologize because this is a newbie question. I am programming with dreamweaver/php using mysql for database. I have a file containing user entered data and for the entry date I am using a field type "timestamp" and have it set in mysql to CURRENT_TIMESTAMP. I am now trying to format the date only to the screen for display in the format mm-dd-yyyy. I have read book after book and online and can't get a grasp on how to format that data stored in the timestamp field to the screen in the format I want. All I seem to find is how to use mysql commands to format the current system date. I can't find how to take the data from mysql in the timestamp format and display on my page as mm-dd-yy. If it would be better for me to store the date in a different way I am open to suggestions. Thanks in advance for your help! Pamela My field in mysql is cls_entry_date with type of timestamp. It is set to default of CURRENT_TIMESTAMP. I would like to echo with php the date in the format mm-dd-yyy.
  12. I'm marking this solved. I decided to move to PHP section. Thanks!
×
×
  • 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.