dificaulty for clean quotes

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

esteftaats
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Sep 21, 2013 1:43 pm

dificaulty for clean quotes

Postby esteftaats » Sat Sep 21, 2013 1:46 pm

Hi guys.



I was wrote this script.



but I have a dificulty in this script.

Code: Select all

<?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.

Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron