Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL connection failing on same query. Trying to reconnect with default user
    primarykey
    data
    text
    <p>I am getting the following error on the same query: Warning: mysql_query(): Access denied for user 'www-data'@'localhost' (using password: NO)</p> <p>The error only occurs on the first try from any particular IP. After I refresh the page, the script runs fine. To be more specific, I will run it from a browser in one location, and it will error. If I refresh the page, the problem is fixed. That is until I try from another location.</p> <p>From what I gather, its losing the connection to the database server and trying to reconnect with the default username. What's confusing me is that it fails on the same query each time. Let's call this query_X. Multiple queries run before query_X including selects, inserts, and updates. Query_X looks like this:</p> <pre><code>UPDATE game_users SET status_cd=$tmp_status, expire_date=date_add('$currentExpire', interval $l_license_duration_days day) WHERE game_user_id=$l_game_user_id </code></pre> <p>As an example, the variables being passed are:</p> <pre><code>$tmp_status = 1; $currentExpire = '2011-12-05'; $l_license_duration_days = 30; $l_game_user_id = 1; </code></pre> <p>What is it about this query that makes the connection fail, and why does refreshing the page fix the problem?</p> <p>Fyi, I'm using persistent connect.</p> <p>Edit: I just tried again from an ip that I tried last night. And I received the error again. That is on the first run of the script. After I ran the page a second time, it worked fine.</p> <p>Edit: It will also error the first time it's run on a particular browser, even if it is on the same IP, i.e. it will error once on firefox and then be fine, error on chrome once and then be fine, etc.</p> <p>Edit: I've narrowed it down to a mail() function that was happening just before query_X. I still don't know why the mail function is closing the mySQL connection. I've decided to put the mail function (which works properly and sends the email) at the end of the php file, where I would close the connection anyways. It's a hack, but I've spent too much time on this already.</p>
    singulars
    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