Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-03-24 20:27:20

AndrijaM
Member
From: Belgrade, Serbia
Registered: 2007-12-22
Posts: 190
Website

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

#2 2008-03-24 21:35:24

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

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.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

Board footer

Powered by FluxBB