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

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.