Page 1 of 1

connection to foreign database

Posted: Wed Jun 21, 2006 2:04 pm
by sailorarie
Hi,

I am pretty new to cmsmadesimple. So please apology for stupid questions.. ;-)

I made a php script which i include using {include_php file="myscripts/index.php"}

From that script i would like to connect to a (foreign) database (mysql) to show the contents of a table in that db in my website.

Usually, in a normal website i do something like:


--------
$db = mysql_connect('host', 'mysql_user', 'mysql_password');
$sql = "SELECT * FROM TABLE";
$result = mysql_query($sql,$db);
$num_rows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
  echo "$row[0]"; 
}
mysql_close($db);
--------

For some reason this doesnt work. Can somebody help ?

Is there a global variable that links to the db where cmsmadessimple is stored ?

Thnx in advance

Re: connection to foreign database

Posted: Wed Jun 21, 2006 2:21 pm
by calguy1000
try using something other than $db which is used alot within CMS.

i.e.: use $foreigndb as your database variable.

Re: connection to foreign database

Posted: Thu Jun 22, 2006 2:41 pm
by sailorarie
Thanks. That solved my problem !

Arie