sql - i have a error in joomla - query please. i have and error in this query -


$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(); 

error displaying error page: application instantiation error: have error in sql syntax; check manual corresponds mysql server version right syntax use near '600,1000,articulo nuevo 1,articulo de test 1)' @ line 3

sql=insert 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)

you getting sql error because have not quoted 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 insert query. $query    ->insert($db->quotename($table))    ->columns($db->quotename($columns))    ->values(implode(',', $db->quote($values))); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -