Jump to content

php scripts not woking on IIS6


zhq

Recommended Posts

Dear All,

 

The php scripts got errors when running on IIS 6.0 web server and windows server 2003. The error massages and the php codes are shown below. Please help me if you know the answer. Thanks a lot in advance.

 

zhqnus

 

####

error messages

***

Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in C:\Inetpub\wwwroot\vlsi\forward.php on line 21

 

Warning: file_get_contents(http://vlsi-test.ece.nus.edu.sg\/uploadfiles/CMOS_C35_noise_para_ENG-189_rev1.pdf): failed to open stream: No error in C:\Inetpub\wwwroot\vlsi\forward.php on line 21

 

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\vlsi\forward.php:21) in C:\Inetpub\wwwroot\vlsi\forward.php on line 62

 

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\vlsi\forward.php:21) in C:\Inetpub\wwwroot\vlsi\forward.php on line 63

 

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\vlsi\forward.php:21) in C:\Inetpub\wwwroot\vlsi\forward.php on line 64

 

Warning: fopen(): php_network_getaddresses: gethostbyname failed in C:\Inetpub\wwwroot\vlsi\forward.php on line 66

 

Warning: fopen(http://vlsi-test.ece.nus.edu.sg\/uploadfiles/CMOS_C35_noise_para_ENG-189_rev1.pdf): failed to open stream: No error in C:\Inetpub\wwwroot\vlsi\forward.php on line 66

 

Warning: fread(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\vlsi\forward.php on line 29

 

Warning: fclose(): supplied argument is not a valid stream resource in C:\Inetpub\wwwroot\vlsi\forward.php on line 68

####

 

 

####

forward.php

***

<?php

include("download_header.php");

header("Cache-control: private");

 

 

$filedir = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'];

if (dirname($HTTP_SERVER_VARS['PHP_SELF']) != "/")

$filedir = $filedir . dirname($HTTP_SERVER_VARS['PHP_SELF']) . "/";

 

$tempdir = $filedir . "temp/";

$filedir = $filedir . "uploadfiles/";

 

 

$redirect = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'];

if (dirname($HTTP_SERVER_VARS['PHP_SELF']) != "/")

$redirect = $redirect . dirname($HTTP_SERVER_VARS['PHP_SELF']) . "/";

$redirect = $redirect . "download_main.php";

 

function RemoteFileSize($remote_file)

{

$file = file_get_contents($remote_file);

 

return strlen($file);

}

 

function Longfread($handle, $size){

$contents = "";

do {

$data = fread($handle, $size);

if (strlen($data) == 0) {

break;

}

$contents .= $data;

} while(true);

return $contents;

}

 

 

 

if (isset($_GET['page'])){

$page=$_GET['page'];

 

mysql_connect("localhost","root","") or die ("Unable to connect to MySQL server.");

$db = mysql_select_db("nus") or die ("Unable to select requested database.");

$sql = "SELECT f_name from file WHERE f_ID=\"$page\"";

$result = mysql_query($sql);

 

if($result){

if (mysql_num_rows($result) == 0){

echo "This file may not exist in database. Please enter your administrator name correctly.

<a href=$redirect>BACK</a>.<br>";

exit();

} else{

$row_array = mysql_fetch_row($result);

$filename = $row_array[0];

//$filename ="logout.pdf";

//$tempdir=$tempdir.$filename;

$filedir=$filedir.$filename;

 

$filesize=RemoteFileSize($filedir);

 

header("Content-Type: application/pdf");

header("Content-Length: ".$filesize);

header("Content-Disposition: inline; filename=$filename");

 

$fp = fopen($filedir, 'rb');

$pdf_buffer = Longfread($fp, 8192);

fclose ($fp);

print $pdf_buffer;

exit();

 

//header("Location: $filedir");

//exit();

 

}

}

 

}else{

header("Location: $redirect");

}

#####

 

zhqnus

 

Link to comment
Share on other sites

  • 5 weeks later...

You didnt say if the script was working but displaying errors ?

 

If it works turn off WARNINGS

 

Ig it dosnt some thoughts:

 

is your allow_url_fopen set to true ?

 

[a href=\"http://vlsi-test.ece.nus.edu.sg\/uploadfiles/CMOS_C35_noise_para_ENG-189_rev1.pdf\" target=\"_blank\"]http://vlsi-test.ece.nus.edu.sg\/uplo...NG-189_rev1.pdf[/a]

 

theres a \/ after the domain part not sure how the call will treat this.

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.