Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
session problem... http 500 error, please help
Old 11-16-2008, 06:39 PM session problem... http 500 error, please help
Experienced Talker

Posts: 38
Trades: 0
hi guys,

I'm just a newbie in php, trying to create an upload script.
it was working initially, until i start using session, so that i can pass values between pages.

i have few pages, and session is working well, until reaching the last page (upload_process.php).

form.php - flname.php - upload.php - upload_process.php
(gather imput) - (create dir) - (upload files - form) - (upload process/display log)

here is my code for upload_process.php:

PHP Code:
<?php 
  
// this starts the session 
  
session_start(); 
 
  
$success 0
  
$fail 0
  
$uploaddir 'chenup/'
  
$max_size "10000000"// 50000 is the same as 50kb 
  
$totalfiles "5"
  
session_start(); 
 
  require(
'includes/application_top.php'); 
 
  echo 
'<html ' HTML_PARAMS '><head><meta http-equiv="Content-Type" content="text/html; charset=' CHARSET '">'
  echo 
'<title>' TITLE ' - Upload Photos</title>'
  echo 
'<base href="' . (($request_type == 'SSL') ? HTTPS_SERVER HTTP_SERVER) . DIR_WS_CATALOG '">'
  echo 
'<link rel="stylesheet" type="text/css" href="stylesheet.css"></head>'
  echo 
'<body><center><table class="infoBoxContents" border="0" width="100%" cellspacing="0" cellpadding="0"><tr class="infoBoxContents"><td class="infoBoxContents" align="center"><table class="infoBoxContents" border="0" width="90%" cellspacing="8" cellpadding="8">'
 
  for (
$i=0;$i<$totalfiles;$i++) 
   { 
      if(
$_FILES['userfile']['name'][$i]) 
       { 
          
$uploadfile $uploaddir basename($_FILES['userfile']['name'][$i]); 
          
$ext strtolower(substr($uploadfile,strlen($uploadfile)-3,3)); 
 
         if (
preg_match("/(jpg|gif|png|tif|pdf)/",$ext)) 
         { 
            
// Check File Size 
            
if(($_FILES['userfile']['size'][$i] < $_POST['MAX_FILE_SIZE']) || ($_FILES['userfile']['size'][$i] < $max_size)) 
            { 
               if (
move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $uploadfile)) 
               { 
                  
$success++; 
                  
$success_total++; 
                  echo 
'<tr><td class="UploadPage" align="center"><b><font color="#00CC00">Upload Success !</font></b><br>' ' <b>' $_FILES['userfile']['name'][$i] . '</b> (' $_FILES['userfile']['size'][$i]/1024 ' kb)'
                  echo 
'</td></tr>'
               } 
               else 
               { 
                  
$fail++; 
                  echo 
'<tr><td class="UploadPage" align="center"><b><font color="#ff0000">Upload Failed.! Please retry</font></b><br>' ' <b>' $_FILES['userfile']['name'][$i] . '</b> (' $_FILES['userfile']['size'][$i]/1024 ' kb)'
                  echo 
'</td></tr>'
               } 
            } 
            else 
            { 
               
$fail++; 
               echo 
'<tr><td class="UploadPage" align="center"><b><font color="#ff0000">Upload Failed ! File size exceed 10MB</font></b><br>' ' <b>' $_FILES['userfile']['name'][$i] . '</b> (' $_FILES['userfile']['size'][$i]/1024 ' kb)'
                  echo 
'</td></tr>'
            } 
         } 
         else 
         { 
               
$fail++; 
               echo 
'<tr><td class="UploadPage" align="center"><b><font color="#ff0000">Upload Failed ! Invalid File Extension</font></b><br>' ' <b>' $_FILES['userfile']['name'][$i] . '</b> (' $_FILES['userfile']['size'][$i]/1024 ' kb)'
                  echo 
'</td></tr>'
          } 
       } 
   } 
  echo 
'</table></td></tr><tr><td class="main" align="center">&nbsp;<br><table class="infoBoxContents" border="2" width="40%" cellspacing="3" cellpadding="3"><tr><td class="main" align=left>'
  echo 
'<b>Total number of files uploaded:</b></td><td class="main" align=left> &nbsp;'.$success
  echo 
'</td></tr><tr><td class="main" align=left><b>Total number of files not uploaded:</b></td><td class="main" align=left> &nbsp;'.$fail '</td></tr></table></td></tr>'
  echo 
'<tr><td class="main" align="center">&nbsp;<br><form method="post"><input type="button" value="Close Window" onclick="window.close()"></form>&nbsp;&nbsp;&nbsp;<FORM METHOD="LINK" ACTION="upload.php"><INPUT TYPE="submit" VALUE="Continue"></FORM></td></tr>'
  echo 
'<tr class="infoBoxContents"><td class="main" align="center">&nbsp;<p><img src="http://www.webmaster-talk.com/images/store_logo.png" alt="PicsWorld">   <br><font size=-2>Copyright © 2008 <a href="http://picsworld.biz/">PicsWorld</a></font></td></tr></table>'
?>
The php script will be working if i remark // the session start (). when i unremark it (using session), the page will show http 500 error.

i would appreciate if someone could help me out here. really need your help, thanks.

i will show the rest of the files if you need me to.

btw, i'm hosted on a linux machine.

thanks a lot.
superkingkong is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-20-2008, 10:45 AM Re: session problem... http 500 error, please help
Average Talker

Posts: 19
Trades: 0
Http 500 errors are generally due to the web server software and usually not a client side problem.

Have you tried creating a simple test script declaring a session to see if that works?

If no sessions are working, you'll need to access your server logs to determine what the problem is with your setup as there'll probably be a session handling error in there. Not being very familiar with Linux that's about as much as I can help.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Limotek is offline
Reply With Quote
View Public Profile Visit Limotek's homepage!
 
Old 11-20-2008, 01:32 PM Re: session problem... http 500 error, please help
Banned

Posts: 81
Trades: 0
You need to log into root access to change the folder directory settings to 777 and that should help.
heretostay is offline
Reply With Quote
View Public Profile
 
Old 11-21-2008, 01:57 AM Re: session problem... http 500 error, please help
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Have you read the instructions file twice because this happend when we doesn't read them carefully? You may reread it and retry again.
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to session problem... http 500 error, please help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19697 seconds with 12 queries