Ok guys i got this problem here: I got a class i made that creates a link ressource for a mysql database. Stores it inside of itself with different login and password and other params. Other functions are also available for usage.
When i start this class it connects fine, i can also use it no problem. BUT...At one point i start referencing this object to other objects so they can use one and only one connection. If one of these alternate objects using the connection does an error, i can NO PROBLEM get the mysql_error() using the link ressource from inside the alternate object. If i try to get the error from outside that object in my top level script lets say, i use the one and only mysql_connection object and it still fails. it's like it doesn't see the error. (I think it's because the object is being copied, but i looked at my script several times and i never see any copy.) My only guess is that a mysql_link resssource is also an object and gets copied or lost somewhere in the middle. Can anybody tell me what i could do??? (PS i didn't post all the source and the real login info...tehre is too much to paste and also, it's too improtant to reveal anything) SOURCE: class mysql_connection{ //Variables var $mysql_link; var $mysql_username; var $mysql_password; var $mysql_database; //Constructor(Establishes the connection) function mysql_connection($hostname, $username, $password, $database){ //Connection to database $this->mysql_link = mysql_connect("$hostname", "$username", "$password"); if(!$this->mysql_link){ //Display an error message exit("Error connecting to mysql server, contact web administrator or try again later!"); } //Select the database if(!mysql_select_db("$database", $this->mysql_link)){ //Display an error message exit("Error selecting database on mysql server, contact web administrator or try again later!"); } } } class arenas{ //System objects var $mysql_server; var $item; //Variables/Arrays var $indexes = array(); var $curindex = 0; //Constructor function arenas(&$mysql_server){ //Store the server $this->mysql_server = &$mysql_server; //Build the index $this->refresh(); } } $mysql_server = new mysql_connection("localhost", "username", "password", "database"); //Get the arenas and the current item $arenas = new arenas($mysql_server); //At this point i would do a sql query from inside my arenas class that would raise an error //If i echo the error from inside the class using //echo mysql_error($this->mysql_server->mysql_link); //it works //if i echo from the script itself like here it doesn't work echo mysql_error($mysql_server->mysql_link); //The first one will show something, the second will never show the error, any clue why? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php