473,513 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mysql Works On One Page But No Other!

Ajm113
161 New Member
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
  2.  
  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)
Codes

connect.php

[PHP]<?php
// 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";
mysql_select_db($dbname);

?>[/PHP]

Some Other Page Then Login

[PHP]//Top
ob_start();
session_start();

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';
?>
[/PHP]

Close.php
[PHP]<?php
include 'connect.php'

mysql_close($link);
?>
[/PHP]
Jun 25 '08 #1
1 1324
Atli
5,058 Recognized Expert Expert
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

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

Similar topics

0
3925
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
74
7876
by: John Wells | last post by:
Yes, I know you've seen the above subject before, so please be gentle with the flamethrowers. I'm preparing to enter a discussion with management at my company regarding going forward as either...
3
3375
by: apostolosl | last post by:
Hi there. I need to update a remote database from a local one. I use mysqldump in my php page in order to create a file for each table, like this: $command="mysqldump table_products >...
39
5825
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7519
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.