开发者

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

开发者 https://www.devze.com 2023-02-22 12:09 出处:网络
hi im fairly new to cms made simple and ive stumbled upon a problem thats beyond me, my coad is <?php

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

精彩评论

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

关注公众号