MySQL errors

Permalink Browser Info Environment
I am playing about with some ideas offline before implementing them on the site.

I have created a product that requires no delivery and is not a physical product.
http://www.awesomescreenshot.com/image/694607/c88f8c1475dae8240d8ae...

I add the product to a page using a product block and the 'select product' option. No callouts or overlays. Just a price, description and add to cart.
http://www.awesomescreenshot.com/image/694619/6c537994361432a7289fd...
Default view template
http://www.awesomescreenshot.com/image/694624/9f136a3a55351a0874093...

On clicking 'Add to cart' the AJAX hangs. In the developer console the response is a SQL error
<h1>An unexpected error occurred.</h1>
<div class="ccm-error block-message alert-message error">mysqli error: [1064: 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 '?' at line 1] in EXECUTE("select productID, orderID, quantity, prPricePaid, prDiscount, prName from CoreCommerceOrderProducts where orderProductID = ?")
</div><p><a href="http://localhost/ecosurety/cms2" class="btn">< Back to Home</a></p>
</div>

The cart shows a product added, but it has a zero price:
http://www.awesomescreenshot.com/image/694683/eaaf97194124af81bc777...


The post data is
rcID:183
submit:Add to Cart
productID:2
method:JSON


Exploring fixes, If I hack the Product::getByID() method, from
$row = $db->GetRow("select productID, orderID, quantity, prPricePaid, prDiscount, prName from CoreCommerceOrderProducts where orderProductID = ?", $orderProductID);

to
$row = $db->GetRow("select productID, orderID, quantity, prPricePaid, prDiscount, prName from CoreCommerceOrderProducts where orderProductID = ?", array($orderProductID));

I now get a further error
Fatal error: Call to a member function rescanOrderProductPricePaid() on a non-object in E:\web\ecosurety\cms2\packages\core_commerce\models\order\product.php on line 94

Type: Discussion
Status: In Progress
JohntheFish
View Replies:
JohntheFish replied on at Permalink Reply
JohntheFish
I was logged in as admin while doing all of the above.
JohntheFish replied on at Permalink Reply
JohntheFish
Allocating the product to a page and selecting 'Inherit from current page' makes no difference. Same errors.
JohntheFish replied on at Permalink Reply
JohntheFish
This doesn't appear to happen on an existing site/installation on my dev system. Only on a newly installed site.
JohntheFish replied on at Permalink Reply
JohntheFish
Never mind. Updating the fresh install to the latest eCommerce solved the problem.

But why did the existing eCommerce installation work OK on the same previous version? But not this installation?
Korvin replied on at Permalink Reply
Korvin
I'm not sure why it wasn't working, but your original error makes it sound like `$orderProductID` is null where it shouldn't be. I'm glad to hear updating fixed the issue :)
JohntheFish replied on at Permalink Reply
JohntheFish
I suspect that data somewhere was lax about differentiating between null, empty string and zero with SQL parameters. Perhaps relating to the first ever cart.

concrete5 Environment Information

# concrete5 Version
5.6.3.4

# concrete5 Packages
eCommerce (2.8.12), Editor Comment (1.0.1)

# concrete5 Overrides
languages/ar, languages/cs_CZ, languages/da_DK, languages/de_DE, languages/el_GR, languages/es_AR, languages/es_ES, languages/es_MX, languages/es_PE, languages/fa_IR, languages/fi_FI, languages/fr_FR, languages/it_IT, languages/ja_JP, languages/nb_NO, languages/nl_NL, languages/pl_PL, languages/pt_BR, languages/pt_PT, languages/ro_RO, languages/ru_RU, languages/sk_SK, languages/sl_SI, languages/sv_SE, languages/tr_TR, languages/vi_VN, languages/zh_TW

# concrete5 Cache Settings
Block Cache - On
Overrides Cache - On
Full Page Caching - Off

# Server Software
Apache/1.3.11 (Win32)

# Server API
cgi-fcgi

# PHP Version
5.3.29

# PHP Extensions
bcmath, bz2, calendar, cgi-fcgi, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, gmp, hash, iconv, imap, json, libxml, mbstring, mcrypt, mhash, mysql, mysqli, mysqlnd, odbc, openssl, pcre, PDO, pdo_mysql, PDO_ODBC, pdo_sqlite, pgsql, Phar, Reflection, session, SimpleXML, soap, sockets, SPL, sqlite3, standard, tidy, tokenizer, wddx, xml, xmlreader, xmlrpc, xmlwriter, zip, zlib.

# PHP Settings
max_execution_time - 30
log_errors_max_len - 1024
max_file_uploads - 40
max_input_nesting_level - 64
max_input_time - 60
max_input_vars - 1000
memory_limit - 128M
post_max_size - 32M
safe_mode - Off
safe_mode_exec_dir - <i>no value</i>
safe_mode_gid - Off
safe_mode_include_dir - <i>no value</i>
sql.safe_mode - Off
upload_max_filesize - 16M
mysql.max_links - Unlimited
mysql.max_persistent - Unlimited
mysqli.max_links - Unlimited
mysqli.max_persistent - Unlimited
odbc.max_links - Unlimited
odbc.max_persistent - Unlimited
pcre.backtrack_limit - 1000000
pcre.recursion_limit - 100000
pgsql.max_links - Unlimited
pgsql.max_persistent - Unlimited
session.cache_limiter - nocache
session.gc_maxlifetime - 7200
soap.wsdl_cache_limit - 5
safe_mode_allowed_env_vars - PHP_
safe_mode_protected_env_vars - LD_LIBRARY_PATH

Browser User-Agent String

Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You may not request a refund that is not currently owned by you.