Re: brain cramp, ouch!
| From: | Robert Cummings | Date: | Fri, 17 May 2002 18:38:11 +0000 |
| Subject: | Re: brain cramp, ouch! | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-98170@lists.php.net to get a copy of this message | ||
Robert Cummings wrote:
>
> Kelly Meeks wrote:
> >
> > Ok
> >
> > Let's say I'm querying a table, and looping thru the results:
> >
> > $connect=mysql_connect(host,user,pass);
> > $thedb=mysql_select(database1);
> > $thequery="select * from foo";
> > $theresult=mysql_query($thequery) or die (mysql_error())
> > while ($output=mysql_fetch_assoc($theresult)){
> >
> > do stuff here..
> >
> > }
> >
> > What if while I'm looping, I want to take the information I'm looping thru,
> > and want to write it to completely different database, assuming that the
> > same username and password info works for both databases?
> >
> > Would you use multiple mysql_select_db statements, and then make refer. to
> > the result of that select in your queries?
> >
> > I'm getting errors when I do that.
> >
> > Sorry to be so moronical,
>
> This is not moronical, it gets a lot of coders... what you need to do is
> create another connection because the value returned from the mysql_connect
> function is a resource identofier, which means if you run two queries on the
> same connection the second result set will overwrite the first.
Or maybe it's just the result set var that needs to be unique... I don't
clearly remember since I have a pooling system that abstracts all this
mess for me :)
Cheers,
Rob.
--
.-----------------.
| Robert Cummings |
:-----------------`----------------------------.
| Webdeployer - Chief PHP and Java Programmer |
:----------------------------------------------:
| Mail : mailto:robert.cummings@webmotion.com |
| Phone : (613) 731-4046 x.109 |
:----------------------------------------------:
| Website : http://www.webmotion.com |
| Fax : (613) 260-9545 |
`----------------------------------------------'