Jump to content


Photo

Keep getting an internal server error and only when I run this part of my script


  • Please log in to reply
4 replies to this topic

#1 rinkhals

rinkhals
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 July 2006 - 02:59 AM

Hey guys,

I keep getting an internal server error and I have checked everything that my hosts suggest which leaves only my code. I have worked it out to a certain potion of code and for the life of me I can't see to find the error, can anyone else skim through it and see if they find anything that might help. I know this isn't the best bit of upload code around but I am the only one who will ever have access to it.

I really appreciate any help

if (isset($_POST['addfile'])){

$error = 0;

$catid = $_POST['category'];

$bigimg_path = "/address/photos/img/";
$linkimg_path = "/address/photos/linkimg/";

$bigimg_path = $bigimg_path . basename( $_FILES['bigfile']['name']); 
$linkimg_path = $linkimg_path . basename( $_FILES['linkfile']['name']); 

$bigimg = "http://address/photos/img/". basename( $_FILES['bigfile']['name']);
$linkimg = "http://address/photos/linkimg/".basename( $_FILES['linkfile']['name']);

if(move_uploaded_file($_FILES['bigfile']['tmp_name'], $bigimg_path)) {
    echo "The large file ".  basename( $_FILES['bigfile']['name']). 
    " has been uploaded<br />";
} else{
    echo "There was an error uploading the large file, please try again!";
    $error = 1;
};

if(move_uploaded_file($_FILES['linkfile']['tmp_name'], $linkimg_path)) {
    echo "The link file ".  basename( $_FILES['linkfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the link file, please try again!";
    $error = 1;
};

if ($error == 0)
{

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn);

    $query = "INSERT INTO galimg (catid, img, linkimg) VALUES ('$catid', '$bigimg', '$linkimg')";
    mysql_query($query) or die('Error, query failed');
    mysql_close($conn);

};

};

Grae

#2 mhoctober

mhoctober
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 19 July 2006 - 11:17 AM

Grae....

do you know what line the code is failing on? You may have to write some 'Echos' to determine exactly what line of code is causing the error. It would also help if you could tell us exactly what the error reads.

#3 rinkhals

rinkhals
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 July 2006 - 03:28 PM

No, I don't know what line of code it is, I keep getting a 500 Internal Server Error when I run this code and it seems only this code. I have already checked the various folders permissions and theey are correct.

#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 03:39 PM

http://wordpress.org...ort/topic/73138
http://bugs.php.net/...id=35970&edit=1
http://gallery.menalto.com/node/48174
http://bugs.php.net/...?id=9981&edit=1
http://support.netfi...my-website.html
here is your code

if (isset($_POST['addfile'])){

$error = 0;

$catid = $_POST['category'];

$bigimg_path = "/address/photos/img/";
$linkimg_path = "/address/photos/linkimg/";

$bigimg_path = $bigimg_path . basename( $_FILES['bigfile']['name']); 
$linkimg_path = $linkimg_path . basename( $_FILES['linkfile']['name']); 

$bigimg = "http://address/photos/img/". basename( $_FILES['bigfile']['name']);
$linkimg = "http://address/photos/linkimg/".basename( $_FILES['linkfile']['name']);

if(move_uploaded_file($_FILES['bigfile']['tmp_name'], $bigimg_path)) {
    echo "The large file ".  basename( $_FILES['bigfile']['name']). 
    " has been uploaded<br />";
} else{
    echo "There was an error uploading the large file, please try again!";
    $error = 1;
};

if(move_uploaded_file($_FILES['linkfile']['tmp_name'], $linkimg_path)) {
    echo "The link file ".  basename( $_FILES['linkfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the link file, please try again!";
    $error = 1;
};

if ($error == 0)
{

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn);

    $query = "INSERT INTO galimg (catid, img, linkimg) VALUES ('$catid', '$bigimg', '$linkimg')";
    mysql_query($query) or die('Error, query failed');
    mysql_close($conn);

};

};

do this below
if (isset($_POST['addfile'])){

$error = 0;

$catid = $_POST['category'];

$bigimg_path = "/address/photos/img/";
$linkimg_path = "/address/photos/linkimg/";

$bigimg_path = $bigimg_path . basename( $_FILES['bigfile']['name']); 
$linkimg_path = $linkimg_path . basename( $_FILES['linkfile']['name']); 

$bigimg = "http://address/photos/img/". basename( $_FILES['bigfile']['name']);
$linkimg = "http://address/photos/linkimg/".basename( $_FILES['linkfile']['name']);

/* block out all of this, try it see if it works
if(move_uploaded_file($_FILES['bigfile']['tmp_name'], $bigimg_path)) {
    echo "The large file ".  basename( $_FILES['bigfile']['name']). 
    " has been uploaded<br />";
} else{
    echo "There was an error uploading the large file, please try again!";
    $error = 1;
};
*/

if(move_uploaded_file($_FILES['linkfile']['tmp_name'], $linkimg_path)) {
    echo "The link file ".  basename( $_FILES['linkfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the link file, please try again!";
    $error = 1;
};

if ($error == 0)
{

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn);

    $query = "INSERT INTO galimg (catid, img, linkimg) VALUES ('$catid', '$bigimg', '$linkimg')";
    mysql_query($query) or die('Error, query failed');
    mysql_close($conn);

};

};

Copy and paste the above over your other code.  THen if it still gives you error do this.
if (isset($_POST['addfile'])){

$error = 0;

$catid = $_POST['category'];

$bigimg_path = "/address/photos/img/";
$linkimg_path = "/address/photos/linkimg/";

$bigimg_path = $bigimg_path . basename( $_FILES['bigfile']['name']); 
$linkimg_path = $linkimg_path . basename( $_FILES['linkfile']['name']); 

$bigimg = "http://address/photos/img/". basename( $_FILES['bigfile']['name']);
$linkimg = "http://address/photos/linkimg/".basename( $_FILES['linkfile']['name']);

if(move_uploaded_file($_FILES['bigfile']['tmp_name'], $bigimg_path)) {
    echo "The large file ".  basename( $_FILES['bigfile']['name']). 
    " has been uploaded<br />";
} else{
    echo "There was an error uploading the large file, please try again!";
    $error = 1;
};
/* Block out this one completely.
if(move_uploaded_file($_FILES['linkfile']['tmp_name'], $linkimg_path)) {
    echo "The link file ".  basename( $_FILES['linkfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the link file, please try again!";
    $error = 1;
};
 */
if ($error == 0)
{

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn);

    $query = "INSERT INTO galimg (catid, img, linkimg) VALUES ('$catid', '$bigimg', '$linkimg')";
    mysql_query($query) or die('Error, query failed');
    mysql_close($conn);

};

};

try that one above if it doesn't work then do this
if (isset($_POST['addfile'])){

$error = 0;

$catid = $_POST['category'];

$bigimg_path = "/address/photos/img/";
$linkimg_path = "/address/photos/linkimg/";

$bigimg_path = $bigimg_path . basename( $_FILES['bigfile']['name']); 
$linkimg_path = $linkimg_path . basename( $_FILES['linkfile']['name']); 

$bigimg = "http://address/photos/img/". basename( $_FILES['bigfile']['name']);
$linkimg = "http://address/photos/linkimg/".basename( $_FILES['linkfile']['name']);

if(move_uploaded_file($_FILES['bigfile']['tmp_name'], $bigimg_path)) {
    echo "The large file ".  basename( $_FILES['bigfile']['name']). 
    " has been uploaded<br />";
} else{
    echo "There was an error uploading the large file, please try again!";
    $error = 1;
};

if(move_uploaded_file($_FILES['linkfile']['tmp_name'], $linkimg_path)) {
    echo "The link file ".  basename( $_FILES['linkfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the link file, please try again!";
    $error = 1;
};
/*
if ($error == 0)
{

$conn = mysql_connect($dbhost,$dbuser,$dbpass) or die('Error connecting to mysql');
mysql_select_db($dbname,$conn);

    $query = "INSERT INTO galimg (catid, img, linkimg) VALUES ('$catid', '$bigimg', '$linkimg')";
    mysql_query($query) or die('Error, query failed');
    mysql_close($conn);

};
*/
};

try all of these just like that, it will single out, take note if any of these stop the error, if one of them stops the error then the coded out part is the thing we need to concentrate on, then after that, show us the code again and tell us the results of this test.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#5 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 July 2006 - 03:40 PM

Also like he said above, copy and paste the exact full error message 505, not just 505 internal server error, but if there's more copy and paste the entire thing.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users