At 23:36 22.11.2002, Patrick Anderson at TUE said:
--------------------[snip]--------------------
>For some (strange, I know) reason I would like to copy the content of a
>webpage into a database.
>
>I would like to have code like
>
>$whocares = include ("http://www.microsoft.nl");
>$query = "insert into html values ($whocares,...)";
>..
>
>However, include can not copy the content to a variable. Does anyone
>have an idea how to circumvent this problem?
--------------------[snip]--------------------
It's kinda strange you want to keep M$'es page in a database... *g*
$fp = fopen('http://www.microsoft.nl', 'r');
if ($fp) {
$buffer = null;
while ($chunk = fread($fp, 512*128)) // get in 512k chunks
$buffer .= $chunk;
fclose($fp);
str_replace('\'', '\'\'', $buffer);
$query = 'insert into html(thepage) values (\''.$buffer.'\')';
}
else die('No connection to Microsoft');
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php