471,120 Members | 1,310 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,120 software developers and data experts.

Mysql Works On One Page But No Other!

161 100+
I am running the Bizzar Server and I got mysql and php working. I created a login/logout page that does the user stuff and it works 100%. But if I used mysql on some other page I get these warnings.

Expand|Select|Wrap|Line Numbers
  1. Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\BizzarServer\Apache2\htdocs\index.php on line 77
  3. Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\BizzarServer\Apache2\htdocs\index.php on line 77
  4. Access denied for user 'ODBC'@'localhost' (using password: NO)


// Connect to server and select databse.
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '****';

$link = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = "accountdb";


Some Other Page Then Login


include 'connect.php';

$query = "SELECT * FROM accountTbl";
$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array( $result, MYSQL_NUM ) or die(mysql_error());

$avatar = $row['avatar'];
if($avatar == ""){
$avatar = "http://img1.jurko.net/avatar_5450.jpg";

echo "Welcome {$row['email']}! <br>" .
"points: {$row['points']} <br>" .
"Avatar: <img src=\"$avatar \" width=\"100px\" height=\"100px\"><br><br>";

include 'closedb.php';

include 'connect.php'

Jun 25 '08 #1
1 1215
5,058 Expert 4TB
The error you are getting would suggest you are trying to open a database connection without passing any user information.
ODBC is the default user used when no user info is passed.

Given that your "connect.php" is hard-coded with this info, it is unlikely that the problem is there.

When you call mysql_query without an open database connection, it will attempt to open one with the default user.
I would guess that is what is happening.

So, my guess is that your "connect.php" is not being included properly, or that is is not working as it should.
Did you perhaps forget to add it to the file?
Or is it perhaps being included to late, after a query is issued?
Jun 25 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.