tags:

views:

14

answers:

2

Hi, I currently have a page that is something like this

<?php
mysql_connect(...);

mysql_query('the pages queries');

### here ###

mysql_query('the pages queries');

?>

but where it says ### here ###, i basically want to do this:

mysql_connect(new server/new user)
mysql_query(update db2.log ...)

is there any easy way to do this so it 100% won't mess up any thing else on the site? I want to log stuff on a lot of sites, so want to put a little function in (then call it) on loads of different sites of mine. currently i'm using curl to request a page (basically http://mysite.com/log/log.php?vars=x&amp;here=y)

+4  A: 

Use link identifiers.

$link = mysql_connect(blablabla);
$link2 = mysql_connect(blablabla2);

mysql_query('SQL QUERY 1', $link);
mysql_qurty('SQL QUERY 2', $link2);
cypher
yeah, that's the way you should do, every time... also if you use 1 single connection...
Marcx
what if i don't have a link identifier on the initial one?also, does wordpress do this by default?
phpno
That shouldn't be a problem. If it is, you'll have to use link identifiers for both. OR better yet, use MySQLi class instead of old mysql_ functions.
cypher
A: 

I assume you don't want to throw the link identifier in every other query. In that case, use mysqli or PDO with PDO_MySQL if available to avoid messing up the 'last mysql resource identifier', after which you close that connection / destory that instance.

Wrikken