Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

php/mysql get_lock problem

78 views
Skip to first unread message

therflin

unread,
Jul 22, 2009, 9:44:35 AM7/22/09
to
Hi,
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)
and
it works providing the expected result (see http://i30.tinypic.com/10oqlhg.jpg)
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
configured....

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:
".mysql_error());

function testit ($q) {
echo "Query: <b>" . $q . "</b><br>\n";
$r=mysql_query($q);
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)
RESULT:
ERROR (1146): Table 'mysql.proc' doesn't exist

C. (http://symcbean.blogspot.com/)

unread,
Jul 22, 2009, 12:14:52 PM7/22/09
to
On Jul 22, 2:44 pm, therflin <therf...@gmail.com> wrote:
> Hi,
> 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)
> and
> it works providing the expected result (seehttp://i30.tinypic.com/10oqlhg.jpg)

> 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
> configured....
>
> Any help is really appreciated.

hat immediately springs to mind is the difference between localhost
and 127.0.0.1 - i.e. connecting via an internet socket and filesystem
socket. I suspect that if you replicate the connection type from
phpmyadmin in your PHP code, it will work (or check the procs_priv,
db, user and host tables in the mysql database)

C.

Jerry Stuckle

unread,
Jul 22, 2009, 2:33:51 PM7/22/09
to

Please don't multipost. If you have to post to multiple newsgroups,
please crosspost.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

therflin

unread,
Jul 22, 2009, 4:49:51 PM7/22/09
to
On 22 Lug, 20:33, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> therflin wrote:
> > Hi,
> > 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)
> > and
> > it works providing the expected result (seehttp://i30.tinypic.com/10oqlhg.jpg)
> jstuck...@attglobal.net
> ==================

I tried to provide to mysql_connect both localhost and 127.0.0.1
but I got the same problem.

Very strangely when connecting locally (using mysql client) (with and
without -h option)
I had the first time the error while all the other tests (even
repeating the failing test) it worked...

But from PHP it didn't work ever...

Jerry Stuckle

unread,
Jul 22, 2009, 6:40:30 PM7/22/09
to

As I said - please do not multipost! Crosspost instead.

This is being discussed in comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

jstu...@attglobal.net
==================

0 new messages