473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

query issue

I've been trying to nut this error out for the last three days to no
success. Here's the code:

$usern = "myusername";
$passw = "mypassword";
$db="mydatabase";
$link2 = @mysql_connect("localhost", $usern, $passw);
if (! $link2) {
die("Connect error.");
}
mysql_select_db($db) or die("DB Select error");

$status = mysql_query("SELECT * FROM members WHERE usern='$user'");
while ($display = mysql_fetch_array($status)) {
print $display['usern'];

}
mysql_close($link2);

(Obviously Ive change the real database name, user and password, but
rest assured the real ones are correct - this i have triple and
quadruple checked)
On a whim I changed the $status variable to:
$status = mysql_query("SELECT * FROM members WHERE usern='$user'") or
die (mysql_error());
and was given this error:
Access denied for user 'myusername@localhost' (Using password: NO)
This is what confuses me - why isn't it recognising the use of
password? All help appreciated.

Sep 27 '07 #1
7 1200
Chenky wrote:
I've been trying to nut this error out for the last three days to no
success. Here's the code:

$usern = "myusername";
$passw = "mypassword";
$db="mydatabase";
$link2 = @mysql_connect("localhost", $usern, $passw);
if (! $link2) {
die("Connect error.");
}
mysql_select_db($db) or die("DB Select error");

$status = mysql_query("SELECT * FROM members WHERE usern='$user'");
while ($display = mysql_fetch_array($status)) {
print $display['usern'];

}
mysql_close($link2);

(Obviously Ive change the real database name, user and password, but
rest assured the real ones are correct - this i have triple and
quadruple checked)
On a whim I changed the $status variable to:
$status = mysql_query("SELECT * FROM members WHERE usern='$user'") or
die (mysql_error());
and was given this error:
Access denied for user 'myusername@localhost' (Using password: NO)
This is what confuses me - why isn't it recognising the use of
password? All help appreciated.
You're using the wrong userid/password combination.

Talk to your host to see what the should be.

Of, if it's your own server, set the permissions in MySQL correctly,

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 27 '07 #2
Like i said before, I've double triple quadruple checked all that.
Other mysql operations are conducted using exactly the same parametres
no issues at all.

Any further help appreciated.

Sep 27 '07 #3
Chenky wrote:
Like i said before, I've double triple quadruple checked all that.
Other mysql operations are conducted using exactly the same parametres
no issues at all.

Any further help appreciated.
Hmm. It may be that there is an internal variable called $user somewhere
else..

Try echoing the $query string and pasting it into a terminal session
running mysql on th server itself.

That's how I fix most issues like that.

Sep 27 '07 #4
Chenky wrote:
Like i said before, I've double triple quadruple checked all that.
Other mysql operations are conducted using exactly the same parametres
no issues at all.

Any further help appreciated.
Access denied for user 'myusername@localhost' (Using password: NO)

This doesn't lie. You are attempting to log in as myusername@localhost,
and your password field is blank or missing.

echo $passw just before you issue the connect and see what it says.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 27 '07 #5
The plot thickens. The problem isn't on the connect - thats all fine.
Its the actual query. I echoed the $passw and that was as expected.
It's not until the query with the die() added to it that that error
shows up.

Just as a note as an experiment, i did a mysql_num_rows query on the
$status before the while loop - it returned '1'. So its able to
execute that query. It's the while loop that was originally
encountering the problem. Then I tested the $status with a die() and
it comes up with the error.

My fundamental confusion: it dies with no password recognised, but
performed the num_rows query?!

Sep 28 '07 #6
Chenky wrote:
The plot thickens. The problem isn't on the connect - thats all fine.
Its the actual query. I echoed the $passw and that was as expected.
It's not until the query with the die() added to it that that error
shows up.

Just as a note as an experiment, i did a mysql_num_rows query on the
$status before the while loop - it returned '1'. So its able to
execute that query. It's the while loop that was originally
encountering the problem. Then I tested the $status with a die() and
it comes up with the error.

My fundamental confusion: it dies with no password recognised, but
performed the num_rows query?!
Then there's more to it than the code you showed us indicates.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Sep 28 '07 #7
On Sep 27, 8:25 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
Chenky wrote:
The plot thickens. The problem isn't on the connect - thats all fine.
Its the actual query. I echoed the $passw and that was as expected.
It's not until the query with the die() added to it that that error
shows up.
Just as a note as an experiment, i did a mysql_num_rows query on the
$status before the while loop - it returned '1'. So its able to
execute that query. It's the while loop that was originally
encountering the problem. Then I tested the $status with a die() and
it comes up with the error.
My fundamental confusion: it dies with no password recognised, but
performed the num_rows query?!

Then there's more to it than the code you showed us indicates.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
I've been using mysql functions for years and ive never seen this sort
of willy nilly craziness. Either one of two things are happening...

1) Jerry is completely correct and this is absurd
2) PHP has a bug in its mysql connection which has never been
experienced before.

Either we need to see some proper output or this is a moot discusion,
as it wont do us any good to speculate on the meaning of what has been
posted because its not code, and hear-say is meaningless.

Sep 29 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DBNovice | last post by:
I have a database that keeps records on the issue and failure of an item. Currently, the database is poorly desisned; therefore I'm performing queries to break the data into normalized tables and...
3
by: Brian Oster | last post by:
After applying security patch MS03-031 (Sql server ver 8.00.818) a query that used to execute in under 2 seconds, now takes over 8 Minutes to complete. Any ideas on what the heck might be going...
3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
4
by: Starbuck | last post by:
OK, first let me say that I am no DB person. But I have a user here who keeps getting this error whenever she does, whatever it is she does, with databases... A google search takes me to...
3
by: Megan | last post by:
hi everybody- it seems like my update query should work. the sql view seems logical. but that might be up to discussion...lol...i'm a newbie! UPDATE , Issue SET .IssueID = . WHERE ((.=.));
2
by: Brian Tabios | last post by:
Hello Everyone, I have a very complex performance issue with our production database. Here's the scenario. We have a production webserver server and a development web server. Both are running...
5
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the...
2
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
1
by: Andy_Khosravi | last post by:
Background: Access 2003 (converted from A97 DB recently), database is split into FE/BE with the FE residing on client machine. I've got a question about how I can possibly optimize a query I've...
18
by: JGrizz | last post by:
Greetings, I first off want to state that I am new to the forum, so if this question ends up in the wrong area, I apologize. This pertains to Access 2003/VBA/SQL issues... I have been doing some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.