将XPath查询插入数据库

时间:2015-09-11 14:47:57

标签: php mysql ajax xpath domdocument

我正在制作一个刮刀,用户可以在其中创建模板,在其中他/她控制所刮的内容,模板编辑器将存储XPath位置,因为我可以使用XPath旁边的DOMDocument。我目前用于存储查询的PHP脚本是:

<?php



    $mysql = new mysqli("*****" , "*****" , "*****" , "price_scraper");

    $prod_name = $mysql->real_escape_string($_POST['name']);
    $prod_price = $mysql->real_escape_string($_POST['price']);
    $prod_stock = $mysql->real_escape_string($_POST['stock']);
    $prod_desc = $mysql->real_escape_string($_POST['description']);
    $prod_image = $mysql->real_escape_string($_POST['image']);
    $prod_styles = $mysql->real_escape_string($_POST['styles']);
    $prod_offer_prices = $mysql->real_escape_string($_POST['offer_price']);
    $prod_man_ref = $mysql->real_escape_string($_POST['man_ref']);
    $prod_specs = $mysql->real_escape_string($_POST['specs']);
    $website_id = $mysql->real_escape_string($_POST['site_id']);


    $query = "INSERT INTO `scraper_templates` (`product_name` , `product_price` , `product_stock` , `product_description` , `product_image` , `product_styles` , `product_offer_prices` , `product_man_ref` , `product_specs` , `website_id`) VALUES ('$prod_name' , '$prod_price' , '$prod_stock' , '$prod_desc' , '$prod_image' , '$prod_styles' , '$prod_offer_prices' , '$prod_man_ref' , '$prod_specs' , '$website_id')";

    $q = $mysql->query($query);

    if($q){
        die("1");
    }else{
        die("0");
    }
?>

当我将XPath值插入数据库时​​,所有行都是空的。我认为逃避字符串可以解决问题但事实并非如此。

0 个答案:

没有答案