Jump to content

beemer832

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Posts posted by beemer832

  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. 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

     

     

  5. 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

     

     

  6. 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

  7. 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

  8. 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";
    }
    ?>

     

     

  9. 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

  10. 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

  11. 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

  12. interesting... there isn't a GD section.......

     

    Configure Command './configure' '--host=i686-redhat-linux-gnu' '--build=i686-redhat-linux-gnu' '--target=i386-redhat-linux' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--without-mime-magic' '--without-sqlite' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--disable-dom' '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter' '--disable-json' '--without-pspell'

     

     

     

  13. I am working with the simpleimage.php script to allow me to create two separate images from one uploaded image. I keep getting the following error in my httpd error logs: PHP Fatal error:  Call to undefined function imagecreatefromjpeg() in /var/www/html/classifieds/SimpleImage.php on line 31.

     

    I just upgraded to php 5.2.13 after reading an issue with the GD library and support for JPEG's in 5.2.12. This did not fix the issue.

     

    SimpleImage.php file:

    <?php
    /*
    * File: SimpleImage.php
    * Author: Simon Jarvis
    * Copyright: 2006 Simon Jarvis
    * Date: 08/11/06
    * Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
    * 
    * This program is free software; you can redistribute it and/or 
    * modify it under the terms of the GNU General Public License 
    * as published by the Free Software Foundation; either version 2 
    * of the License, or (at your option) any later version.
    * 
    * This program is distributed in the hope that it will be useful, 
    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
    * GNU General Public License for more details: 
    * http://www.gnu.org/licenses/gpl.html
    *
    */
    
    class SimpleImage {
       
       var $image;
       var $image_type;
    
       function load($filename) {
          $image_info = getimagesize($filename);
          $this->image_type = $image_info[2];
          if( $this->image_type == IMAGETYPE_JPEG ) {
             $this->image = imagecreatefromjpeg($filename);
          } elseif( $this->image_type == IMAGETYPE_GIF ) {
             $this->image = imagecreatefromgif($filename);
          } elseif( $this->image_type == IMAGETYPE_PNG ) {
             $this->image = imagecreatefrompng($filename);
          }
       }
       function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
          if( $image_type == IMAGETYPE_JPEG ) {
             imagejpeg($this->image,$filename,$compression);
          } elseif( $image_type == IMAGETYPE_GIF ) {
             imagegif($this->image,$filename);         
          } elseif( $image_type == IMAGETYPE_PNG ) {
             imagepng($this->image,$filename);
          }   
          if( $permissions != null) {
             chmod($filename,$permissions);
          }
       }
       function output($image_type=IMAGETYPE_JPEG) {
          if( $image_type == IMAGETYPE_JPEG ) {
             imagejpeg($this->image);
          } elseif( $image_type == IMAGETYPE_GIF ) {
             imagegif($this->image);         
          } elseif( $image_type == IMAGETYPE_PNG ) {
             imagepng($this->image);
          }   
       }
       function getWidth() {
          return imagesx($this->image);
       }
       function getHeight() {
          return imagesy($this->image);
       }
       function resizeToHeight($height) {
          $ratio = $height / $this->getHeight();
          $width = $this->getWidth() * $ratio;
          $this->resize($width,$height);
       }
       function resizeToWidth($width) {
          $ratio = $width / $this->getWidth();
          $height = $this->getheight() * $ratio;
          $this->resize($width,$height);
       }
       function scale($scale) {
          $width = $this->getWidth() * $scale/100;
          $height = $this->getheight() * $scale/100; 
          $this->resize($width,$height);
       }
       function resize($width,$height) {
          $new_image = imagecreatetruecolor($width, $height);
          imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
          $this->image = $new_image;   
       }      
    }
    ?>
    
    

     

    Then I am using this to actually change my file sizes in another script:

    <?
    //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('uploads/screenshot.jpg');
       $image->resize(175, 115);
       $image->save('/images/thumb/screenshot.jpg');
    ?>

     

    Let me know if I missed anything, only posted here a few times. Also I am VERY new to PHP, only been coding for about a month now.

     

    Thanks

    Josh

     

    SimpleImage.php website:http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php

  14. I am just starting to learn PHP and work on a personal project. My goal is to offer a Login page for a business owner to log into their website and then add/remove content in a certain section as needed (classified information, part information, used equipment, etc.)

     

    I have a login script working successfully, but am trying to get pointed down the correct path where to start looking at the authenticated sessions and cookies to restrict unauthorized access.

     

    The page now loads to index.php which then redirects to parts.php once the user has been authenticated. I need to make sure that any user cannot browse to parts.php and gain access.

     

    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.