SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Formerly known as RockNRollPig Shpigford's Avatar
    Join Date
    Dec 2002
    Location
    Denver, CO
    Posts
    2,877
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    "Build An Automated PHP Gallery System In Minutes"...i've got problems

    okay...i just started the tutorial "Build An Automated PHP Gallery System In Minutes" over at sitepoint.com....at any rate...the second step or so you make a filed called preupload.php and insert the code which is as follows:
    PHP Code:
    <?php 
     
    include 'config.inc.php'
     
    // initialization 
     
    $photo_upload_fields ''
     
    $counter 1
     
    // If we want more fields, then use, preupload.php?number_of_fields=20 
     
    $number_of_fields = (isset($_GET['number_of_fields'])) ? 
       (int)(
    $_GET['number_of_fields']) : 5
     
    // Firstly Lets build the Category List 
     
    $result mysql_query('SELECT category_id,category_name FROM gallery_category'); 
     while(
    $row mysql_fetch_array($result)) { 
       
    $photo_category_list .= <<<__HTML_END 
    <option value="$row[0]">$row[1]</option>\
    __HTML_END

     } 
     
    mysql_free_result$result );   
     
    // Lets build the Image Uploading fields 
     
    while($counter <= $number_of_fields) { 
       
    $photo_upload_fields .= <<<__HTML_END 
    <tr><td
     
    Photo {$counter}: 
     <
    input name="photo_filename[]" 
    type="file" /> 
    </
    td></tr
    <
    tr><td
     
    Caption
     <
    textarea name="photo_caption[]" cols="30" 
       
    rows="1"></textarea
    </
    td></tr
    __HTML_END
       
    $counter++; 
     } 
     
    // Final Output 
     
    echo <<<__HTML_END 
    <html
    <
    head
    <
    title>Lets upload Photos</title
    </
    head
    <
    body
    <
    form enctype="multipart/form-data" 
     
    action="upload.php" method="post" 
     
    name="upload_form"
     <
    table width="90%" border="0" 
       
    align="center" style="width: 90%;"
       <
    tr><td
         
    Select Category 
         
    <select name="category"
         
    $photo_category_list 
         
    </select
       </
    td></tr
       <!
    —Insert the image fields here --> 
       
    $photo_upload_fields 
       
    <tr><td
         <
    input type="submit" name="submit" 
           
    value="Add Photos" /> 
       </
    td></tr
     </
    table
    </
    form
    </
    body
    </
    html
    __HTML_END
    ?>
    anywho....i upload that and then went to the the preupload.php page and i get this error:

    Parse error: parse error in /home/lindfd/public_html/preupload.php on line 21

    line 21 is:
    PHP Code:
       $photo_category_list .= <<<__HTML_END 
    anybody know why?

  2. #2
    SitePoint Member
    Join Date
    Oct 2003
    Location
    York, UK
    Posts
    23
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RockNRollPig
    line 21 is:
    PHP Code:
       $photo_category_list .= <<<__HTML_END 
    anybody know why?
    it's to do with the <<<__HTML_END thing... this gave me a headache too!

    here's my code:

    Code:
    <?php 
     include 'config.inc.php'; 
    
     // initialization 
     $photo_upload_fields = ''; 
     $counter = 1; 
    
     // If we want more fields, then use, preupload.php?number_of_fields=20 
     $number_of_fields = (isset($_GET['number_of_fields'])) ? 
       (int)($_GET['number_of_fields']) : 1; 
    
     // Firstly Lets build the Category List 
     $result = mysql_query('SELECT category_id,category_name FROM gallery_category'); 
     while($row = mysql_fetch_array($result)) { 
      $photo_category_list .= "    <option value='".$row[0]."'>$row[1]</option>\n";  } 
     mysql_free_result( $result );   
    
     // Lets build the Image Uploading fields 
     while($counter <= $number_of_fields) { 
       $photo_upload_fields .= " <div id=\"uploadcontainer\">
        <div id=\"uploadtext\">
         [ upload :: {$counter} ]
        </div>
        <div id=\"uploadbox\">
         <input name=\"photo_filename[]\" type=\"file\" size=\"36\" />
        </div>
        <div id=\"declarationtext\">
         [ anything to declare? ]
        </div>
        <div id=\"declarationbox\">
         <textarea name=\"photo_caption[]\" cols=\"49\" rows=\"3\"></textarea>
        </div>
        <br />"; $counter++ ; }
    
     // Final Output 
     echo "<html> 
     <head> 
      <title>upload photos innit?</title>
      <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\" />
      <script src=\"javascripts/validatecategorycreate.js\" language=\"javascript\" type=\"text/javascript\"></script>  
     </head> 
     <body> 
      <form action=\"categorycreate.php\" method=\"post\" enctype=\"multipart/form-data\" name=\"category_create\" onSubmit=\"MM_validateForm('newcategory','','R');return document.MM_returnValue\">
       create new category :: <br/>
       <input type=\"text\" maxlength=\"30\" name=\"newcategory\" /><br />
       <input type=\"submit\" name=\"submit\" value=\"create\" />
      </form> 
      <form enctype=\"multipart/form-data\" action=\"upload.php\" method=\"post\" name=\"upload_form\"> 
       select category ::<br />
       <select name=\"category\" class=\"categorydropdown\">
    $photo_category_list
       </select><br />
       <br />
       <!-— Insert the image fields here --> 
       $photo_upload_fields<br />
       <div id=\"submitbutton\">
        <input type=\"submit\" name=\"submit\" value=\"add photos\" /><br />
       </div>
      </form> 
     </body> 
    </html>" ;
    ?>
    i'm not sure why mayank did this in the sample files, but wherever you see <<<__HTML_END or just __HTML_END replace it with a single speech mark... that seemed to do the job for me...

    btw, i just thought i'd mention that line 22 of your code (<option value="$row[0]">$row[1]</option>n) should have a backslash before the "n"... so it reads <option value="$row[0]">$row[1]</option>\n

    i'm not exactly an expert on php or anything but if i can help out any more i'll try!

    jonic.

  3. #3
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well really it would be easier to just use quotes and escape your string instead of using the heredoc syntax. Use this:

    PHP Code:
    while($row mysql_fetch_array($result))
    {
           
    $photo_category_list .= "<option value=\"$row[0]\">$row[1]</option>";

    Also indent your code. It makes it a lot easier for people to debug and read. Including yourself

  4. #4
    Non-Member hyperimage's Avatar
    Join Date
    Dec 2003
    Location
    Croatia
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    hi

    instead heredoc string just put:
    echo "blabla";
    cya

  5. #5
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo 'blabla'; is more appropriate in this instance due to the fact the above user is outputting HTML

  6. #6
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks...I have the same trouble, but
    why is not possible to use <<<__HTML_END
    ?
    why doesn´t it work?
    Regards from Spain.

  7. #7
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem. It works.
    But I have another doubt.
    When I run phpinfo() I obtain this:
    GD Support enabled
    GD Version 1.6.2 or higher

    All tutorial works, but with '.gif' photos I obtain these warnigns:
    Code:
    Warning: ImageCreateFromGif: No GIF read support in this PHP build in c:\archivos de programa\easyphp\www\gallery\upload.php on line 72
    
    Warning: ImageGif: No GIF create support in this PHP build in c:\archivos de programa\easyphp\www\gallery\upload.php on line 84
    
    Warning: imagedestroy(): supplied argument is not a valid Image resource in c:\archivos de programa\easyphp\www\gallery\upload.php on line 85
    Anyone knows why?
    thanks and regards from Spain

  8. #8
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the 'gif' photos do not appear in small size ...buaaa

  9. #9
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?

  10. #10
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    UK
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dont think you can use gif's with GD library. Check php's site.

  11. #11
    SitePoint Enthusiast
    Join Date
    Jun 2004
    Location
    UK
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Further to the above the only MIME type specified in the script is .jpg or .JPEG to GD lib format.

  12. #12
    SitePoint Addict marylin77's Avatar
    Join Date
    Aug 2003
    Location
    Spain
    Posts
    362
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok Thanks ..it´s True


Bookmarks

Posting Permissions

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