Jump to content

Stupid Error 1064 - Please Help!


lbravo

Recommended Posts

Hello,

 

I've got an error 1064, and I know that means I've misused a reserved word, but for the life of me, I can't see it.

 

Does anyone see what's wrong with this?

for ($i=0, $n=sizeof($this->products); $i<$n; $i++) {
$db->Execute('UPDATE products_licences SET orders_id='.$zf_insert_id
. ' WHERE products_id='.$this->products[$i]['id']
. ' AND orders_id IS NULL'
. ' LIMIT '.$this->products[$i]['qty']
);
$dbres = $db->Execute("SELECT licences_code FROM products_licences"
. " WHERE products_id=".$this->products[$i]['id']
. " AND orders_id=".$zf_insert_id
);

 

And here's the error message -

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 ':7b8c4c37c00e45716db5456927e5ca75 AND orders_id IS NULL LIMIT 1' at line 1

in:

[uPDATE products_licences SET orders_id=30 WHERE products_id=12:7b8c4c37c00e45716db5456927e5ca75 AND orders_id IS NULL LIMIT 1]

 

I'm using MySQL 5.0.32-Debian_7etch3-log, Apache 2, and Debian Linux.

 

Here's the table:

CREATE TABLE `products_licences` (
    ->   `licences_id` int(10) unsigned NOT NULL auto_increment,
    ->   `products_id` int(10) unsigned NOT NULL default '0',
    ->   `products_attributes_id` int(10) unsigned default NULL,
    ->   `licences_code` varchar(250) NOT NULL default '',
    ->   `orders_id` int(10) unsigned default NULL,
    ->   PRIMARY KEY  (`licences_id`),
    ->   KEY `product_id` (`products_id`,`orders_id`),
    ->   KEY `product_attributs_id` (`products_attributes_id`)
    -> ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 

 

Thanks in advance!

 

LBravo

Link to comment
Share on other sites

I'm still having difficulties with this --  I added quotes to the '$i' variable, and now I get this 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 'AND orders_id IS NULL LIMIT' at line 1

in:

[uPDATE products_licences SET orders_id=37 WHERE products_id= AND orders_id IS NULL LIMIT ]

 

Once again, here's the updated code:

 

   $db->Execute('UPDATE products_licences SET orders_id='.$zf_insert_id
                       . ' WHERE products_id='.$this->products['$i']['id']
                           . ' AND orders_id IS NULL'
                           . ' LIMIT '.$this->products['$i']['qty']
                       );
          $dbres = $db->Execute('SELECT licences_code FROM products_licences'
                       . ' WHERE products_id='.$this->products['$i']['id']
                           . ' AND orders_id='.$zf_insert_id
                       ); 

 

Sorry I'm being such a dolt today... I appreciate any help for sure!

 

LBravo

Link to comment
Share on other sites

Sorry, I meant the entire variable... that is, the string literal you're producing -- switch to double-quotes for the php string, singles for mysql strings:

  $db->Execute("UPDATE products_licences SET orders_id='".$zf_insert_id."'"
                       . " WHERE products_id='".$this->products[$i]['id']."'"
                           . " AND orders_id IS NULL"
                           . " LIMIT ".$this->products[$i]['qty']

Link to comment
Share on other sites

Hi!  Thanks so much for trying to help me!

 

I've modified the code to match what you suggested, but I'm still getting an 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 ':7b8c4c37c00e45716db5456927e5ca75 AND orders_id IS NULL' at line 1

in:

[sELECT count(*) AS count FROM products_licences WHERE products_id=12:7b8c4c37c00e45716db5456927e5ca75 AND orders_id IS NULL]

 

Here's the modified code:

$db->Execute("UPDATE products_licences SET orders_id='".$zf_insert_id."'"
                       . " WHERE products_id='".$this->products[$i]['id']."'"
                           . " AND orders_id IS NULL"
                           . " LIMIT ".$this->products[$i]['qty']
					   );
          $dbres = $db->Execute('SELECT licences_code FROM products_licences'
                       . " WHERE products_id='".$this->products[$i]['id']."'"
                           . " AND orders_id=".$zf_insert_id
                       ); 

 

I've been working on this for more than a week, and my nerves are starting to fray....

 

LOL - thanks again!

Link to comment
Share on other sites

You need to fix the second order_id... I didn't give you that one...

 

$dbres = $db->Execute('SELECT licences_code FROM products_licences'
                       . " WHERE products_id='".$this->products[$i]['id']."'"
                           . " AND orders_id='".$zf_insert_id."'"
                       ); 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.