Joe Stuart wrote:
>
> I'm having problems with the Mysql.pm module. When I have the two
> statements
>
> $dbh = Mysql->connect($host,$database,$username,$password);
> my $sth = $dbh->query("insert into users values(NULL, 'Jon',
> 'Sterling', 'Doe', 24, '[EMAIL PROTECTED]')");

You don't need to escape the 'at' with single quotes - only with
double ones.

> My problem is when I run it as root it works fine, but when I run it as
> a regular user I get

Clue: this must eb a permissions problem!

> Mysql connect('database=userdb;host=localhost','joe_stuart',...)
> failed: Can't connect to local MySQL server through socket
> '/var/lib/mysql/mysql.sock' (13) at ./SendQuery.pl line 43

... so the Mysql->connect call returns 'undef', causing ...

> Can't call method "query" on an undefined value at ./SendQuery.pl line
> 81.

First of all, check the return from the 'connect' call:

  $dbh = Mysql->connect($host,$database,$username,$password)
      or die Mysql->errmsg;

and, depending on the error message, talk to your sysadmin about
access to the database.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to