anoniem Geplaatst: 12 februari 2002 Delen Geplaatst: 12 februari 2002 Ik heb een php-script gekregen om een gedeelte van een website op te halen, nu krijg ik alleen verschillende foutmeldingen. Weet iemand waar die voor staan (ik ben een beginner in php). Hieronder het script: <?php html2rdf.php3, plus a few cache files. $filename = "http://www.nieuwscorner.nl/overzicht_23.html"; // Location of the News Source $start = "Laatste 30 nieuwskoppen van Hockey"; // Start Grabbing Code $stop = "</table>"; // Stop Grabbing Code $page = "data.txt"; //name of first cache file $page2 = "data1.txt"; $page3 = "nieuws.rdf"; // Get contents of the specified URL and writes it into a string $fd = fopen( $filename, "r" ); $contents = fread( $fd, 20000 ); fclose( $fd ); // Isolates desired section. if(eregi("$start(.*)$stop", $contents, $printing)) { $substring=$printing[1]; // while is added as there are multiple instances of the </table> string & eregi // searches to include the most that matches, not the next. while(eregi("(.*)$stop", $substring, $printing)) { $substring=$printing[1]; }; } else { echo "Error, geen nieuws gevonden, excuses"; } // Replaces specific HTML tags and text $printing[1] = eregi_replace( "- .* records</b>", "", $printing[1] ); // Text $printing[1] = eregi_replace( "<IMG SRC=[^>]*>", "", $printing[1] ); // Images $printing[1] = eregi_replace( "<font[^>]*>", "", $printing[1] ); // Fonts $printing[1] = eregi_replace( "</font>", "", $printing[1] ); $printing[1] = eregi_replace( "<tr[^>]*>", "<li>", $printing[1] ); // Table Codes $printing[1] = eregi_replace( "<td[^>]*>", "", $printing[1] ); $printing[1] = eregi_replace( "</tr>", "", $printing[1] ); $printing[1] = eregi_replace( "</td>", "", $printing[1] ); // Adds Absolute URL $printing[1] = eregi_replace( "href="", "href="http://www.nieuwscorner.nl", $printing[1]); // Saves output to include file $cartFile = fopen("$page","w"); fwrite($cartFile,$printing[1]); fclose($cartFile); // Create RDF format // What appears on the head of the RDF file. $rdf1 = "Content-Type: text/html <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/"> <channel> <title>Nieuws</title> <link>http://hmhc.org</link> <description>HMHC-nieuws<description> </channel>"; // Changes include formatting above almost to XML format $rdf2 = eregi_replace( "<li>", "<item>", $printing[1] ); $rdf2 = eregi_replace( "<a href="", "<link>", $rdf2 ); $rdf2 = eregi_replace( "">", "</link></item><title>", $rdf2 ); $rdf2 = eregi_replace( "</a>", "</title>n", $rdf2 ); // Saves this to a cache file $cartFile = fopen("$page2","w"); fwrite($cartFile,$rdf2); fclose($cartFile); // Opens cache file and line by line changes the format to be in proper XML format $fd = fopen("$page2", "r"); $rdf2a = ""; // Leave this blank while ($buffer = fgets($fd, 4096)) { $buffer = eregi_replace( "(<link>.*</item>)(<title>.*</title>)", "\2 n \1 n", $buffer); $buffer = eregi_replace( "</link>", "</link>n", $buffer ); $rdf2a .= $buffer; } fclose($fd); // Closing the RDF & placing it together in a single variable $rdf3 = "</rdf:RDF>"; $rdf = $rdf1 . $rdf2a. $rdf3; // Writes above variable to a RDF file $cartFile = fopen("$page3","w"); fwrite($cartFile,$rdf); fclose($cartFile); ?> En de foutmeldingen: Warning: fopen("http://www.nieuwscorner.nl/overzicht_23.html","r") - A socket must be already connected. in /host/h/m/h/p/o/r/hmhc.port5.com/up.php on line 35 Warning: Supplied argument is not a valid File-Handle resource in /host/h/m/h/p/o/r/hmhc.port5.com/up.php on line 36 Warning: Supplied argument is not a valid File-Handle resource in /host/h/m/h/p/o/r/hmhc.port5.com/up.php on line 37 Heeft iemand een idee hoe ik dit kan oplossen, alvast bedankt... David Quote Link naar reactie
anoniem Geplaatst: 12 februari 2002 Auteur Delen Geplaatst: 12 februari 2002 Volgens mij zit er iets niet goed in de regel: $printing[1] = eregi_replace( "href="", "href="http://www.nieuwscorner.nl", $printing[1]); Er staan te veel " tekens. Probeer: ( "href=", "href=http://www.nieuwscorner.nl", $printing[1]); Quote Link naar reactie
Aanbevolen berichten
Om een reactie te plaatsen, moet je eerst inloggen