Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Cant connect to another database from txp
Hi,
I get the following error when connecting to another database from txp:
$host = 'localhost'; $user = 'root'; $pass = ''; $db = 'base1;
tag_error <txp:php> -> Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) on line 7
ERROR: Unable to connect!
and the code I’m using in txp is:
<txp:php>
...some code before...
include('config.inc');
$connection = mysql_connect($host, $user, $pass) or die('ERROR: Unable to connect!');
mysql_select_db($db, $connection) or die('ERROR: Unable to select database!');
// update vote counter
$query = "UPDATE answers SET acount = acount + 1 WHERE aid = ".$vote." AND qid = 1";
$result = mysql_query($query) or die("ERROR: $query. ".mysql_error());
mysql_close($connection);
</txp:php>
Since I have only 2 tables in that database, can i put those tables in my txp database, could that couse any problem?
Offline
Re: Cant connect to another database from txp
as long as the table name doesn’t conflict with a texpattern table you should be able to use the same database for both.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline