Click to See Complete Forum and Search --> : save the result data into mysql db


SunnyVu
11-20-2007, 08:16 PM
Hi,

I have this script to read the result data:

$note = "";
echo "<h3>Data Dump</h3>";
$data = file($tmp) or die('Could not read file!');
//loop through array and print each line
foreach ($data as $line) {
$note = $note.$line."<br>";
}


If I do this, it writes to the page with all the data:
echo $note;

However, somehow when I stored in the database, the field NOTE has no data (BLANK). Other fields (hr, mr, interface, action) are fine. Also then datatype for NOTE field is set to TEXT.



mysql_select_db("infs", $MySQLconn);
mysql_query("INSERT INTO inband_conversion_log (hr, mr, interface, action, note) VALUES ('$hrname', '$clli', '$interface', 'Remove Interface Confirm', '$note')");
mysql_close($MySQLconn);

Please help,
Thanks.

trymbill
11-21-2007, 04:01 AM
What kind of a field / column is "note" in your MySQL table?

SunnyVu
11-21-2007, 11:10 AM
I use Datatype = Text for field "NOTE" in my table. I also tried Datatype = BLOG for field "NOTE", but no luck.

SunnyVu
11-21-2007, 04:57 PM
Figured it out. In the string has single quote ('), that screwed me up.

this works:
mysql_query("INSERT INTO inband_conversion_log (hr, mr, interface, filelink, action, note) VALUES ('$hrname', '$clli', '$interface', '$tmp', 'Outband Interface Confirm', '" . str_replace("'","''",$note) . "')");