Jump to content

Archived

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

vbnullchar

Access denied for user 'ODBC'@'localhost'

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

Share this post


Link to post
Share on other sites
Class runs fine for me on PHP5. However PHP4 doesnt support the __constuct or __destruct functions. This is only supported by PHP5.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.