J
Jose Angel Campos
Hi, I will like to know if you know how to do it. I have this code for
read google news and I want to added to my DB MYSQL so I can store the
news for reading went I want.
Here is the code I use for read the news.
<?
//include "lang.php";
include "funciones.php";
echo <<<EOT
<center>
<h3><strong>SPANISH NEWS</strong></h3>
<table width="100%" align=center style="border:0px solid #aa0033;
font-size:small">
<tr>
<td width="3" rowspan=3> <div align="center"> <a
href=index.php?action=weather><img
src="http://www.inm.es/wwb/predi/p01gesp1.jpg" height=90 width=150
alt="Weather"><br><center>
<font color="#000000" size="2"><strong>The
Weather</a></strong></font></center> </div></td>
<td colspan=2 align=center><b>Subscribe for free to
Fuerteventura<br>
News</b></td>
</tr>
<form action="add_email.php">
<tr>
<td width="232"><div align="center">Email:
<input type=text name=email>
</div></td>
<td width="3"> </td>
</tr>
</form>
<tr>
<td height="26" colspan=2 align=center> <div align="center">
<input type=submit name="sub" value="Subscribe">
</div></td>
</tr>
</table>
</center>
EOT;
$url = "/news?hl=en&ned=us&q=spain&ie=UTF-8&output=rss";
$xml_parser = xml_parser_create();
$rss_parser = new RSS_1_0_Parser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$file = new GetWebObject("news.google.com", 80, $url);
$datas = $file->get_header();
//echo $datas["status"];
//echo $datas["Content-Type"];
$xml_declaration = "<?xml version=\"1.0\" ?>";
$fp = $file->get_content();
$new_contents="";
$xml_declaration_count = substr_count(Substr($fp,0,10),"<?xml");
if($xml_declaration_count == "0")
{
$new_contents = $xml_declaration . $fp ;
}
else
{
$new_contents = $fp;
}
if (!xml_parse($xml_parser, $new_contents ) )
{
//echo($fp);
die(sprintf("Unable to parse : XML error: %s at line
%d",xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
echo <<<EOT
<table width="100%" border="0">
<tr>
<td><div align="center">
<p><font size="2">Linking to <a
href="http://www.fuerteventuranews.com">Fuerteventuranews.com</a>.
<br>
Many sites are happy to link to us because <br>
we provide a comprehensive source of<br>
information about Fuerteventura. If you wish <br>
to link to the site, then add this code to your HTML
code.<br>
<textarea name="textarea" cols="50" rows="3"><a
href="http://www.fuerteventuranews.com">Fuerteventura, News Guide,
Information, Travels and Places to visit
http://www.fuerteventuranews.com</a>
</textarea>
</font> </p>
</div></td>
</tr>
</table>
EOT;
?>
How Can I save this to my DB??
THANKS TO ALL!!
read google news and I want to added to my DB MYSQL so I can store the
news for reading went I want.
Here is the code I use for read the news.
<?
//include "lang.php";
include "funciones.php";
echo <<<EOT
<center>
<h3><strong>SPANISH NEWS</strong></h3>
<table width="100%" align=center style="border:0px solid #aa0033;
font-size:small">
<tr>
<td width="3" rowspan=3> <div align="center"> <a
href=index.php?action=weather><img
src="http://www.inm.es/wwb/predi/p01gesp1.jpg" height=90 width=150
alt="Weather"><br><center>
<font color="#000000" size="2"><strong>The
Weather</a></strong></font></center> </div></td>
<td colspan=2 align=center><b>Subscribe for free to
Fuerteventura<br>
News</b></td>
</tr>
<form action="add_email.php">
<tr>
<td width="232"><div align="center">Email:
<input type=text name=email>
</div></td>
<td width="3"> </td>
</tr>
</form>
<tr>
<td height="26" colspan=2 align=center> <div align="center">
<input type=submit name="sub" value="Subscribe">
</div></td>
</tr>
</table>
</center>
EOT;
$url = "/news?hl=en&ned=us&q=spain&ie=UTF-8&output=rss";
$xml_parser = xml_parser_create();
$rss_parser = new RSS_1_0_Parser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$file = new GetWebObject("news.google.com", 80, $url);
$datas = $file->get_header();
//echo $datas["status"];
//echo $datas["Content-Type"];
$xml_declaration = "<?xml version=\"1.0\" ?>";
$fp = $file->get_content();
$new_contents="";
$xml_declaration_count = substr_count(Substr($fp,0,10),"<?xml");
if($xml_declaration_count == "0")
{
$new_contents = $xml_declaration . $fp ;
}
else
{
$new_contents = $fp;
}
if (!xml_parse($xml_parser, $new_contents ) )
{
//echo($fp);
die(sprintf("Unable to parse : XML error: %s at line
%d",xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
echo <<<EOT
<table width="100%" border="0">
<tr>
<td><div align="center">
<p><font size="2">Linking to <a
href="http://www.fuerteventuranews.com">Fuerteventuranews.com</a>.
<br>
Many sites are happy to link to us because <br>
we provide a comprehensive source of<br>
information about Fuerteventura. If you wish <br>
to link to the site, then add this code to your HTML
code.<br>
<textarea name="textarea" cols="50" rows="3"><a
href="http://www.fuerteventuranews.com">Fuerteventura, News Guide,
Information, Travels and Places to visit
http://www.fuerteventuranews.com</a>
</textarea>
</font> </p>
</div></td>
</tr>
</table>
EOT;
?>
How Can I save this to my DB??
THANKS TO ALL!!