{"id":7289,"date":"2014-06-03T23:35:35","date_gmt":"2014-06-03T23:35:35","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/syntax-error-debug-unexpected-t_constant_encapsed_string-closed-collection-of-common-programming-errors\/"},"modified":"2014-06-03T23:35:35","modified_gmt":"2014-06-03T23:35:35","slug":"syntax-error-debug-unexpected-t_constant_encapsed_string-closed-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/06\/03\/syntax-error-debug-unexpected-t_constant_encapsed_string-closed-collection-of-common-programming-errors\/","title":{"rendered":"Syntax Error Debug &#8211; Unexpected T_CONSTANT_ENCAPSED_STRING [closed]-Collection of common programming errors"},"content":{"rendered":"<p>Trying to pull off a histogram of Quote Values in a shopping cart. This query works if I paste it directly into mySQL, however I am having problems with the PHP side of things.<\/p>\n<p>Error message:<\/p>\n<pre><code>Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in ...\/...\/... Line 26.\n<\/code><\/pre>\n<p>My code:<\/p>\n<pre><code>echo '<\/code><\/pre>\n<h2><code>Histogram of Quotes<\/code><\/h2>\n<pre>';\n\n$sql = 'SELECT \n            ROUND(ROUND(Fixes.FixAM\/31.1035 * Products.Fineness * Products.Buy * Quotes.Weight, 2), -3)    AS bucket,\n            COUNT(*) AS Count,\n            RPAD('', LN(COUNT(ROUND(Fixes.FixAM\/31.1035 * Products.Fineness * Products.Buy * Quotes.Weight, 2))), \"*\") AS bar\n        FROM   \n            Quotes,\n            Products,\n            Fixes,\n            Currencies,\n            Metals,\n            ProductTypes\n        WHERE\n            Quotes.ProductId = Products.Id AND\n            Products.MetalId = Metals.Id AND\n            Products.ProductTypeId = ProductTypes.Id AND\n            Fixes.CurrencyId = Currencies.Id AND\n            Fixes.MetalId = Metals.Id AND\n            Currencies.Code = \"GBP\"                     \n        GROUP BY bucket';\n\n$stmt = $db-&gt;prepare($sql); \n$stmt-&gt;execute();\n    $rows = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);  \n<\/pre>\n<p><code>Line 26 is the line which says <code>GROUP BY bucket';<\/code><\/code><\/p>\n<p>PROOF that SQL Code Works<\/p>\n<pre><code>bucket  COUNT   bar\n0       114     *****\n1000    37      ****\n2000    8       **\n3000    2       *\n4000    3       *\n5000    4       *\n8000    1   \n9000    1   \n10000   1   \n21000   1   \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Trying to pull off a histogram of Quote Values in a shopping cart. This query works if I paste it directly into mySQL, however I am having problems with the PHP side of things. Error message: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in &#8230;\/&#8230;\/&#8230; Line 26. My code: echo &#8216; Histogram of Quotes &#8216;; $sql [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7289","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7289"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7289\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}