Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: t_string error

  1. #1
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts

    t_string error

    PHP Code:
    <?php
    #######################################
    //path where to store images
    $path_thumbs "images/thumbs";
    $path_big "images/big";
    $path_mini "images/mini
    //the new width of the resized image.
    $img_thumb_width = 200; // in pixcel
    $ing_mini_width = 50;

    $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_thumbs)){
       die ("
    ErrorThe directory <b>($path_thumbs)</bis NOT writable");
    }
    if (!is_writeable($path_big)){
        die ("
    ErrorThe directory <b>($path_big)</bis NOT writable");
    }
    if (!is_writeable($path_mini)){
        die ("
    ErrorThe directory <b>($path_mini)</bis NOT writable");
    }



    ?>
    i get i have a t_string error on this line $extlimit = "yes"; but i can see a problem

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    118
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Change this:

    PHP Code:
    $path_mini "images/mini 
    to this:

    PHP Code:
    $path_mini "images/mini"
    You were missing a closing quote and a semi colon.

  • #3
    Regular Coder
    Join Date
    Nov 2006
    Posts
    601
    Thanks
    1
    Thanked 2 Times in 2 Posts
    thanks... might as well try keep it on same topic... my image upload/resize script has come back wiht some errors

    obviusly you have seen config.php

    here is my upload script

    PHP Code:
    <?php



    session_start
    ();

    //load the config file

    include("config.php");

    require 
    '../settings.php';





    //if the for has submittedd

    if (isset($_POST['upForm'])){



           
    $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!. <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";

              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.  <br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";

              exit();

           }

           
    //get the file extension.

           
    $getExt explode ('.'$file_name);

           
    $file_ext $getExt[count($getExt)-1];



    //get users ID

        
    $id $_SESSION['user_id'];  

        



          

          
    //get the new width variable.

           
    $ThumbWidth $img_mini_width;



           
    //keep image type

           
    if($file_size){

              if(
    $file_type == "image/pjpeg" || $file_type == "image/jpeg"){

                   
    $new_img imagecreatefromjpeg($file_tmp);

               }elseif(
    $file_type == "image/x-png" || $file_type == "image/png"){

                   
    $new_img imagecreatefrompng($file_tmp);

               }elseif(
    $file_type == "image/gif"){

                   
    $new_img imagecreatefromgif($file_tmp);

               }

               
    //list width and height and keep height ratio.

               
    list($width$height) = getimagesize($file_tmp);

               
    $imgratio=$width/$height;

               if (
    $imgratio>1){

                  
    $newwidth $ThumbWidth;

                  
    $newheight $ThumbWidth/$imgratio;

               }else{

                     
    $newheight $ThumbWidth;

                     
    $newwidth $ThumbWidth*$imgratio;

               }

               
    //function for resize image.

               
    if (function_exists(imagecreatetruecolor)){

               
    $resized_img imagecreatetruecolor($newwidth,$newheight);

               }else{

                     die(
    "Error: Please make sure you have GD library ver 2+");

               }

               
    imagecopyresampled($resized_img$new_img0000$newwidth$newheight$width$height);

               
    //save image

               
    ImageJpeg ($resized_img,"$path_mini/$id.$file_ext");

               
    ImageDestroy ($resized_img);

               
    ImageDestroy ($new_img);

               
    //print message

               //echo "<br>Image Thumb: <a href=\"$path_thumbs/$id.$file_ext\">$path_thumbs/$id.$file_ext</a>";

            
    }



           

    $miniWidth $img_mini_width;



           
    //keep image type

           
    if($file_size){

              if(
    $file_type == "image/pjpeg" || $file_type == "image/jpeg"){

                   
    $new_img imagecreatefromjpeg($file_tmp);

               }elseif(
    $file_type == "image/x-png" || $file_type == "image/png"){

                   
    $new_img imagecreatefrompng($file_tmp);

               }elseif(
    $file_type == "image/gif"){

                   
    $new_img imagecreatefromgif($file_tmp);

               }

               
    //list width and height and keep height ratio.

               
    list($width$height) = getimagesize($file_tmp);

               
    $imgratio=$width/$height;

               if (
    $imgratio>1){

                  
    $newwidth $miniWidth;

                  
    $newheight $miniWidth/$imgratio;

               }else{

                     
    $newheight $miniWidth;

                     
    $newwidth $miniWidth*$imgratio;

               }

               
    //function for resize image.

               
    if (function_exists(imagecreatetruecolor)){

               
    $resized_img imagecreatetruecolor($newwidth,$newheight);

               }else{

                     die(
    "Error: Please make sure you have GD library ver 2+");

               }

               
    imagecopyresampled($resized_img$new_img0000$newwidth$newheight$width$height);

               
    //save image

               
    ImageJpeg ($resized_img,"$path_mini/$id.$file_ext");

               
    ImageDestroy ($resized_img);

               
    ImageDestroy ($new_img);

               
    //print message

               //echo "<br>Image Thumb: <a href=\"$path_thumbs/$id.$file_ext\">$path_thumbs/$id.$file_ext</a>";

            
    }



            
    //upload the big image

            
    move_uploaded_file ($file_tmp"$path_big/$id.$file_ext");

            
    //echo "<br>Image Big: <a href=\"$path_big/$id.$file_ext\">$path_big/$id.$file_ext</a>";



            
    echo "<br><br>--<a href=\"$_SERVER[PHP_SELF]\">back</a>";

            

            

    $query "INSERT INTO user_images (user_id, ext) VALUES ('$id', '$file_ext')

              ON DUPLICATE KEY UPDATE ext = '$file_ext'"
    ;

    mysql_query($query) or die(mysql_error());



    }else{ 
    //if the form hasn't been submitted.



          //print the form

          
    echo "<script>

          function view_img(img_name){

             document[img_name].src = upForm.imgfile.value;

                document[img_name].width = 150;

          }

          </script>\n\n

          <br><h3>:: Browse an Image to Upload:</h3>\n

          <form method=\"post\" name=\"upForm\" enctype=\"multipart/form-data\" action=\"$_SERVER[PHP_SELF]\">\n

          <input type=\"file\" name=\"imgfile\" > <img src='' name='img_vv' width='0'><br>\n

          Image width will resize to <b>$img_thumb_width</b> with height ratio.

          <br><input type=\"Submit\" name=\"upForm\" value=\"Upload & Resize\">\n

          </form>

          <a href=\"view_gallery.php\">View Images</a>"
    ;

          }

         



    ?>

    this is the errors i get

    Code:
    Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /public_html/members/uploader.php on line 123
    
    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /public_html/members/uploader.php on line 131
    
    Warning: imagejpeg(): supplied argument is not a valid Image resource in public_html/members/uploader.php on line 135
    
    Warning: imagedestroy(): supplied argument is not a valid Image resource in public_html/members/uploader.php on line 137
    
    Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in public_html/members/uploader.php on line 197
    
    Warning: imagecopyresampled(): supplied argument is not a valid Image resource in public_html/members/uploader.php on line 205
    
    Warning: imagejpeg(): supplied argument is not a valid Image resource in public_html/members/uploader.php on line 209
    
    Warning: imagedestroy(): supplied argument is not a valid Image resource in public_html/members/uploader.php on line 211
    seems to be as i try resize the image again it does ths


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •