You are here: fsockopen() Cookie problem Maximum execution time of 30 seconds exceeded « PHP Language « IT news, forums, messages
fsockopen() Cookie problem Maximum execution time of 30 seconds exceeded

Posted by Thorak on 03/20/07 21:00

Im having a wierd problem with one of my php scripts opening a socket
connection with session variables. My page is continualy returning

Fatal error: Maximum execution time of 30 seconds exceeded in "bla bla
bla" line 43
line 43 is: $html .= fgets($fp, 4096);

The thing is this code below works for me if i remove the line:

$Headers .= "Cookie: ".$Cookie."\r\n";

problem is then i don't have my session data filling in the form
fields. As soon as I add this line so that the form fields can get the
information needed then i get this Maximum execution error.

I know im getting a result for: $Cookie = $_SERVER["HTTP_COOKIE"]
cause of the echo that is returned and does match the echo of the
session on all my other scripts.

I have tried using things like: stream_set_timeout($fp, 60); to
control this - but they dont seem to do anything. And changing the:
$fp = fsockopen($URL, 80, $errno, $errstr, 30); to $fp =
fsockopen($URL, 80, $errno, $errstr, 120);

/*
//==================================
//==============================
*/
session_start();

$URL = "vinyl-design"; // localhost network connection
$Cookie = $_SERVER["HTTP_COOKIE"]; // gives
"PHPSESSID=c32fc53d15e03ba25f1ad6be035a7eb1"

$Page = 'interface2/order_details.php';

$fp = fsockopen($URL, 80, $errno, $errstr, 30);

// check if the website is found
if(!$fp) {
echo 'Failed opening socket connection!<br>'.$errstr.'('.
$errno.')';
}

else {
// write to the http server
$Headers = "GET /".$Page." HTTP/1.1\r\n";
$Headers .= "Host: ".$URL."\r\n";
$Headers .= "Content-Type: text/html\r\n";
$Headers .= "Cookie: ".$Cookie."\r\n";
$Headers .= "Connection: Close\r\n\r\n";
fwrite($fp, $Headers);

// read the website
while(!feof($fp)) {
stream_set_timeout($fp, 60);

// store the html into a variable
$html .= fgets($fp, 4096);

$info = stream_get_meta_data($fp); // get any error
information
while reading the data

if ($info['timed_out']) {
echo 'Connection timed out while trying to
read data!';
}
}
fclose($fp);

}

echo $html;

/*
//==============================
//==================================
*/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация