SunnyVu
03-06-2007, 12:41 AM
Hi,
I am trying to insert a record into the database. What I want to do is read everything in the text file and store it in a third variable ($result), then after that, I insert this in a database table (text). Please help!
$strTest1 = "test1"; - First variable
$strTest2 = "test2"; - Second variable.
$result = Third variable, I would like to read all the data in the text file below (which is echo correctly when I try the codes below)
$tmp = "tmp1.txt";
$data = file($tmp) or die('Could not read file!');
// loop through array and print each line
foreach ($data as $line) {
echo $line."<br>";
}
My SQL syntax would be:
mysql_query("INSERT INTO scriptactlog (login, scriptname, scriptoutput) VALUES ('$strTest1', '$strTest2', '$result')");
Thanks in advance
I am trying to insert a record into the database. What I want to do is read everything in the text file and store it in a third variable ($result), then after that, I insert this in a database table (text). Please help!
$strTest1 = "test1"; - First variable
$strTest2 = "test2"; - Second variable.
$result = Third variable, I would like to read all the data in the text file below (which is echo correctly when I try the codes below)
$tmp = "tmp1.txt";
$data = file($tmp) or die('Could not read file!');
// loop through array and print each line
foreach ($data as $line) {
echo $line."<br>";
}
My SQL syntax would be:
mysql_query("INSERT INTO scriptactlog (login, scriptname, scriptoutput) VALUES ('$strTest1', '$strTest2', '$result')");
Thanks in advance