Jump to content

MySQL connect through Perl DBI or the Mysql.pm module


timmah1

Recommended Posts

How do you do this?

 

I have this:

<?

$host = "localhost";
$user = "xx";
$password = "xx";
$database   = "xx";


$db = Mysql->connect($host, $user, $password, $database);

if ( !$db )
{
echo "Error connecting to database.\n";
}


mysql_select_db($db);
?>

 

Which gives me the error

Parse error: parse error, unexpected T_OBJECT_OPERATOR in /home/www/canadianva/member/config.php on line 12

Line 12 is: $db = Mysql->connect($host, $user, $password, $database);

 

What's wrong?

 

Thanks in advance

mysql_connect is a function, not a method inside of an object.

 

<?php

$host = "localhost";
$user = "xx";
$password = "xx";
$database   = "xx";

$db = mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db($database, $db) or die(mysql_error());

?>

 

Of course, that assumes that you are not using a database abstraction class and you have created an object named "mysql" and you are calling a method called "connect"....if you are trying to do that, then you need a "$" in front of the "Mysql".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.