Login     Sign up
how do i access $db in cutom script
Dann (@zipp2000)
Join date: Sep 17th 2010
Community posts: 28
View Profile
Send Message

I'm trying to add a custom script that needs to access database i set global like in account.php but gives me "can not connect " message, if i add in data manually it works fine. this is for a module i'm working on.

is $db_info['host'] the correct request ?
gave $db['host'] too no luck

sample
[code]
function loadto() {
global $nav, $config, $db, $client;

$conn=mysql_connect($db_info['host'];, $db_info['user'], $db_info['pass']);
mysql_select_db($db_info['dbname']) or die("unable to connect");

}
[/code]

166 months ago
Jcow Master (@falcone)
Join date: Sep 2nd 2010
Community posts: 917
View Profile
Send Message

if this custom script is a module, it is not necessary to connect to the database because you should already be connected.

166 months ago
Dum Dum Gratis (@domgratis)
Join date: Aug 4th 2010
Community posts: 82
View Profile
Send Message

yep. you don't need to connect separately. :)

166 months ago
Dann (@zipp2000)
Join date: Sep 17th 2010
Community posts: 28
View Profile
Send Message

ahh ok thanks was so simple was trying to use wrong query string [code]".tb()."accounts "."" [/code]
without .tb(). my bad lol

166 months ago