开发者

I have a page that uses a mysql connection. How can i make 1 mysql request using a new connection without messing up the current connection?

开发者 https://www.devze.com 2023-01-08 06:35 出处:网络
I currently have a page that is something like this <?php mysql_connect(...); mysql_query(\'the pages queries\');

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消