hta access question

I'm running a script that allows the user to upload a picture. The code works as far as the way that it fires in a testing environment, but when I try it live, I'm getting an internal Server Error:

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


When I look at my error log, it's referring to the htaccess file. I've run into this before, but I've forgotten how to solve it.

What's wrong with it and how do I fix it?
Apache Server at tidewaterretirement.com Port 80
brucegustPHP DeveloperAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
That is the procedure, I don't know whether it will be good.  http://www.php.net/manual/en/configuration.changes.php   There is a link on that page to the list of 'php.ini' directives.
0
 
PapertripCommented:
Show us what "it" is and maybe we can help ;)
0
 
Dave BaldwinFixer of ProblemsCommented:
You might be asking for something that isn't supported on Godaddy.  Run 'phpinfo()' on your hosting and check to see that the functions you're using are supported.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
brucegustPHP DeveloperAuthor Commented:
Here's the code:

 
<?php 
session_start(); 
if (@$_SESSION['auth'] != "yes")                   
{
header("Location: default.php");
exit();
}
 
include ("../carter.inc");

function jpgResizeFrom( $filename, $width, $height, $newFilePath, $quality=75 ) { 
if ( file_exists( $filename ) && !is_dir( $filename ) ) { 
// Get current dimensions and calculate the best size
list($widthOrig, $heightOrig) = getimagesize($filename);

if ( $heightOrig > 0 ) {

$ratioOrig = $widthOrig/$heightOrig;

if ( ($width/$height) > $ratioOrig)
	 $width = $height * $ratioOrig;
else
	 $height = $width / $ratioOrig;


// Resample the original image
//
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $widthOrig, $heightOrig);


// Output to a file and clear memory of the old images
//
imagejpeg($image_p, $newFilePath, $quality);
//imagedestroy($image_p);
//imagedestroy($image);

} 

} // if file_exists
}
 
$target = "../Photos/"; 
$target = $target . basename( $_FILES['photo']['name']) ;
$url = basename($_FILES['photo']['name']); 

 
if(!move_uploaded_file($_FILES['photo']['tmp_name'], $target))  header("Location: photo_noupload.php");
else 
{
 
 
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");
$insert = "update bio set formal_pic='$url' where id ='$_POST[bio_id]'";
$insertexe = mysqli_query($cxn, $insert)
or die ("Couldn't execute query.");
}

//make a thumbnail
$width = 160;  // pixels
$height = 100;   // pixels 
$newFilePath = '../thumbs/';
$imageFolder = '../Photos';
$fileParts = pathinfo( $url );
$filename  = $fileParts['filename'];
$extension = strtolower( $fileParts['extension'] );
$origName  = "$imageFolder/$filename.$extension";
$newName   = "$newFilePath/$filename.$extension"; 
if ( $extension == "jpg" || $extension == "jpeg" || $extension=="JPEG" || $extension=="JPG" ) {
jpgResizeFrom( $origName, $width, $height, $newName );
 }

?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>The Retirement Guys of Tidewater | Casual Picture Upload</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="../AC_RunActiveContent.js" language="javascript"></script>
<script type="../text/javascript" src="swfobject.js"></script>
<link href="../stylesheet.css" rel="stylesheet" type="text/css" />
<script language="JavaScript"> 
 
<!--
 window.resizeTo(550,600)
 -->
 </SCRIPT>
</head>


<table width="500">
<tr>
<td>&nbsp;<BR>
Here's the picture you just uploaded...!
<P>
Thanks!
<P>
</td>
</tr>
<tr>
<td>&nbsp;<BR>
<HR>&nbsp;<BR>
</td>
</tr>
<tr>
<td>
	<table>
	<tr>
	<td>
	<IMG SRC="../Photos/<?php echo $url; ?>" width="200">
	</td>
	</tr>
	</table></form>

</body>
</html>

Open in new window


Sometimes it works, sometimes it doesn't. It will work with this picture (one of man an woman in winter garb), but then it won't work with the picture of the guy in the suit.

Weird.

The error log reference the htaccess file, but why that doesn't happen every time, I don't understand. winter shot - this worksgary.jpg
0
 
brucegustPHP DeveloperAuthor Commented:
OK, I broke things down to some bare bones dynamics and I"m hoping somebody can go, "Oh - that's what the issue is."

Here's my form when that starts this whole thing:

 
<form enctype="multipart/form-data" action="mini_formal_execute.php" method="Post">
	<table>
	<tr>
	<td>
	Photo
	</td>
	<td>
	<input name="photo" type="file" size="60">
	</td>
	</tr>
	<tr>
	<td colspan="2"><input type="hidden" name="bio_id" value="<?php echo $the_id; ?>">&nbsp;<BR>
	<input type="Submit" value="Submit">
	</td>
	</tr>
	</table></form>

Open in new window


Nothing to it, right?

OK, now look a this...

<?php
session_start();
if (@$_SESSION['auth'] != "yes")                  
{
header("Location: default.php");
exit();
}
 
include ("../whatever.inc");
$cxn = mysqli_connect($host,$user,$password,$database)
or die ("couldn't connect to server");

echo "hello";

?>

Again, this only happens when I try to upload the photo of the guy in the suit. But the fact that I'm getting a server error when all I'm attempting to do is say, "Hello" rules out configuration issues, I'm thinking, but I don't know what else could be the problem.

Thoughts?
0
 
brucegustPHP DeveloperAuthor Commented:
Just to clarify: All I'm doing on the other end of the form is echoing the word, "hello" and I'm getting the server error -  but only when I try to upload the photo of the guy in the suit. When I do a different photo, I'm OK, but it's not consistent.

What's the problem?
0
 
Dave BaldwinFixer of ProblemsCommented:
In

if (@$_SESSION['auth'] != "yes")  

remove the @.

http://us3.php.net/manual/en/language.operators.errorcontrol.php
0
 
brucegustPHP DeveloperAuthor Commented:
Hey, folks!

I think I'm on the threshold of fixing this.

After talking with godaddy and elaborating on the error messages I've been getting, they seem to think that since I'm running PHP 5, the php.ini file needs to be updated to a php5.ini file.

Question is: How?

I've been going through the web and it would appear that all I need to do is rename the file to php5.ini, but I wanted to run that past some ninjas whose counsel would allow me the opportunity to do this right the first time.

So, how do I set up a php5.ini file?
0
 
Dave BaldwinFixer of ProblemsCommented:
You normally just add the parts that you need to change in a 'php5.ini' in your web root.  

But!! It's better than that!!  http://community.godaddy.com/system-alerts/?ci=42512  A notice that uploads over 128KB are having problems right now!!
0
 
brucegustPHP DeveloperAuthor Commented:
Man, Dave, that's good news. I could not for the life of me figure out what was going on.

Still, let me repeat back to you what you mentioned about the php.ini file. If I take the content that is currently sitting on the php.ini file and rename it to php5.ini and add any of the other parameters that I might want to include, I'm good, correct?
0
 
brucegustPHP DeveloperAuthor Commented:
Yo, Dave! I changed the php.ini file but it didn't make any difference.

Still, I'm thinking it was a good move in that I am running PHP5. The bottom line is that article you referenced to me. I just got off the phone with godaddy and they confirmed that they are working on it and hopefully it will be solved soon!

Thanks!
0
 
brucegustPHP DeveloperAuthor Commented:
Just got off the phone with godaddy again and this time I was directed to my control panel where I changed a configuration with php that was affecting uploads that take a little more time.

Problem solved, problem solved!

Thanks, Dave!
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.