Yeah that was it exactly what was wrong. Thank you!
*********** REPLY SEPARATOR ***********
On 13/01/2001 at 18:03 Sterling Hughes wrote:
>Toby Butzon wrote:
>>
>> This is a matter of figuring out why the variable isn't a
>> valid file handle resource. To do so, find where it should
>> be made such a resource (the line that says $fp =
>> fsockopen...etc... is probably it), and add some error
>> checking. I believe this function has its own way of
>> returning what's wrong; check php.net/fsockopen and take a
>> look at additional arguments... Then you must simply output
>> the resulting error message (which is assumed to be
>> resulting because the file handle is not being created).
>>
>> --Toby
>>
>
>That is good advice, but i don't think that's the poster's problem.
>
>The problem is the following code:
>
>fputs("$fp", "GROUP $groups[$i]\n");
>
>You cannot stringify a resource (with PHP 4). Therefore the offending code must
>look like:
>
>fputs($fp, "GROUP $groups[$i]\n");
>
>In order to work...
>
>-Sterling
>
>
>> ----- Original Message -----
>> From: "K.Simon" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Saturday, January 13, 2001 11:07 AM
>> Subject: [PHP] Wondering whats wrong?
>>
>> Hello,
>> running the following script (exec.php) on telnet account i
>> get this error:
>> Warning: Supplied argument is not a valid file handler
>> resource in exec.php on line 21
>> Can anybody tell me whats wrong with it? Normally it should
>> fetch the newsgroups on my local news server and insert them
>> into rows on a mysql database. This script is part of
>> myPHPusenet-0.9.9.
>> I hope the script was not too long.
>>
>> THE SCRIPT:
>> *********************************************************
>>
>> #!/usr/bin/php -q
>>
>> <?
>>
>> $start = gettimeofday();
>>
>> include("conf.inc.php");
>> include("newsgroups.inc.php");
>>
>> @mysql_connect($hostname, $username, $password) OR DIE
>> ("Could not connect");
>> @mysql_select_db("$database") OR DIE ("Could not open
>> database");
>>
>> $i = 0;
>> $j = 0;
>>
>> while($i < sizeof($groups) ) {
>>
>> $fp = fsockopen("$server", 119);
>> set_socket_blocking($fp, true);
>> $response = fgets($fp, 256);
>> fputs("$fp", "GROUP $groups[$i]\n");
>> $gruppe = fgets($fp, 1024);
>> $range = split(" ", $gruppe);
>> $range_start = $range[2];
>> $range_end = $range[3];
>>
>> $db_ng_name[$i] = ereg_replace("\.","_", $groups[$i]);
>>
>> $query1 = "UPDATE last SET last.last = '$range_end' WHERE
>> newsgroup = '$db_ng_name[$i]'";
>> $query2 = "SELECT last FROM last WHERE (newsgroup LIKE
>> '$db_ng_name[$i]')";
>> $runit2 = MYSQL_QUERY($query2);
>> $result = @MYSQL_RESULT($runit2,0,last);
>>
>> IF (@MYSQL_NUMROWS($runit2) == 1) {
>>
>> $range_start = $result;
>>
>> while($range_start < $range_end) {
>>
>> system("parse.php $server $groups[$i] $range_start");
>>
>> $range_start++;
>> $j++;
>>
>> }
>>
>> }
>>
>> ELSE {
>> PRINT "No new posts in $groups[$i]\n";
>> }
>>
>> $runit1 = MYSQL_QUERY($query1);
>>
>> $i++;
>> }
>>
>> $tables = MYSQL_LIST_TABLES($database);
>> $k = 0;
>>
>> WHILE ($k < MYSQL_NUM_ROWS ($tables)) {
>> $area_names[$k] = MYSQL_TABLENAME ($tables, $k);
>> $query = "SELECT count(*) AS total_nr FROM $area_names[$k]";
>> $q_string = @MYSQL_QUERY($query);
>> $fundet = @MYSQL_RESULT($q_string,0,total_nr);
>>
>> $total += $fundet;
>> $k++;
>> }
>>
>> $date = date("d");
>> $month = date("F");
>> $shortmonth = date("M");
>> $year = date("Y");
>> $hour = date("H");
>> $min = date("i");
>> $sec = date("s");
>>
>> $end = gettimeofday();
>>
>> $exec_time = number_format( (($end["sec"] +
>> $end["usec"]/1000000) - ($start["sec"] +
>> $start["usec"]/1000000)), 3);
>>
>> $contents = "Hi!\n\nThe newsparser was run $date $month
>> $year at $hour:$min:$sec, and it inserted $j posts in
>> the\ndatabasen, there are now $total posts in the
>> \n\nDatabase the update took $exec_time seconds.\n\n--
>> \n\nYours Truly.\n\tmyPHP usenet";
>>
>> mail("$email", "$subject", "$contents",
>> "From:$USER@$HOSTNAME\nReply-To: [EMAIL PROTECTED]");
>>
>> $fp = fopen($logname, "a") or die ("Could not open
>> logfile");
>> $logmess = "$shortmonth $date $hour:$min:$sec the newsparser
>> inserted $j posts, there are now $total total\n";
>> $write = fputs($fp, $logmess);
>> fclose($fp);
>>
>> ?>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail:
>> [EMAIL PROTECTED]
>> For additional commands, e-mail:
>> [EMAIL PROTECTED]
>> To contact the list administrators, e-mail:
>> [EMAIL PROTECTED]
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]