Jump to content

[SOLVED] Internal server error


carsey

Recommended Posts

Hi,

 

Im having a big problem with my table. The main function of the site works fine where we submit articles and they are stored in the database in MYSQL. But, if we enter a large amount of HTML to be stored, it simply throws us a internal server error preventing us from saving to the database.

 

The database is set to longtext so the amount of characters shouldnt really be a problem.

 

What is a solution to this problem??

 

Anything else needed im happy to give you it if neccessary.

 

Chris

Link to comment
Share on other sites

Hi,

 

Well, the problem is when we are submitting content to the database, the overall submitting process works a dream, but when we are submitting a large amount of text we get the error.

 

Here is the code:

 

<?
include "functions.php";
logincheck();
?>

<?
include_once "../includes/db_connect.php";
?>

<?

$cat=$_POST['cat'];
$name=$_POST['name'];
$articles=$_POST['articles'];
$type=$_POST['type'];


if ($_POST['Submit']){
mysql_query("INSERT INTO `1` (`id`, `name`, `article`, `cat`, `type`, `author`) VALUES ('', '$name', '$articles', '$cat', '$type', '$username')");
print"<p class='success'>You Added The $type, $name</p>";
}

?>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.success {
color: #990000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
font-weight: bold;
color: #009900;
text-decoration: none;
background-color: #FFFFFF;
text-align: center;
padding: 5px;
border: 2px solid #000000;
margin-right: 100px;
margin-left: 100px;
}
-->
</style>


<link href="../style.css" rel="stylesheet" type="text/css" />
<form action="" method="post" name="form1" class="style1" id="form1">
  <p align="center">
    Name:
    <input name="name" type="text" id="name" />
</p>
  <p align="center">Category
<select name="cat" id="cat">
  <option>Hardware</option>
   <option> Windows</option>
  <option>Software</option>
  <option>Security</option>
  <option>Networking</option>
  <option>Alternate Computing</option>
  <option>Business and Career</option>
  <option>Gaming
    </select>
</p>
  <p align="center">Type
    <select name="type" id="type">
      <option>Article</option>
      <option>Tutorial</option>
  <option>Tips</option>
    </select>
  </p>    
  <div align="center">
    <input type="submit" name="Submit" value="Submit" />
  </div>
  <p align="center">Articles:</p>
  <p align="center">
    <textarea name="articles" cols="100%" rows="200" id="articles"></textarea>
  </p>
  <p align="center">
  </p>
</form>


 

Hope that helps

Link to comment
Share on other sites

Your table name is "1" ? Anyways, whats the exact error you get? Maybe some more details would be good.

 

Like change this

mysql_query("INSERT INTO `1` (`id`, `name`, `article`, `cat`, `type`, `author`) VALUES ('', '$name', '$articles', '$cat', '$type', '$username')");

into this

$query = "INSERT INTO `1` (`id`, `name`, `article`, `cat`, `type`, `author`) VALUES ('', '$name', '$articles', '$cat', '$type', '$username')";
mysql_query($query) or die(mysql_error()." ".mysql_errno ()." ".$query);

and post here what it spits out.

 

As an additional thing you can add this to the top of the script, just after the <?php thing, and copy all the warnings and errors that one spits out too.

error_reporting(E_ALL);

Link to comment
Share on other sites

HI again.

 

I still get the same Internal server error message

 

Here is the message:

 

Internal Server Error

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

Please contact the server administrator, webmaster@carsey2.hosting-town.com 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.

 

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

 

Link to comment
Share on other sites

If you can get a holed of the error_log of that servers apache, that would help, check for the latest entries, there is something awfully wrong there. Looks to me like PHP wasnt compiled right or a config error. You can see html pages on that host? PHP otherwise works fine?

Link to comment
Share on other sites

PLease see attached error log.

 

All pages on the host work fine,  Including both PHP and HTML pages. See yourself via the link here: http://www.c-carse.co.uk

 

Articles in general, if they are short, are fine and submit no problem. (see the tips section > Windows) as they all submitted no problem and the script added links etc.

 

Its just the long articles that are failing to submit.

 

hope this helps.

 

Many thanks for your support thus far.

 

Chris

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Hi,

 

This is what occurs in the error log when I submit:

[Mon Oct 22 22:55:15 2007] [error] [client 86.141.248.52] File does not exist: /home/carseyh/public_html/404.shtml

[Mon Oct 22 22:55:15 2007] [error] [client 86.141.248.52] File does not exist: /home/carseyh/public_html/stylesheets/online.css

[Mon Oct 22 22:55:15 2007] [error] [client 86.141.248.52] File does not exist: /home/carseyh/public_html/404.shtml

[Mon Oct 22 22:55:15 2007] [error] [client 86.141.248.52] File does not exist: /home/carseyh/public_html/admin/includes/in.css

[Mon Oct 22 22:55:10 2007] [error] [client 86.141.248.52] File does not exist: /home/carseyh/public_html/500.shtml

 

Please feel free to add me to MSN, if you wish.

 

Chris

Link to comment
Share on other sites

Are you properly escaping the data?

 

I see no where in your code where you are properly escaping the data...

So.. how about you escape your data before you put it in the database... just to eliminate that as a possible problem..

 

Also add some error reporting to your mysql functions..

 

Link to comment
Share on other sites

You could do something along the lines of:

<?php
function escape($str){
	if(get_magic_quotes_gpc())
		$str = stripslashes($str);

	return mysql_real_escape_string($str);
}

$cat=escape($_POST['cat']);
$name=escape($_POST['name']);
// etc..
?>

 

Also change mysql_query(...); to mysql_query(...) or die(mysql_error());  temporarily so we can see if there is any error.

 

If escaping the data doesn't correct the issue you should still do it anyway to ensure there is no SQL injection.

 

But if that doesn't work and you don't get an error message then it's likely that the error is being caused by some "security" module such as mod_security. Basically it tries to identify attacks by using patterns and if a pattern is matched it will stop the request and show an error page.

 

Link to comment
Share on other sites

I changed the file to this but im not sure whether it is correct.

 

<?

function escape($str){
	if(get_magic_quotes_gpc())
		$str = stripslashes($str);

	return mysql_real_escape_string($str);
}

$cat=escape($_POST['cat']);
$name=escape($_POST['name']);
    $articles=escape($_POST['articles']);
    $type=escape($_POST['type']);


if ($_POST['Submit']){

mysql_query("INSERT INTO `1` (`id`, `name`, `article`, `cat`, `type`, `author`) VALUES ('', '$name', '$articles', '$cat', '$type', '$username')") or die(mysql_error());;
print"<p class='success'>You Added The $type, $name</p>";
}

?>

Link to comment
Share on other sites

Sorry, here is the full code used in the create articles file.

 

<?
include "functions.php";
logincheck();
?>

<?
include_once "../includes/db_connect.php";
?>

<?

function escape($str){
	if(get_magic_quotes_gpc())
		$str = stripslashes($str);

	return mysql_real_escape_string($str);
}

$cat=escape($_POST['cat']);
$name=escape($_POST['name']);
    $articles=escape($_POST['articles']);
    $type=escape($_POST['type']);


if ($_POST['Submit']){

mysql_query("INSERT INTO `1` (`id`, `name`, `article`, `cat`, `type`, `author`) VALUES ('', '$name', '$articles', '$cat', '$type', '$username')") or die(mysql_error());
print"<p class='success'>You Added The $type, $name</p>";
}

?>
<style type="text/css">
<!--
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.success {
color: #990000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
font-weight: bold;
color: #009900;
text-decoration: none;
background-color: #FFFFFF;
text-align: center;
padding: 5px;
border: 2px solid #000000;
margin-right: 100px;
margin-left: 100px;
}
-->
</style>


<link href="../style.css" rel="stylesheet" type="text/css" />
<form action="" method="post" name="form1" class="style1" id="form1">
  <p align="center">
    Name:
    <input name="name" type="text" id="name" />
</p>
  <p align="center">Category
<select name="cat" id="cat">
  <option>Hardware</option>
   <option> Windows</option>
  <option>Software</option>
  <option>Security</option>
  <option>Networking</option>
  <option>Alternate Computing</option>
  <option>Business and Career</option>
  <option>Gaming
    </select>
</p>
  <p align="center">Type
    <select name="type" id="type">
      <option>Article</option>
      <option>Tutorial</option>
  <option>Tips</option>
    </select>
  </p>
  <p align="center">Articles:</p>
  <p align="center">
    <textarea name="articles" cols="100" rows="50" id="articles"></textarea>
  </p>
  <p align="center">
    <input type="submit" name="Submit" value="Submit" />
  </p>
</form>


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.