Re: PHP->Mysql: How the heck do I read a html file into one string as input for DB fied???
| From: | Matthew Ballard | Date: | Wed, 13 Dec 2000 09:45:46 +0000 |
| Subject: | Re: 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-30071@lists.php.net to get a copy of this message | ||
Just run addslashes on the text you are putting into mysql, ie:
$pageURL = addslashes($dbinput["pageContURL"][1]);
$pageInfo = addslashes($dbinput["pageInfo"][0]);
$pageContent = addslashes(implode(file($dbinput["pageContURL"][1])," "));
Matthew
At 10:28 AM 12/13/2000 +0100, you wrote:
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();} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net