Hello,
This I am sure is a rookie question but here goes.
I have a varuable $btn
I want to take what ever data that is currently in the field "news" in table "scrape_btn" and replace it with $btn
I am using php and MYSQL
Here is all of the code... I used or die() statements at the end of my mysql statements then used a print mysql success to determine were the problem is. It appears to connect to the db and the table however it seams to die at the update command.
<?php
mysql_connect ('localhost', 'myuser', 'mypassword')or die();
print "connect success";
mysql_select_db ('mydatabase')or die();
print "<br>select db success";
$open = fopen("http://www.someserver.com/headlines/index.jsp", "r");
// the above statement opens up the page using the socket libraries and reads it,
// fopen takes the pages as the 1st arguement and type of opening (r in this case) as the 2nd
$read = fread($open, 45000);
// fread scours to the 15000th byte and captures all the encountered bytes into $read
fclose($open);
$search = eregi("<IMG SRC=\"/images/tab_headlines.gif\" WIDTH=\"147\" HEIGHT=\"17\" BORDER=\"0\"><BR>(.*)<TD valign=\"top\" ALIGN=\"center\">", $read, $printing);
// Case insensitive search on the data
$printing[1] = str_replace("<TABLE cellspacing=\"2\" cellpadding=\"2\" border=\"0\" width=\"100%\">", "", $printing[1]);
$printing[1] = str_replace("<TR>", "", $printing[1]);
$printing[1] = str_replace("<TD>", "", $printing[1]);
$printing[1] = str_replace("<IMG BORDER=\"0\" HEIGHT=\"12\" WIDTH=\"10\" SRC=\"/images/arrow.gif\"><font size=\"1\" face=\"arial, helvetica, sans-serif\">", "", $printing[1]);
$printing[1] = str_replace("</font>", "", $printing[1]);
$printing[1] = str_replace("</TD>", "", $printing[1]);
$printing[1] = str_replace("</TR>", "", $printing[1]);
$printing[1] = str_replace("</TABLE>", "", $printing[1]);
$printing[1] = str_replace("<BR CLEAR=\"none\">", "", $printing[1]);
$printing[1] = str_replace("HREF=\"", "href=\"javascript:New('http://www.someserver.com", $printing[1]);
$printing[1] = str_replace("\">", "');\">", $printing[1]);
$printing[1] = str_replace("</A>", "</A><br><br>", $printing[1]);
// Striping and replacing data
$content = $printing[1];
$content = explode("ยท", $content);
// well this is also a common cancellation or rather the place where the shifting headlines into
// elements actually takes place with the help of "?" and explode();
$headlines = sizeof($content);
// counting the array elements
for ($i = 0; $i < $headlines; $i++) {
$btn = $content[$i];
// If I use print "$btn"; instead of the below two statements it prints.
mysql_query("UPDATE scrape_btn SET news='".$btn."'")or die();
print "<br>Databes Update Success";
}
?>
What is wrong with my mysql_query statement?
Many Thanks
Chris W.