Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

hta access question

Posted on 2011-09-22
13
Medium Priority
?
281 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 84

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
Technology Partners: 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!

 

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 84

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 84

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 84

Accepted Solution

by:
Dave Baldwin earned 2000 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 84

Expert Comment

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

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

647 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