I want do connect to database.
I create a snipped with this code:
<?php
function connection()
{
if (!($link=mysql_connect("localhost","root","")))
{
echo "Error to connection data base.";
exit();
}
if (!mysql_select_db("testeDB",$link))
{
return "Error to select data base.";
exit();
}
return $link;
}
$link=connection();
return "Established Connection.
";
mysql_close($link); //close connection
?>
and the after I call the snipped on the document, but doesn’t work.
How I connect the database?
but I want create another database for to save my information...
I to be able save my information on the modx database or I have to create another database?
-
☆ A M B ☆
- 24,524 Posts
Life is so much easier if you can use the same database; unless it’s a really busy site, it should not cause any performance problems. Then you can just use the same database connection, with different table prefixes than what you used for the MODx tables (modx_ by default).