Jump to content

Access denied for user 'ODBC'@'localhost'


vbnullchar

Recommended Posts

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

[code]class cMysql {
    var $_version = "1.0";
    var $_lastupdate = "7/17/2006";
    var $_author = "Arnel Labarda <[email protected]>";

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);
}[/code]

this is really weird but this script below is working

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

thanks
[b]EDITED BY WILDTEEN88: REMOVED DATABASE CONNECTION INFORMATION[/b]
Link to comment
https://forums.phpfreaks.com/topic/15794-access-denied-for-user-odbclocalhost/
Share on other sites

[quote author=wildteen88 link=topic=102053.msg404473#msg404473 date=1153997849]
Class runs fine for me on PHP5. However PHP4 doesnt support the __constuct or __destruct functions. This is only supported by PHP5.
[/quote]

hmmm, I see. thanks...
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:
[code]function __construct () {[/code]
To declare your constructor, you do this for PHP4:
[code]function cMysql() {[/code]
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.

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.