RE: [PHP] 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 10:10:58 +0000 |
| Subject: | RE: [PHP] PHP->Mysql: How the heck do I read a html file into one string as input for DB fied??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30077@lists.php.net to get a copy of this message | ||
Hi Matthew,
Exactly what I was looking for!!! Thanks a lot!!!
"Life can be so beautiful if we think the easy way!"
Yoeri.
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();
> }
>
>