timmah1 Posted January 16, 2008 Share Posted January 16, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/86345-mysql-connect-through-perl-dbi-or-the-mysqlpm-module/ Share on other sites More sharing options...
hitman6003 Posted January 17, 2008 Share Posted January 17, 2008 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". Quote Link to comment https://forums.phpfreaks.com/topic/86345-mysql-connect-through-perl-dbi-or-the-mysqlpm-module/#findComment-441561 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.