Jump to content

beemer832

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

beemer832's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I didn't before you posted that. Then i read through it and that was good information but the resolution to my issue. I've had that issue in the past so I am familiar with it. The issue I was having had to do with a while loop not meeting its requirements which was then not running my function that was running the header redirect. So my code was working as intended, I just wasn't taking into account for all its logic. Thanks for pointing the sticky out and I'll be sure to look for others on future posts. thanks -beemer
  2. I need to know if what I am doing will even work. I have a .php page which submits information into a form to a insert_form.php page which then parses then information and adds it to a DB. In this insert_form.php page I have a function which is being called which is located in another .php file called function.php. This function adds images to the file system and will display errors if anything happens to the user. I do this by doing a header redirect: header('location:link.php?error=error message that i want to display'); The problem is the function is working because the images are being loaded correctly, but if something happens to the images and the header redirect gets initiated, its not redirecting. I need to know if the header redirect would work when being a function in another file or not. thanks beemer
  3. Error handling was on with the devel server, just making the point that Godaddy does not have a very good default php.ini file. I am using the same error handling on both servers now. Not trying to have someone else fix my code, just trying to understand why it works on one server, but not the other. I am under the assumption that the header() redirect on the index.php is sending output to the browser. Will investigate further. thanks -beemer
  4. which page do you add the: ob_start(); ?? thanks -beemer
  5. First want to start by saying these pages work perfect on my own hosted devel server running centos5. I am moving these to godaddy for production and am running into this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/93/6413093/html/classifieds/login.php:7) in /home/content/93/6413093/html/classifieds/init.php on line 2 The first page you browse to is index.php: <? header('location: secured_page.php'); ?> Header refers it to secured_page.php: <? require('init.php'); ?> Then there is a bunch of HTML code under neath this page. This is the secured (password protected) page. The init.php that is required: <? session_start(); require('config.php'); require('quotes.php'); With more PHP code under neath. The first 7 lines of the login.php page are all HTML code. The 7th line in this page that is PHP is: : sha1(sha1($_REQUEST['password']).$_SESSION['salt']); I cannot for the life of me figure out why this is happening. Checked for whitespace and characters before the session_start() in the init.php file. Any and all help is greatly appreciated. thanks -beemer
  6. Scenario: each row contains an ID, title, description, price, and up to 5 images. There are not always 5 images stored in each row. The images are stored as a file path which is then pulled out of the DB and used to display an image via HTML. I need to do some sort of loop/check that looks at the contents of a particular row (actually all rows in this particular table) and then decide how many times to loop through the images to display them all correctly on the webpage. I could statically set a variable for each column but then it would have a space for an image but nothing would show. I really want this to be able to only load the images that are stored in the DB. Any help on how I can go about this? thanks -beemer
  7. okay good to know for future notice, I will update that. the code is working now though. the file is uploaded. thanks -beemer
  8. Great question.... I have included the entire PHP page below, I was leaving out the DB information and some image manipulation code. I am redirecting the page back to the main page, index.php as there is no data on this page. Is this incorrect? <? header("location: /classifieds/index.php"); echo '<html><center>'; //first lets upload any files that were selected// $date = date("m/d/y",time()); //check that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 2500000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/uploads/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $newname); echo $tempnewname; $newname=$tempnewname[9].'/'.$tempnewname[10]; echo "It's done! The file has been saved as: ".$filename; } else { echo "Error: A problem occurred during file upload!"; } } else { //echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";// $timestampname = str_replace('.jpg', date('j-n-Y_g:i:s').'.jpg', (basename($_FILES['uploaded_file']['name']))); $path = dirname(__FILE__).'/uploads/'; $fullname = $path.$timestampname; //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $fullname); $newname=$tempnewname[7].'/'.$tempnewname[8]; $picname=$tempnewname[8]; ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))); } } else { echo "Error: Only .jpg images under 2.5MB are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> <? //Convert full size image to 1-thumbnail size 2-similar size for all images. files will be saved in corresponding folders// include('SimpleImage.php'); $image = new SimpleImage(); $image->load($fullname); $image->resize(175, 115); $image->save("images/thumb/2$picname"); $thumbpic="images/thumb/2$picname"; $image = new SimpleImage(); $image->load($fullname); $image->resize(640, 480); $image->save("images/full/2$picname"); $fullpic="images/full/2$picname"; ?> <? //now lets enter this information into the DB// include'dbconnect.php'; $title=$_POST['title']; $description=$_POST['description']; //$images=$_POST['uploaded_file'];// $price=$_POST['price']; mysql_connect($hostname,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO parts VALUES ('','$title','$description','$thumbpic','$fullpic','$price')"; mysql_query($query); mysql_close(); ?> </html> thanks -Beemer
  9. I need to be able to upload multiple files with the use of one form. Right now I have support for one file and it works great. I am stuck on what route I should take for times sake and reliability and functionality. Can I run each file on its own through the PHP script to upload the file; I would have to create a loop to run through the script as many times as there are files. OR Do I create new functionality and add the files through the use of an array? This is where I am getting the ARRAY idea: http://www.phpeasystep.com/phptu/2.html This is the PHP code that is submitting the image and uploading to file system. This is what I would use to loop through multiple files if I take the loop method. <? header("location: /classifieds/index.php"); echo '<html><center>'; //first lets upload any files that were selected// $date = date("m/d/y",time()); //check that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 2500000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/uploads/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $newname); echo $tempnewname; $newname=$tempnewname[9].'/'.$tempnewname[10]; echo "It's done! The file has been saved as: ".$filename; } else { echo "Error: A problem occurred during file upload!"; } } else { //echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";// $timestampname = str_replace('.jpg', date('j-n-Y_g:i:s').'.jpg', (basename($_FILES['uploaded_file']['name']))); $path = dirname(__FILE__).'/uploads/'; $fullname = $path.$timestampname; //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $fullname); $newname=$tempnewname[7].'/'.$tempnewname[8]; $picname=$tempnewname[8]; ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))); } } else { echo "Error: Only .jpg images under 2.5MB are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?> Thanks for hte help -Beemer
  10. This is the code that uploading the file, checking for size and file type, and then displaying errors on the page. Thanks for moving the thread, didn't know where it needed to be posted. <? header("location: /classifieds/index.php"); echo '<html><center>'; //first lets upload any files that were selected// $date = date("m/d/y",time()); //check that we have a file if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = substr($filename, strrpos($filename, '.') + 1); if (($ext == "jpg") && ($_FILES["uploaded_file"]["type"] == "image/jpeg") && ($_FILES["uploaded_file"]["size"] < 2500000)) { //Determine the path to which we want to save this file $newname = dirname(__FILE__).'/uploads/'.$filename; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $newname); echo $tempnewname; $newname=$tempnewname[9].'/'.$tempnewname[10]; echo "It's done! The file has been saved as: ".$filename; } else { echo "Error: A problem occurred during file upload!"; } } else { //echo "Error: File ".$_FILES["uploaded_file"]["name"]." already exists";// $timestampname = str_replace('.jpg', date('j-n-Y_g:i:s').'.jpg', (basename($_FILES['uploaded_file']['name']))); $path = dirname(__FILE__).'/uploads/'; $fullname = $path.$timestampname; //strip off file path for $newname variable so path is not accessible via html// $tempnewname = explode('/', $fullname); $newname=$tempnewname[7].'/'.$tempnewname[8]; $picname=$tempnewname[8]; ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))); } } else { echo "Error: Only .jpg images under 2.5MB are accepted for upload"; } } else { echo "Error: No file uploaded"; } ?>
  11. I am working on a PHP project that will allow a user to upload a handful of images, and then submit text to go along with it. To simplify the uploading process of a file, I restricted the type of file that can be uploaded (jpg) and the size (2.5mb). The problem is, the form is calling to a PHP script, and I have error logging built in to alert the user of why a file didn't upload, but since the PHP script is just being called, no errors are being displayed on the page. I guess unless I do a refresh of a few seconds to view any errors on the page.... What I would like to do is show a pop-up/error message notifying the user that the file type or size is incorrect and needs to be adjusted. Now part of the problem is, the file needs to be uploaded to the server first, and then everything can be checked, so I am really getting confused. If someone can point me in the right direction on what I could use to accomplish this, it would be greatly appreciated. Thanks -beemer
  12. You were spot on. The diretory path had an extra few folders in it, so when I exploded the path and picked the information I needed out of it, I was pulling the wrong information. Still having some other issues with files, but I think I can deal with it. Thanks for your help -Josh
  13. I am having issues getting an image resizing script using GD to work correctly on a GoDaddy webhosting account. I have the same files running on my own personal test server 100%. http://mackscycles.com/php.phpPersonal server phpinfo() http://kearneylawn.com/php.phpGoDaddy phpinfo() Errors displaying when running php script in Godaddy server: Simpleimage.php is the image resizing script I am using. Error: No file uploaded Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/93/6413093/html/classifieds/SimpleImage.php on line 60 Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/93/6413093/html/classifieds/SimpleImage.php on line 63 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/content/93/6413093/html/classifieds/SimpleImage.php on line 82 Warning: imagesx(): supplied argument is not a valid Image resource in /home/content/93/6413093/html/classifieds/SimpleImage.php on line 60 Warning: imagesy(): supplied argument is not a valid Image resource in /home/content/93/6413093/html/classifieds/SimpleImage.php on line 63 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/content/93/6413093/html/classifieds/SimpleImage.php on line 82 Warning: Cannot modify header information - headers already sent by (output started at /home/content/93/6413093/html/classifieds/insert_item.php:47) in /home/content/93/6413093/html/classifieds/insert_item.php on line 91 Thanks Josh
  14. got the first issue squared away by running "yum install php-gd" (centos 5) That downloaded and installed GD support for PHP, then had to restart Apache for changes to take affect. Now I have a few more issues, but haven't had a chance to dig into them yet. Thanks for everyones help -josh
  15. Okay well that explains why it isn't working correctly. So now my question is, how do I get this version of PHP to support GD? I did a yum update php to install the newest version. Running Centos 5. thanks josh
×
×
  • 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.