我在joomla中有一个错误-请查询.我在这个查询中有错误 [英] i have a error in joomla - query please. i have and error in this query

查看:291
本文介绍了我在joomla中有一个错误-请查询.我在这个查询中有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$datos = explode(';',$linea);
    $product_ean = trim($datos[0]);
    $product_price = trim($datos[1]);
    $name_es = trim($datos[2]);
    $short_description_es = trim($datos[3]);

    echo $product_ean,'<br>';
    echo $product_price,'<br>';
    echo $name_es ,'<br>';
    echo $short_description_es,'<br>';

    $db = JFactory::getDbo();
    $query = $db->getQuery(true);

    $columns = array('product_id' ,'product_ean', 'product_price', 'name_es-ES', 'short_description_es-ES');
    $values = array(NULL, $product_ean, $product_price, $name_es, $short_description_es);

    $query
        ->insert($db->quoteName('vrg_jshopping_products'))
        ->columns($db->quoteName($columns))
        ->values(implode(',', $values));

    $db->setQuery($query);
    $db->execute();


显示错误页面的错误:应用程序实例化 错误:您的SQL语法有误.检查与您的MySQL服务器版本相对应的手册,以在第3行的'600,1000,articulo nuevo 1,Articulo de test 1)'附近使用正确的语法


Error displaying the error page: Application Instantiation Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '600,1000,articulo nuevo 1,Articulo de test 1)' at line 3

SQL = INSERT INTO vrg_jshopping_products(product_idproduct_eanproduct_pricename_es-ESshort_description_es-ES)值(,600,1000,articulo nuevo 1,Articulo de test 1)

SQL=INSERT INTO vrg_jshopping_products (product_id,product_ean,product_price,name_es-ES,short_description_es-ES) VALUES (,600,1000,articulo nuevo 1,Articulo de test 1)

推荐答案

由于未引用值,因此出现sql错误.可以使用以下代码.

You are getting sql error because you have not quoted your values.You can use below code.

$columns = array('product_id' ,'product_ean', 'product_price', 'name_es-ES', 'short_description_es-ES');
$values = array(NULL, $product_ean, $product_price, $name_es, $short_description_es);


// Prepare the insert query.
$query
   ->insert($db->quoteName($table))
   ->columns($db->quoteName($columns))
   ->values(implode(',', $db->quote($values)));

这篇关于我在joomla中有一个错误-请查询.我在这个查询中有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆