Solved

hta access question

Posted on 2011-09-22
13
275 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
13 Comments
 
LVL 21

Expert Comment

by:Papertrip
ID: 36584474
Show us what "it" is and maybe we can help ;)
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36584483
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
 

Author Comment

by:brucegust
ID: 36584518
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:brucegust
ID: 36585976
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
 

Author Comment

by:brucegust
ID: 36585981
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36588572
In

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

remove the @.

http://us3.php.net/manual/en/language.operators.errorcontrol.php
0
 

Author Comment

by:brucegust
ID: 36589107
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36589215
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
 

Author Comment

by:brucegust
ID: 36589284
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
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 36589328
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
 

Author Comment

by:brucegust
ID: 36589566
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
 

Author Comment

by:brucegust
ID: 36589717
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
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 36589893
You're welcome, glad to help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question