Jump to content


Photo

Access denied for user 'ODBC'@'localhost'


  • Please log in to reply
4 replies to this topic

#1 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 27 July 2006 - 10:45 AM

how having some problems with regards to connecting to my mysql server.
heres the mysql class im using, www.psksoft.com check this site to see the error
my host is using php4 and mysql4

class cMysql { 
    var $_version = "1.0"; 
    var $_lastupdate = "7/17/2006"; 
    var $_author = "Arnel Labarda <err503@gmail.com>"; 
		
	function __construct () {
		//connect to host
		//if(!$this->link=mysql_connect("xxx","yyy","zzz")) {
		//if(!$this->link=mysql_connect("xxx","yyy","zzz")) {
		//if(!$this->link=mysql_connect("xxx","yyy","zzz")) {
		if(!$this->link=mysql_connect("localhost","xxx","yyy")) {
			//unable to connect
			echo "Error connecting to " . $this->server . " please check your settings.php";
			return;
	}
		//connect to database
		if (!mysql_select_db("psksoftdb",$this->link)) {
                         if (!mysql_select_db("core_db",$this->link)) {

			//unable to connect
			return;
		}
	}
	//destructors
	function __destruct () {
		mysql_close($this->link);
	}

this is really weird but this script below is working

<?php
$link = mysql_connect('localhost', 'yoshi', 'decb3f');
if (!$link)
{
   die('Could not connect: ' . mysql_error());
}
else { echo 'Connected successfully'; }
mysql_close($link);
?>

thanks
EDITED BY WILDTEEN88: REMOVED DATABASE CONNECTION INFORMATION
Registered Linux User #399942
Ubuntu User #14134
--
my blog

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 July 2006 - 10:57 AM

Class runs fine for me on PHP5. However PHP4 doesnt support the __constuct or __destruct functions. This is only supported by PHP5.

#3 unkownname

unkownname
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 27 July 2006 - 10:58 AM

I dont know if im right but try changing ODBC to something else if you notice your php code has Yoshi as user and ODBC is used by mysql so yah its a command in mysql system thats my thout though that and you should take off your password if that is it.

#4 vbnullchar

vbnullchar
  • Members
  • PipPipPip
  • Advanced Member
  • 428 posts
  • LocationPasig City, Philippines

Posted 27 July 2006 - 11:05 AM

Class runs fine for me on PHP5. However PHP4 doesnt support the __constuct or __destruct functions. This is only supported by PHP5.


hmmm, I see. thanks...

Registered Linux User #399942
Ubuntu User #14134
--
my blog

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 27 July 2006 - 11:09 AM

I probably should of said this earlier but you can create a constructor for PHP4. In order to do so you'll have to create a function with the same name as your class so rather than doing:
function __construct () {
To declare your constructor, you do this for PHP4:
function cMysql() {
Now PHP4 will automatically run the cMySQL function when you create a new instance of your class. However I'm not sure about a PHP4 equivalent to a destructor.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users