Jump to content

MySQL connect through Perl DBI or the Mysql.pm module


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".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.