vbnullchar Posted July 27, 2006 Share Posted July 27, 2006 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 errormy 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] Quote Link to comment https://forums.phpfreaks.com/topic/15794-access-denied-for-user-odbclocalhost/ Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 Class runs fine for me on PHP5. However PHP4 doesnt support the __constuct or __destruct functions. This is only supported by PHP5. Quote Link to comment https://forums.phpfreaks.com/topic/15794-access-denied-for-user-odbclocalhost/#findComment-64583 Share on other sites More sharing options...
unkownname Posted July 27, 2006 Share Posted July 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15794-access-denied-for-user-odbclocalhost/#findComment-64584 Share on other sites More sharing options...
vbnullchar Posted July 27, 2006 Author Share Posted July 27, 2006 [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... Quote Link to comment https://forums.phpfreaks.com/topic/15794-access-denied-for-user-odbclocalhost/#findComment-64588 Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/15794-access-denied-for-user-odbclocalhost/#findComment-64590 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.