why always 500:internal server error???

Discussion in 'PHP' started by true_promote, Jan 5, 2007.

  1. #1
    I have a php script which runs all fine on localhost,but when I uploaded and run the same script on my web server it gave a internal server error 500,premature end of sdript headers:(null)
    But it was running fine on my localhost,file permission set to 755 and I had uploaded the file using my web host's online file uploading system.
    What might have been the possible reason for its failure...

    the script is below
    <?php
    //WRITING THE FORMATED AND ALTERNATE RSS INPUT FEED
    //writing data onto myrss1 text file
    $number=date("d-m-Y");
    $f1=fopen("myrss1$number.txt","w");
    $f2=fopen("rss1.txt","r");$f3=fopen("rss2.txt","r");
    $n=1;
    while ($n<=4)
    {
    $n2=1;
    while ($n2==1)
    {
    $data=fgetc($f2);
    if ($data=="^")
    {$n2=3;}
    else
    fwrite($f1,"$data");
    }
    $n3=1;
    while($n3==1)
    {
    $data2=fgetc($f3);
    if ($data2=="^")
    {$n3=3;}
    else
    fwrite($f1,"$data2");
    }
    $n=$n+1;
    }
    fclose($f1);
    fclose($f2);
    fclose($f3);

    //writing data onto myrss2 file
    $f1=fopen("myrss2$number.txt","w");
    $f2=fopen("rss3.txt","r");$f3=fopen("rss4.txt","r");
    $n=1;
    while ($n<=4)
    {
    $n2=1;
    while ($n2==1)
    {
    $data=fgetc($f2);
    if ($data=="^")
    {$n2=3;}
    else
    fwrite($f1,"$data");
    }
    $n3=1;
    while($n3==1)
    {
    $data2=fgetc($f3);
    if ($data2=="^")
    {$n3=3;}
    else
    fwrite($f1,"$data2");
    }
    $n=$n+1;
    }
    fclose($f1);
    fclose($f2);
    fclose($f3);

    //CREATING TWO NEW HTML PAGES
    //writing the page 1
    $f1=fopen("title1.txt","r");$f2=fopen("description1.txt","r");
    $title1=fread($f1,4096);$description1=fread($f2,4096);
    fclose($f1);fclose($f2);
    $hyip1=fopen("hyip-news$number.html","w");
    $read=fopen("myrss1$number.txt","r");
    $read1=fopen("htmlpart1.txt","r");
    while (!feof($read1))
    {
    $data=fgetc($read1);
    fwrite($hyip1,"$data");
    }fclose($read1);

    fwrite($hyip1,"$title1");

    $read2=fopen("htmlpart2.txt","r");
    while (!feof($read2))
    {
    $data=fgetc($read2);
    fwrite($hyip1,"$data");
    }fclose($read2);

    fwrite($hyip1,"$description1");
    $read3=fopen("htmlpart3.txt","r");
    while (!feof($read3))
    {
    $data=fgetc($read3);
    fwrite($hyip1,"$data");
    }fclose($read3);

    fwrite($hyip1,"Latest HYIP News for $number");

    $read4=fopen("htmlpart4.txt","r");
    while (!feof($read4))
    {
    $data=fgetc($read4);
    fwrite($hyip1,"$data");
    }fclose($read4);

    while (!feof($read))
    {
    $data=fgetc($read);
    fwrite($hyip1,"$data");
    }fclose($read);

    $read5=fopen("htmlpart5.txt","r");
    while (!feof($read5))
    {
    $data=fgetc($read5);
    fwrite($hyip1,"$data");
    }fclose($read5);

    fwrite($hyip1,"hyip-news2$number.com");

    $read6=fopen("htmlpart6.txt","r");
    while (!feof($read6))
    {
    $data=fgetc($read6);
    fwrite($hyip1,"$data");
    }fclose($read6);

    fclose($hyip1);


    //writing the page 2

    $f1=fopen("title2.txt","r");$f2=fopen("description2.txt","r");
    $title2=fread($f1,4096);$description2=fread($f2,4096);
    fclose($f1);fclose($f2);
    $hyip1=fopen("hyip-news2$number.html","w");
    $read=fopen("myrss2$number.txt","r");
    $read1=fopen("htmlpart1.txt","r");
    while (!feof($read1))
    {
    $data=fgetc($read1);
    fwrite($hyip1,"$data");
    }fclose($read1);

    fwrite($hyip1,"$title2");
    $read2=fopen("htmlpart2.txt","r");
    while (!feof($read2))
    {
    $data=fgetc($read2);
    fwrite($hyip1,"$data");
    }fclose($read2);

    fwrite($hyip1,"$description2");

    $read3=fopen("htmlpart3.txt","r");
    while (!feof($read3))
    {
    $data=fgetc($read3);
    fwrite($hyip1,"$data");
    }fclose($read3);

    fwrite($hyip1,"Latest HYIP News for $number<br/> [page 2]");
    $read4=fopen("htmlpart4.txt","r");
    while (!feof($read4))
    {
    $data=fgetc($read4);
    fwrite($hyip1,"$data");
    }fclose($read4);

    while (!feof($read))
    {
    $data=fgetc($read);
    fwrite($hyip1,"$data");
    }fclose($read);
    $read5=fopen("htmlpart5.txt","r");
    while (!feof($read5))
    {
    $data=fgetc($read5);
    fwrite($hyip1,"$data");
    }fclose($read5);

    fwrite($hyip1,"hyip-news$number.html");

    $read6=fopen("htmlpart6.txt","r");
    while (!feof($read6))
    {
    $data=fgetc($read6);
    fwrite($hyip1,"$data");
    }fclose($read6);

    fclose($hyip1);
    ?>
     
    true_promote, Jan 5, 2007 IP
  2. koolasia

    koolasia Banned

    Messages:
    1,413
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Wat u do is when uploading the files do not chmod these files just upload n try
     
    koolasia, Jan 6, 2007 IP
  3. Pat Gael

    Pat Gael Banned

    Messages:
    1,331
    Likes Received:
    68
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ask your hosting service, some of them have disable functions like fopen(), fetch, and grab so the will not run.

    Otherwise chmod 666 or 777 on txt files as stated by koolasia.
     
    Pat Gael, Jan 6, 2007 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    If any functions were disabled by the host, you'd get a classic {FUNCTION_NAME} has been disabled for security reasons.

    Also, I tried to read through the code, and well it's too much, what is it exactly ?

    Lastly, windows machines handle php in an entirely different fasion from a *nix environment, it's never safe to assume that if a script works on localhost that it will do the same in a production environment, if you have a decent machine @ localhost, then install a vm and download the centos server cd, install apache NOT a wampp, lampp or any other kind of ampp, once done you will have as close to a production environment as there is, if your pc isn't good enough to do that, then make a subdomain on your site and use it to test on, obvioulsy eventually you will become acustomed to the things that do and do not work and will have to upload less and less.

    In short, I'm not suprised .....
     
    krakjoe, Jan 6, 2007 IP