php/mysql get_lock problem

I'm implementing a locking mechanism with MySQL 5.0.36 and PHP 5.2.1
by means of the SQL statement
SELECT GET_LOCK ('lockname', timeout)

If I simply run the SQL statement from phpadmin (same user, same db)
it works providing the expected result (see
but If I run it from php/mysql I'm getting the error 1146 - Table
'mysql.proc' doesn't exist.

Initially I went through the MySQL forums and docs and found that it
is a known problem in case of migrations from previous versions of
MySQL but then I tested through the phpadmin and in that case it
worked... which would mean to me that the mysql-db is properly

Any help is really appreciated.

Here is the sample code :

$db = mysql_connect($host,$user,$password) or die ("DB connection
error: ".mysql_error());
mysql_select_db($db_name, $db) or die ("DB selection errore:

function testit ($q) {
echo "Query: <b>" . $q . "</b><br>\n";
print "RESULT: " .$r ."<br>\n";
print "ERROR (" . mysql_errno() . "): " .mysql_error() ."<br><hr>\n";

testit ("SELECT * from events");
testit ("SELECT GET_LOCK ('events.test', 20)");

which outputs the following:

Query: SELECT * from events
RESULT: Resource id #4
ERROR (0):
Query: SELECT GET_LOCK ('events.test', 20)
ERROR (1146): Table 'mysql.proc' doesn't exist