rawky1976 Posted March 13, 2007 Share Posted March 13, 2007 I'm using an include file that connects as root (just whilst testing)! Here'e my code: - <?php include 'config.php'; include 'opendb.php'; $query_rsCategory = "SELECT category_name FROM category ORDER BY category_name ASC"; $rsCategory = mysql_query($query_rsCategory) or die(mysql_error()); $row_rsCategory = mysql_fetch_assoc($rsCategory); $totalRows_rsCategory = mysql_num_rows($rsCategory); ?> When it runs I get: - Access denied for user 'ODBC'@'localhost' (using password: NO) Where is it getting ODBC from? //Additional: - <?php // This is config.php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = '****'; $dbname = '****'; ?> <?php // This is opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); ?> Link to comment https://forums.phpfreaks.com/topic/42589-where-is-this-odbc-coming-from/ Share on other sites More sharing options...
rawky1976 Posted March 13, 2007 Author Share Posted March 13, 2007 does nobody know? Link to comment https://forums.phpfreaks.com/topic/42589-where-is-this-odbc-coming-from/#findComment-206686 Share on other sites More sharing options...
chronister Posted March 14, 2007 Share Posted March 14, 2007 It is not pulling the username / password connection script properly. I have gotten this error loads of times when I forget to call my connectdb() function. Try doing this. You may need to modify a little as you have the declaration of the variables in a different page than the actual connection script. If you can, just put it all together, otherwise you will have to call global $dbhost,$dbuser,$dbpass,$dbname function connectdb(){ // This is config.php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = '****'; $dbname = '****'; // This is opendb.php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); } or function connectdb(){ global $dbhost,$dbuser,$dbpass,$dbname $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); }; Then anytime you need to run a query, simply call connectdb(); before you actually run the query. Link to comment https://forums.phpfreaks.com/topic/42589-where-is-this-odbc-coming-from/#findComment-206807 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.