User login

Always check for "if ($foo = 'bar')" mistakes... red flag, needs ==

Always look for malformed equality statements, that assign rather than compare, when things are going weird. Earlier rather than later. That's the whole lesson for today.

So why is the select statement, that's supposed to prevent this mess below, not working?

SELECT content_id FROM {cmt_term_node} WHERE nid=%d AND tid=%d

Debugging looks all good:

* term Another versus Another
* SELECT content_id FROM {cmt_term_name} WHERE tid=%d AND name='%s'
* Result: Resource id #91
*

stdClass Object
(
[content_id] => 23
)

* SELECT content_id FROM {cmt_term_node} WHERE nid=%d AND tid=%d
* Result: Resource id #99
*

stdClass Object
(
[content_id] => 10
)

So why/how the hell is it calling the insert statement?

AAAAAAAUUUUUUGGGGGGHHHHHHHHH!

if ($return = 'INSERT') {

NO NO NO NO NO NO NO NO NO. Text editors or PHP parsers should help us mere mortals pick this stuff up! Argh Argh Argh! SQL uses single equals sign for comparision-- PHP must have at least two!

Half a night wasted, but it should work now...

if ($return == 'INSERT') {

user warning: Duplicate entry '18-5' for key 2 query: cmt_term_attribute_set INSERT INTO joe_cmt_term_node (nid, tid) VALUES (5, 18) in /Applications/MAMP/htdocs/joeaustin/includes/database.mysql.inc on line 172.
trigger_error /Applications/MAMP/htdocs/joeaustin/includes/database.mysql.inc: 172 Duplicate entry '18-5' for key 2 query: cmt_term_attribute_set INSERT INTO joe_cmt_term_node (nid, tid) VALUES (5, 18), 512
_db_query /Applications/MAMP/htdocs/joeaustin/includes/database.inc: 200 INSERT INTO joe_cmt_term_node (nid, tid) VALUES (5, 18)
db_query /Users/ben/workspace/drupalcvs/contributions/modules/cmt/cmt.module: 655 INSERT INTO {cmt_term_node} (nid, tid) VALUES (%d, %d), 5, 18
cmt_term_attribute_set /Users/ben/workspace/drupalcvs/contributions/modules/cmt/cmt.module: 500

Array
(
[value] => 5
[field] => nid
)

,

Array
(
[value] => 18
[field] => tid
)

, cmt_term_node
cmt_new_term_form_submit cmt_new_term_form,

Array
(
[op] => Create term
[submit] => Create term
[nid] => 5
[vid] => 15
[form_token] => 0d13a143d2670d22ef625d19b0001c22
[form_id] => cmt_new_term_form
[preview] =>
)

Agaric Design will, collectively, deny ever making any such mistake.

Always look for malformed equality statements, that assign rather than compare, when things are going weird. Earlier rather than later. That's the whole lesson for today.

So why is the select statement, that's supposed to prevent this mess below, not working?

SELECT content_id FROM {cmt_term_node} WHERE nid=%d AND tid=%d

Debugging looks all good:

* term Another versus Another
* SELECT content_id FROM {cmt_term_name} WHERE tid=%d AND name='%s'
* Result: Resource id #91
*

stdClass Object
(
[content_id] => 23
)

* SELECT content_id FROM {cmt_term_node} WHERE nid=%d AND tid=%d
* Result: Resource id #99
*

stdClass Object
(
[content_id] => 10
)

So why/how the hell is it calling the insert statement?

AAAAAAAUUUUUUGGGGGGHHHHHHHHH!

if ($return = 'INSERT') {

NO NO NO NO NO NO NO NO NO. Text editors or PHP parsers should help us mere mortals pick this stuff up! Argh Argh Argh! SQL uses single equals sign for comparision-- PHP must have at least two!

Half a night wasted, but it should work now...

if ($return == 'INSERT') {

user warning: Duplicate entry '18-5' for key 2 query: cmt_term_attribute_set INSERT INTO joe_cmt_term_node (nid, tid) VALUES (5, 18) in /Applications/MAMP/htdocs/joeaustin/includes/database.mysql.inc on line 172.
trigger_error /Applications/MAMP/htdocs/joeaustin/includes/database.mysql.inc: 172 Duplicate entry '18-5' for key 2 query: cmt_term_attribute_set INSERT INTO joe_cmt_term_node (nid, tid) VALUES (5, 18), 512
_db_query /Applications/MAMP/htdocs/joeaustin/includes/database.inc: 200 INSERT INTO joe_cmt_term_node (nid, tid) VALUES (5, 18)
db_query /Users/ben/workspace/drupalcvs/contributions/modules/cmt/cmt.module: 655 INSERT INTO {cmt_term_node} (nid, tid) VALUES (%d, %d), 5, 18
cmt_term_attribute_set /Users/ben/workspace/drupalcvs/contributions/modules/cmt/cmt.module: 500

Array
(
[value] => 5
[field] => nid
)

,

Array
(
[value] => 18
[field] => tid
)

, cmt_term_node
cmt_new_term_form_submit cmt_new_term_form,

Array
(
[op] => Create term
[submit] => Create term
[nid] => 5
[vid] => 15
[form_token] => 0d13a143d2670d22ef625d19b0001c22
[form_id] => cmt_new_term_form
[preview] =>
)

Agaric Design will, collectively, deny ever making any such mistake.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.