Problems with MYSQL queries "Query failed : Can't lock file (errno: 116)"

Posted on 2005-04-28
Last Modified: 2008-01-09
Here is the backgroun data:

I am running phpMyAdmin 2.5.7
MySQL is 3.23.56

I do not have SSH access, I dont even have access to the local server.
All i have are applications I can develop to acess the backbone.
The backbone itself is not even cpanel so i am in a tuff bind.

I am getting a Query failed : Can't lock file (errno: 116) when I do a simple select off a table.

Here is what is odd.
when I run phpMyAdmin there is no problem: i can see the select and I can do ANYTHING I want to it

Then minute I run a php Code (update, select, insert) It refuse and it gives me a Query failed : Can't lock file (errno: 116)

Is there anything I can do?

I have tried reloading the database, it does not work
I have tried flushing the table and found out I cant flush tables.

What can I do? It has been happening recently since I have updated to phpMyAdmin 2.6.2-rc1 but because of those problems I have decided to go back to 2.5.7-pl1. I am still having the same problem.

Also the php code is simple

Connect to the database with username and password and which database.
with a mysql_connecT()
then do a $query = "SELECT * FROM database";
then do a mysql_query($query)

and it fails.
Question by:cthe_artiste
    LVL 1

    Expert Comment

    This seems more like a PHP question, rather than a MySQL question...

    Plug this in, and let us know what the error is

    $query = "SELECT * FROM database";

    $result = @mysql_query($query);
    if(! $result)
    $error = mysql_error(); // get the last error.
    print "Error executing query :: $error";

    I have a feeling you need " $result = mysql_query($query) " instead of just "mysql_query($query)"
    LVL 6

    Expert Comment

    [egor@blend egor]$ perror 116
    Error code 116:  Stale NFS file handle

    See the end of .err files in datadir of your servers, there might be a clue what's happening
    with MySQL on networking filesystems if you happen to run over it.

    Author Comment

    ok a bit on teh coding

    $query = "select * from database";
    $result = mysql_query($query) or die(Query Failed: mysql_errno());

    Thats what I use to find out that my query failed

    as I have explained I can't touch the server..its a shared hosting
    Only section of the place keeps on comming down on me like this..

    and it has to do something about locking the table...but i'm stumped and i haven't even touuch the PHP code.

    The only thing i can say is that the mysql it self is ok...because the DATABSE phpMYAdmin tells me under repair, analyze and check that everything is ok

    when i run the .php file I tell it to go look at "select * from database1" it fails
    then i do a back up copy and do "select * from database2" where the datbase 2 is the backup copy: it works.
    LVL 20

    Accepted Solution

    1.  phpmyadmin usually works as the root...
    maybe the permissions for the user you are using on  your db are set poorly.

    2.  you may also need to supply the correct ip to correct from your php server to the mysql server (as you mention this is shared hosting, then they might not be identically placed).

    3.  also you state 'then do a $query = "SELECT * FROM database";'
    You mean table "SELECT * FROM `table`" not database... and in case you're calling your table database be sure to to back-tick it (` character, same key as ~ on a en-101 kb).
    LVL 5

    Expert Comment

    Although virmaior probably nailed your problem, these are good practices in my opinion:

    When connecting, assing a resource to a variable, say $link.

    When querying, especify the resource you're using:
    $result = mysql_query($query, $link) or die(Query Failed: mysql_errno());

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
    A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi ( had suggested a “sed” way, I actually shell …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now