CMS made simple: using mysql_select_db($dbname); messes up everything

1.9k Views Asked by At

hi im fairly new to cms made simple and ive stumbled upon a problem thats beyond me, my coad is

<?php

$dbh = 'localhost';
$dbu = 'root';
$dbp = '';

$connect = mysql_connect($dbh, $dbu, $dbp) or die ('Error connecting to mysql');

$yatzi = 'myposts';
mysql_select_db($yatzi);

echo "hello";
?>

and im using this through a user defined tag to import a php file, the proble is that everytime i load this page an error pops up saying:

string(61) "Smarty error: unable to read resource: "globalcontent:footer"" string(61) "Smarty error: unable to read resource: "globalcontent:footer""

and everything gets messedup, i seriously have no idead what is going on, can anybody please help me,, thnks...

2

There are 2 best solutions below

0
On BEST ANSWER

If this connection is to the same db server the issue could be that youre overwriting the connection resource and thus your CMS cant pull anything form the db.

This would be because by default PHP will detect that you already have a connection open and return that one if they share the same parameters. You can override this behavior by forcing a new connection:

$connect = mysql_connect($dbh, $dbu, $dbp, true);

Then when using this server you need to make sure you always specify which link to use:

mysql_select_db($yatzi, $connect);

mysql_query($query, $connect);
// etc...

Ohter possible issues might be that you have the code in the worng place (like directly in a Smarty template file without the special php escape tags surrounding it), or that the problem isnt related to your code at all and something is up with your CMS installation or customization.

0
On
<?php

$dbh = 'localhost';
$dbu = 'root';
$dbp = '';
$yatzi = 'myposts';

$connect = mysqli_connect($dbh, $dbu, $dbp,$yatzi) or die ('Error connecting to mysql');

echo "hello";
?>