Re: why $message cannot to be inserted to mysql? see inside

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You'll need to use addslashes() before it is put into the database. Also make sure that your db schema allows for the number of characters you are inserting. With your second question about only grabbing text, use strip_tags() to get rid of html tags. You may also wish to use the other string functions to only grab text within certain tags. Eg. you may only want the text between certain tags (such as <!-- start content --> and <!-- end content --> below) I have written some code which lets me extract this info if you want it.

<html>
<head><title>Something</title>
</head>
<body>
<!-- advertising -->
<!-- start content -->
<p>welcome to the page content</p>
<!-- end  content -->
<!-- more advertising -->
</body>

Hope that helps,
Adam


how to get "specific" contents of a webpage?

£­£­£­£­£­£­£­£­
$filename="http://blahblah/index.php";;
...........
ob_start();
$message = @readfile($filename);
if (false !== $message) { // no readfile error
$message = ob_get_contents();
}
ob_end_clean();

if I echo $message, there is no problem for it show on the screen, however,
it won't get inserted into database which is frustrating me a lot(if change
$message="ok", it can be inserted perfectly fine):


$insertQuery = "insert into posts values ( \"{$fid}\",
\"{$tid}\",
\"{$pid}\",
\"{$author}\",
\"{$message}\",
\"{$subject}\"

)";
@mysql_query ($insertquery, $conn);

based on this, even if I could insert $message later on, how do I
differentiate the contents from images, such as I only want to insert text
info of $message and despite all the images.


thank you, I'm getting frustrated.

Bo

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux