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&here=y)
Use link identifiers.
$link = mysql_connect(blablabla);
$link2 = mysql_connect(blablabla2);
mysql_query('SQL QUERY 1', $link);
mysql_qurty('SQL QUERY 2', $link2);
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.
精彩评论