Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>You should not use backquotes inside VALUES part. It's only to quote mysql identifiers (like table, column names). I think if you remove it your problem will be solved</li> <li>You should use quotes (regular ones either ' or ") when you quote string value in VALUES part (but see below, there is a better approach)</li> <li>If you choose #2, then you need to properly escape your values from XML by using mysql_real_escape_string in your case. In fact, this is a breach in security (see SQL injections) if you don't do this. But even if you say this is a temporary script one-time usage etc, you'll probably end up with another error when there is single- or double-quote in your xml data</li> <li>The best approach is using PDO prepare statements, then you don't bother quoting certain datatypes with quotes or not doing this - you bind certain param with its datatype. And remember that mysql_* functions are deprecated today.</li> </ol> <p>So this code works like a charm:</p> <pre><code>&lt;?php $Products = simplexml_load_file('xml_all_products.xml'); $config = array('db' =&gt; array( 'dbname' =&gt; 'test', 'host' =&gt; 'localhost:4040', 'username' =&gt; 'xx', 'password' =&gt; 'xxx' )); $db = new PDO('mysql:dbname='.$config['db']['dbname'].';host='.$config['db']['host'],$config['db']['username'],$config['db']['password']); foreach($Products-&gt;Product as $Product) { $ProductID = $Product-&gt;ProductID; $Name = $Product-&gt;Name; $DropshipPrice = $Product-&gt;DropshipPrice; $SRP = $Product-&gt;SRP; $Brand = $Product-&gt;Brand; $Xline = $Product-&gt;Xline; $InStock = $Product-&gt;InStock; $Stock = $Product-&gt;Stock; $Barcode = $Product-&gt;Barcode; $Weight = $Product-&gt;Weight; $CategoryID = $Product-&gt;CategoryID; $Category = $Product-&gt;Category; $SmallImage = $Product-&gt;SmallImage; $LargeImage = $Product-&gt;LargeImage; $Description = $Product-&gt;Description; $ProductsRS = $db-&gt;prepare("INSERT INTO test(ProductID, Name, DropshipPrice, SRP, Brand, Xline, InStock, Stock, Barcode, Weight, CategoryID, Category, SmallImage, LargeImage, Description) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); $ProductsRS-&gt;execute(array($ProductID, $Name, $DropshipPrice, $SRP, $Brand, $Xline, $InStock, $Stock, $Barcode, $Weight, $CategoryID, $Category, $SmallImage, $LargeImage, $Description)); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload