Jump to content

[SOLVED] Database Connection from within a function


Guest upirate

Recommended Posts

Guest upirate

I have a page that has a connection to a database.

 

I also call a function that makes a connection to a new database, outputs some data and closes.

 

The problem:        When I call the function, the main page database seems to not pull any data at all.

 

 

Im using all new database connection variables and closing them. Still the main connection stops working.

When you say you are using all new database connection variables, you need to also make sure you are telling mysql to open a new connection. So, within your function, you need to make sure you have declared TRUE within your mysql_connect() function call for your fourth parameter:

<?php
$con1 = mysql_connect($host, $user, $pass); // First connection
$con2 = mysql_connect($host, $user, $pass, TRUE); // force a new connection
?>

 

Hope this helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.