updating a text fileld with large HTML variable

wxdqz

New Member
OK,

I am getting the slashdot.xml file every 30 min or so, and decoding it into html. I then run run a cron job that outputs the html source into a text file. Now, I want to update a text field in my Mysql DB with the data from that file (so I can insert it into a little slashbox on my site). I realize that there is probably a much easier way to do this, but hey, I'm learning.

THe update keeps failing even though I know the file is read into the variable and I know the syntax is correct for the update (It works if I subtitute "foo" for the $data variable). So what's the deal?

Here's the code:
<?
// get contents of a file into a string
$filename = "slash.txt";
$fd = fopen ($filename, "r");
$data = fread ($fd, filesize ($filename));
fclose ($fd);
echo "<head></head><body>";
echo $data;
echo "</body>";
//connect tothe DB
$db = mysql_connect("localhost","root", "yeahright");
mysql_select_db("thatware",$db);
$one = "1";
// Update Block record
$sql = "UPDATE blocks SET content = '$data' WHERE id = $one";
$result = mysql_query($sql,$db)
or die("cannot update");
?>
 
Back
Top