Jump to content

Where is this ODBC coming from?


rawky1976

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.