Thread: [Phplib-users] Access denied, 2 databases, extrange error
Brought to you by:
nhruby,
richardarcher
From: 3s <3s...@se...> - 2002-07-31 11:31:32
|
Hi, my first message to the list. I was using for 3 years ago DB classes from PHPLIB without problems, until now. Normally we use the library with one database only, but in one of my projects I need to connect to different databases (MySql), with different servers and different users. Only in one point the system is showing me the error, in other places works ok, but suspect that I have good look and I doing something wrong. In the browser after the last </html> label shows the following error: Access denied for user: 'pro...@21...' to database 'portal' The scritps makes all needed tasks, connect to 2 different databases, one internal and one external, with different users, prepare the results and shows correctly in the screen. I use different extensions for the db_mysql class: tbl, tbl2, and so on. Every extension has their own properties for database, user, etc. And I make instances of this classes into the functions. I suspect that the problem must be related to: 1st- the user must be probando@213.96.113.210, but for some reason appears in the way pro...@21... 2nd- its trying to connect to the database 'portal' with the wrong user, must be prueba@localhost I tried to debug when makes connections, queries and free the results, but doesnt shows else, during the execution of the script, only when PHP its finishing. Anybody can help me? Regards, Jose Valle -- 3s <3s...@se...> |
From: Donncha O C. <don...@tr...> - 2002-07-31 11:39:14
|
This has been a bug that plagued me several times in the past. To fix it = just=20 make sure that each database connection has a different user. Donncha. On Wednesday 31 July 2002 12:33, 3s wrote: > Hi, > > my first message to the list. > > I was using for 3 years ago DB classes from PHPLIB without problems, > until now. > > Normally we use the library with one database only, but in one of my > projects I need to connect to different databases (MySql), with differe= nt > servers and different users. Only in one point the system is showing me > the error, in other places works ok, but suspect that I have good look > and I doing something wrong. > > In the browser after the last </html> label shows the following error: > > Access denied for user: 'pro...@21...' to > database 'portal' > |
From: <wo...@sw...> - 2002-07-31 12:10:59
|
I ran into a similar problem a while back an made a permanent fix to the code to solve this. The changes are simple and benign and located in db_mysql.inc. I have posted this before and request that the changes get migrated into CVS, but I don't think it ever happened. Here is a diff of the orginal file and my changes: [woodbri@linus php]$ diff db_mysql.inc db_mysql.inc.save 80,83c80,83 < # if (!@mysql_select_db($Database,$this->Link_ID)) { < # $this->halt("cannot use database ".$this->Database); < # return 0; < # } --- > if (!@mysql_select_db($Database,$this->Link_ID)) { > $this->halt("cannot use database ".$this->Database); > return 0; > } 117c117 < $this->Query_ID = @mysql_db_query($this->Database, $Query_String,$this->Link_ID); --- > $this->Query_ID = @mysql_query($Query_String,$this->Link_ID); 185c185 < $res = @mysql_db_query($this->Database, $query, $this- >Link_ID); --- > $res = @mysql_query($query, $this->Link_ID); 196c196 < $res = @mysql_query("unlock tables", $this->Link_ID); --- > $res = @mysql_query("unlock tables"); 244c244 < $id = @mysql_db_query($this->Database, $q, $this->Link_ID); --- > $id = @mysql_query($q, $this->Link_ID); 254c254 < $id = @mysql_db_query($this->Database, $q, $this->Link_ID); --- > $id = @mysql_query($q, $this->Link_ID); 263c263 < $id = @mysql_db_query($this->Database, $q, $this->Link_ID); --- > $id = @mysql_query($q, $this->Link_ID); HTH, -Steve On 31 Jul 2002 at 12:39, Donncha O Caoimh wrote: > This has been a bug that plagued me several times in the past. To fix it just > make sure that each database connection has a different user. > > Donncha. > > On Wednesday 31 July 2002 12:33, 3s wrote: > > Hi, > > > > my first message to the list. > > > > I was using for 3 years ago DB classes from PHPLIB without problems, > > until now. > > > > Normally we use the library with one database only, but in one of my > > projects I need to connect to different databases (MySql), with different > > servers and different users. Only in one point the system is showing me > > the error, in other places works ok, but suspect that I have good look > > and I doing something wrong. > > > > In the browser after the last </html> label shows the following error: > > > > Access denied for user: 'pro...@21...' to > > database 'portal' > > > > > ------------------------------------------------------- > This sf.net email is sponsored by: Dice - The leading online job board > for high-tech professionals. Search and apply for tech jobs today! > http://seeker.dice.com/seeker.epl?rel_code1 > _______________________________________________ > Phplib-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phplib-users > |
From: 3s <3s...@se...> - 2002-08-01 07:42:11
|
Hi, after checking the proposals from woodbri and Donncha, still not working and I'm thinking that the problem must be solve in other way. Because its a conceptual matter possibly. The main problem, I think, it is the way I use PHPLIB into my applications. I'm not an OOP master obviouslly, will try to explain you, if you can sugest a better approach I'll appreciate very much your advice. Applications are build in many layers: 1-index page, load general modules, make security tasks and if all goes well, load the requested page, if not redirect to the home page 2-Page that calls, has their own code for make specific tasks calling to other modules: 3-db classes, one db class for every table or group of tables, including their own common methods for insert, update, etc in every class 4-template 5-layout 5a-layout calls other pages or modules needed for it own What is the problem? I make a new instance of the main db class in every method of every class that manage tables. Example: class categories extends pageNavigation { function categories(){ //calls to libs, language error files, etc } function add($array){ // HERE IT IS THE PROBLEM------------------------------------ // extension of the db_sql class with their own connection // parameters $q= new tbl; //----------------------------------------------------------- $query="insert into categories set bla, bla"; if(!$q->query($query)){ $this->error=$this->msg['NOCONNECTION']; return; } return TRUE; } } What is the advantage? every class for table manage, has their code very well enclosed and can be changed little by little. Every table class has also a constructor for call common libs, language files, etc. I have two different possibilities, change all my code to implement a new solution around PHPLIB db class or migrate to other database library and make a lot of work also. Regards, -- 3s <3s...@se...> |
From: Donncha O C. <don...@tr...> - 2002-08-01 09:15:17
|
On Thursday 01 August 2002 08:43, 3s wrote: > Hi, > > after checking the proposals from woodbri and Donncha, still not workin= g > and I'm thinking that the problem must be solve in other way. Because > its a conceptual matter possibly. > [snip] > =093-db classes, one db class for every table or group of > =09tables, including their own common methods for insert, update, > =09etc in every class If you did change the username used by each db class and still got that e= rror=20 there's something really strange going on.=20 I presume you have setup MySQL correctly, that the usernames you chose do= have=20 permission to access those tables, that your webserver can talk to the My= SQL=20 server, etc. Have you tried googling for an answer? Donncha. |
From: 3s <3s...@se...> - 2002-08-01 09:32:11
|
Hi Donncha, yes I was looking for an answer from yesterday, but without no luck. The system is working, connect and get results from the different databases, and shows correctly but the only problem its the error when finishing after the </html> label. As I said previously I suspect that this error occurs when PHP try to finish the conection, but I have no idea why its mixing conection details from the different classes. I maked all the changes proposed: use different users, put the database name in the query, etc. I was seeing in the forums a lot of problems to manage multiple connections with PHPLIB, ADODB and others, none of then seems suitable for this purpose. That is the reason to look for a different approach, OOP approach, because I'm not an expert in this way and possibly must be a better way to do it. Regards, Jos=E9 Valle On/El Thu, 1 Aug 2002 10:15:08 +0100 Donncha O Caoimh <don...@tr...> wrote/escribi=F3: > If you did change the username used by each db class and still got that e= rror=20 > there's something really strange going on.=20 > I presume you have setup MySQL correctly, that the usernames you chose do= have=20 > permission to access those tables, that your webserver can talk to the My= SQL=20 > server, etc. >=20 > Have you tried googling for an answer? >=20 > Donncha. >=20 --=20 3s <3s...@se...> |
From: Giancarlo <gia...@na...> - 2002-08-01 10:45:05
|
> > The system is working, connect and get results from the different > databases, and shows correctly but the only problem its the error when > finishing after the </html> label. As I said previously I suspect that > this error occurs when PHP try to finish the conection, but I have no > idea why its mixing conection details from the different classes. > > I maked all the changes proposed: use different users, put the database > name in the query, etc. > Did you try to disable mysql persistent connections? it can be done via htaccess, php ini, or in the script top. Gian |