Weird PHP + MySQL resource error

    Date: 03/08/07 (PHP Community)    Keywords: php, mysql, sql, google

    Using PHP 5.2.1 on a windows command (cli) environment I ran into a really weird bug about two days ago. Using xdebug to step through my code, the 'mysql link' resource becomes partially corrupted. What I mean is: it's still a resource, it still has the same id #, but the type shifts to 'Unknown'. I've run extensive searches through the code for all mention of the link resource variable but the only assignment is when it's set with mysql_connect(). This passed through pretty much every safety check (! null, is_resource, isset() ) and into mysql_ library functions. So I kept getting warnings saying to the effect '15 is not a valid mysql link resource' that then cascaded into errors about 1000 ticks afterwards.


    So my question, has anyone heard of this happening, I've rummaged through php.net bugzilla and also googled, but have come up empty.

    Pre-answers: the entire environment is dedicated to this script
    php.ini: all mysql limits are set to -1.
    The script is a daily cronscript.
    At ramp up, the script balloons to 192MB-240MB and 99.9% cpu utilization for the entire duration of the script which is fine because this all will be running on a dedicated machine that will be running idle when this thing executes.


    The solution I came up with, is that when mysql_real_escape_string returns false, unset the resource, then reassign it from mysql_connect() then try 1 more time before throwing an exception.

    Source: http://community.livejournal.com/php/549713.html

« false positive with... || PECL imagick on OS X »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home