开发者

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

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 conne开发者_如何学Pythoncting 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...


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.


<?php

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

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

echo "hello";
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜