Re: AGONIZING Mysql Select DB issue.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Agreed, sounds like a pain. to keep two copies. But if you do it to both 
copies, and use the same code both places (connect via URL, not 'localhost' 
even if you are on the same machine) then it wouldn't be any extra trouble.

The OS will realize that the URL is localhost and make that connection via a 
socket anyways.

Something else to check; if you're using two logins, one for remote, one for 
local, verify that their database permissions are the same.

-Micah




On Monday 18 August 2003 8:11 am, you wrote:
> The worst thing is that The SAME CODE that is used to connect via
> 'localhost' on the server that holds the MYSQL installation works fine. Why
> the heck does it work locally but not via a server to server connection?  I
> keep a code pool for several sites, I don't want to have to do a
> search/replace and keep two versions of my code on each server. That is a
> pain in the arse.
>
> On 8/18/03 11:05 AM this was written:
> > Just do a global search/replace on the table names.
> >
> > *shrug* should do the trick.
> >
> > On Monday 18 August 2003 6:21 am, you wrote:
> >> As I mentioned your suggestion here does work, however while the example
> >> was simple, the application is very extensive and changing every SQL
> >> call is not possible.
> >>
> >> On 8/17/03 4:56 PM this was written:
> >>> Try using the SQL to select which database.
> >>>
> >>> example, instead of:
> >>>
> >>> select * from table1
> >>>
> >>> use:
> >>>
> >>> select * from database1.table1
> >>>
> >>> if that works, and the php command doesn't that may mean the the mysql
> >>> client lib is broken, although, I've been using it with mysql 4 and it
> >>> seems to work fine.
> >>>
> >>> -Micah
> >>>
> >>> On Sunday 17 August 2003 1:49 pm, Thomas Deliduka wrote:
> >>>> I'm not making two connections, I'm making one and only one call to
> >>>> mysql_connect.  Also, there is no way in that function as per the
> >>>> definition page of it (http://us3.php.net/mysql_connect) to have the
> >>>> database selected as per your example below.
> >>>>
> >>>> With my connection though, when I do:
> >>>> $dbh = Mysql_connect(blah, blah, blah)
> >>>> Mysql_select_db("db1")
> >>>>
> >>>> I do call:
> >>>> Mysql_query("query", $dbh);
> >>>>
> >>>> For some reason even though I am calling mysql_select_db("db1") it is
> >>>> latching onto the first available database it has access to (or not as
> >>>> the case/permissions may be) and chooses "db2" instead.
> >>>>
> >>>> I don't know why, connecting to the MySQL 3.23 it selects the right
> >>>> database, connecting to the Mysql 4.x server it doesn't allow a
> >>>> selecting of the table even though I do the select function and it
> >>>> returns true as it was selected properly.
> >>>>
> >>>> On 8/16/03 12:23 AM this was written:
> >>>>> If you are doing this:
> >>>>>
> >>>>> $dbh = mysql_connect("db1", blah blah blah);
> >>>>> $dbh2 = mysql_connect("db2", blah blah blah);
> >>>>>
> >>>>> Then
> >>>>>
> >>>>> $r = mysql_query("select * from mytable");
> >>>>>
> >>>>> will use the db2 connection, because it is the most recent.  However,
> >>>>> if you do this:
> >>>>>
> >>>>> $r = mysql_query("select * from mytable", $dbh);
> >>>>>
> >>>>> it will use the first connection, as specified in the handle that is
> >>>>> passed back by mysql_connect.  mysql_query uses the most recent
> >>>>> connection by default; you can override this action by specifying
> >>>>> which DB handle to use for a given query.  Replace $dbh with $dbh2 to
> >>>>> select from tables on the second database.
> >>>>>
> >>>>> Peter
> >>>>>
> >>>>> On Fri, 15 Aug 2003, Thomas Deliduka wrote:
> >>>>>> Here's the stats:
> >>>>>>
> >>>>>> Two servers:
> >>>>>>
> >>>>>> Server 1, Mysql 4.0.12, PHP 4.3.2, apache 1.3.27
> >>>>>> Server 2, Mysql 4.0.14, PHP 4.3.2, apache 1.3.27
> >>>>
> >>>> --
> >>>>
> >>>> Thomas Deliduka
> >>>> IT Manager
> >>>>      -------------------------
> >>>> Xenocast
> >>>> Street Smart Media Solutions
> >>>> http://www.xenocast.com/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux