Note that there are some explanatory texts on larger screens.

plurals
  1. POMYSQL syntax error - why is this happening?
    primarykey
    data
    text
    <p>I use mysql in my php scripts for more than 6 years but i never encountered error like this.</p> <p>When i execute this SQL command:</p> <pre><code>SELECT `discount_items`.* FROM `discount_items` WHERE (position=1) AND (active=1) AND (end&lt;=1344007212) AND (show=1) LIMIT 1 </code></pre> <p>it throws me this error</p> <pre><code>#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 'show=1) LIMIT 1' at line 1 </code></pre> <p>The table structure is:</p> <pre><code>CREATE TABLE IF NOT EXISTS `discount_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL, `image` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL, `discount` float NOT NULL, `price1` float NOT NULL, `price2` float NOT NULL, `bought` int(11) NOT NULL, `target` int(11) NOT NULL, `desc` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL, `link` text CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL, `active` tinyint(1) NOT NULL, `start` int(11) NOT NULL, `end` int(11) NOT NULL, `position` int(11) NOT NULL DEFAULT '1', `show` int(11) NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; </code></pre> <p>I don't get whats wrong. Obviously the 'show' field cause the problem but i already tried everything.. (there must be something wrong with show field because:</p> <pre><code>SELECT `discount_items`.* FROM `discount_items` WHERE (show=1) AND (active=1) AND (end&lt;=1344007212) AND (position=1) LIMIT 1 </code></pre> <p>throws</p> <pre><code>#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 'show=1) AND (active=1) AND (end&amp;lt;=1344007212) AND (position=1) LIMIT 1' at line 1 </code></pre> <p>So the problem moves with the show field.</p> <p>I am sorry if this is common problem but i googled and found nothing. This error is too global and doesn't explain anything to me.</p> <p>Thanks for any help and tips!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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