esteftaats Posted September 21, 2013 Share Posted September 21, 2013 (edited) Hi guys. I was wrote this script. but I have a dificulty in this script. <?php require_once("simple_html_dom.php"); $post = ""; $html = file_get_html('http://www.irannaz.com/news_detail_26481.html'); $divs = $html->find("div[class=news_detail_text]"); foreach($divs as $div){ $post=$post.$div; } //echo $post; function clean($str) { $str = @trim($str); if(get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } $post = clean($post); $db = mysql_connect("localhost","root",""); mysql_query("SET NAMES 'utf8'", $db); mysql_query("SET CHARACTER SET utf8", $db); mysql_query("SET CHARACTER_SET_CONNECTION=utf8", $db); if ($db) { $sdb = mysql_select_db('wp',$db); if($sdb) { $sql = "INSERT INTO wp_posts (post_title,post_content,post_name,post_date,post_date_gmt,post_modified,post_modified_gmt,post_author,post_status) VALUES ('title2','".$post."','post_name2',now(),now(),now(),now(),1,'draft')"; $result = mysql_query($sql, $db)or die( mysql_error() ); } else { echo"database not found"; } } else { echo"not connected to mysql"; } $cdb = mysql_close($db); ?> once I insert $post in databas, I see post_content field is blank because get_magic_quotes_gpc() is not work in high version of php. I want to Solution for this dificaulty. very tnx. Edited September 21, 2013 by esteftaats Quote Link to comment https://forums.phpfreaks.com/topic/282349-dificaulty-for-clean-quotes/ Share on other sites More sharing options...
.josh Posted September 21, 2013 Share Posted September 21, 2013 get_magic_quotes_gpc would not make your column blank. Your problem is elsewhere. Quote Link to comment https://forums.phpfreaks.com/topic/282349-dificaulty-for-clean-quotes/#findComment-1450596 Share on other sites More sharing options...
esteftaats Posted September 21, 2013 Author Share Posted September 21, 2013 get_magic_quotes_gpc would not make your column blank. Your problem is elsewhere. NO, once I echo $post befor of $post = clean($post); result was true. but once I echo $post after $post = clean($post); result is blank Quote Link to comment https://forums.phpfreaks.com/topic/282349-dificaulty-for-clean-quotes/#findComment-1450604 Share on other sites More sharing options...
vinny42 Posted September 22, 2013 Share Posted September 22, 2013 result was true. Do you mean that $post contains a boolean value? Quote Link to comment https://forums.phpfreaks.com/topic/282349-dificaulty-for-clean-quotes/#findComment-1450631 Share on other sites More sharing options...
Solution esteftaats Posted September 22, 2013 Author Solution Share Posted September 22, 2013 (edited) Do you mean that $post contains a boolean value? No. $post value is html codes. for example : <div class='news_detail_text' > <div style="text-align: center;">این نقاشی های زیبا اثر یک هنرمند سوری به نام محمود اجله است.</div> <div> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-2.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-3.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-4.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-5.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-6.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-7.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-8.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-9.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div style="text-align: center;"> </div> <div style="text-align: center;"><a href="http://www.irannaz.com/news_cats_47.html" > <img border="0" alt="نقاشی های شگفت انگیز و بسیار جالب سه بعدی" src="http://www.irannaz.com/images/2013/08/4/Amazing-and-very-interesting-three-dimensional-drawings-10.jpg" title="نقاشی های شگفت انگیز و بسیار جالب سه بعدی"/></a></div> <div> </div> </div>your data registered Edited September 22, 2013 by esteftaats Quote Link to comment https://forums.phpfreaks.com/topic/282349-dificaulty-for-clean-quotes/#findComment-1450636 Share on other sites More sharing options...
vinny42 Posted September 22, 2013 Share Posted September 22, 2013 hmm.... I missed it before. The escape-string function requires that you are connected to the database and you are caling clean() before you connect. Quote Link to comment https://forums.phpfreaks.com/topic/282349-dificaulty-for-clean-quotes/#findComment-1450639 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.