connection to foreign database

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
sailorarie
New Member
New Member
Posts: 5
Joined: Wed Jun 21, 2006 12:00 pm

connection to foreign database

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: connection to foreign database

Post by calguy1000 »

try using something other than $db which is used alot within CMS.

i.e.: use $foreigndb as your database variable.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
sailorarie
New Member
New Member
Posts: 5
Joined: Wed Jun 21, 2006 12:00 pm

Re: connection to foreign database

Post by sailorarie »

Thanks. That solved my problem !

Arie
Post Reply

Return to “CMSMS Core”