Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 548
  • Last Modified:

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

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.
1 Solution
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)"
[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.
cthe_artisteAuthor Commented:
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.
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).
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Tackle projects and never again get stuck behind a technical roadblock.
Join Now