PHP->Mysql: How the heck do I read a html file into one string as input for DB fied???
| From: | Yoeri De Bruyn | Date: | Wed, 13 Dec 2000 09:28:55 +0000 |
| Subject: | PHP->Mysql: How the heck do I read a html file into one string as input for DB fied??? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30069@lists.php.net to get a copy of this message | ||
Hi phpees!
I want to push each and every page of our site into the DB, but first should
I have the file into a variable that the DB accepts.
Here is how I do it for now, But it says wrong query and stops reading at
the first " encountered in the html file.
$dbinput = array(
"pageInfo" => array(
"0" => "Title 1",
"1" => "Title 2"
),
"pageContURL" => array(
"0" => "page1.html",
"1" => "page2.html"
)
);
//create connection
$connection = mysql_connect("localhost","","")
or die("Couldn't connect to server.");
//select database
$db = mysql_select_db("searchDB", $connection)
or die("Couldn't select database.");
//populate the searchDB
$pageURL = $dbinput["pageContURL"][1];
$pageInfo = $dbinput["pageInfo"][0];
$pageContent = implode(file($dbinput["pageContURL"][1])," ");
//compose sql query
$sqlStore = "INSERT INTO search_site_contentTB (URL_LINK,
PAGE_INFO,PAGE_CONTENT)";
$sqlStore .= "VALUES (\"$pageURL\", \"$pageInfo\",
\"$pageContent\")";
//execute INSERT sql query
if(!($dbResult=mysql_query($sqlStore,$connection))){
print("Couldn't execute query!<BR>\n");
print("MySql Reports:" . mysql_error() . "<BR>\n");
print("Query was: $sqlStore<BR>\n");
exit();
}