{"id":88,"date":"2008-10-12T13:46:00","date_gmt":"2008-10-12T18:46:00","guid":{"rendered":"http:\/\/osric.com\/chris\/accidental-developer\/?p=88"},"modified":"2009-04-09T10:12:30","modified_gmt":"2009-04-09T15:12:30","slug":"weird-little-mysql-error","status":"publish","type":"post","link":"https:\/\/osric.com\/chris\/accidental-developer\/2008\/10\/weird-little-mysql-error\/","title":{"rendered":"Weird little MySQL error."},"content":{"rendered":"<p><a href=\"https:\/\/osric.com\/chris\/accidental-developer\/wp-content\/uploads\/2008\/10\/logo_mysql_sun.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-92\" title=\"logo_mysql_sun\" src=\"https:\/\/osric.com\/chris\/accidental-developer\/wp-content\/uploads\/2008\/10\/logo_mysql_sun.gif\" alt=\"\" width=\"205\" height=\"68\" \/><\/a>So I just moved some code onto a new server, and I&#8217;m suddenly getting the warning:<\/p>\n<p>mysql_query(): 14 is not a valid MySQL-Link resource in &lt;bla bla bal&gt; on line 47<\/p>\n<p>A few other people seem to have gotten this error, but no one has posted a solution. (though one guy oh-so-annoyingly posted &#8220;I figured it out, so never mind&#8221; &#8230; Grrr. I mean, if you&#8217;re going to post a question, the answer should be in that thread if you ever figure it out&#8230;.<\/p>\n<p>So as soon as I figure out the answer I&#8217;m going to post it here.<\/p>\n<p><span style=\"color: #800000;\"><strong>I&#8217;m back with the solution:<\/strong><\/span><\/p>\n<p><span style=\"color: #800000;\">I got clued onto it from this page: http:\/\/bytes.com\/forum\/thread638479.html . The error is coming because mysql_close was being called by the destructor, and because I was in safe mode the same MySQL resource was being used for each instance. What threw me even more though was that the destructor was being called at all, because I thought I only _had_ one instance. Turns out that there is a spot in my code where I (accidentaly) passed my DB object by value rather than refrence. This made a new copy of the object, which ran mysql_connect again, because it was in safe mode it returened the _same_ refrence. Then the object got unloaded, the destructor ran and closed the refrence, even though there was another instance of the object out there still using the same refrence. <\/span><\/p>\n<p><span style=\"color: #800000;\">Icky!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I just moved some code onto a new server, and I&#8217;m suddenly getting the warning: mysql_query(): 14 is not a valid MySQL-Link resource in &lt;bla bla bal&gt; on line 47 A few other people seem to have gotten this error, but no one has posted a solution. (though one guy oh-so-annoyingly posted &#8220;I figured &hellip; <a href=\"https:\/\/osric.com\/chris\/accidental-developer\/2008\/10\/weird-little-mysql-error\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Weird little MySQL error.<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[36,352],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-php","tag-mysql","tag-php"],"_links":{"self":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":5,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":90,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/posts\/88\/revisions\/90"}],"wp:attachment":[{"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osric.com\/chris\/accidental-developer\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}