Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

User Authetication in PHP question

LEGEND ,
Jun 18, 2008 Jun 18, 2008
I have a user authentication problem, and don't know what to try next.
Here's my code -

$LoginRS__query=sprintf("SELECT UserName, UserPassword, UserIsAdmin FROM
users WHERE UserName=%s AND UserPassword=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password,
"text"));
$LoginRS = mysql_query($LoginRS__query, $connADT) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');

If I die($LoginRS__query), copy the string, and use a manual MySQL query to
search the database with it, it succeeds, and finds the proper record.

As you can see from the code, I also have a die(mysql_num_rows($LoginRS)),
and that returns a FALSE!

What the heck?


--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


TOPICS
Server side applications
573
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:g3b12g$q9d$1@forums.macromedia.com...
>I have a user authentication problem, and don't know what to try next.

I would try ColdFusion if I was you :-))

Massimo


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
LOL. That would be too easy, doncha know? I like the challenge! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Massimo Foti" <massimo@massimocorner.com> wrote in message
news:g3b1l9$qud$1@forums.macromedia.com...
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:g3b12g$q9d$1@forums.macromedia.com...
>>I have a user authentication problem, and don't know what to try next.
>
> I would try ColdFusion if I was you :-))
>
> Massimo
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:g3b2bj$rm6$1@forums.macromedia.com...
> LOL. That would be too easy, doncha know? I like the challenge! 8)

It's upo to you after all. Just ask Dan Short how his life changed for the
better as soon as he moved to ColdFusion :-))

Massimo


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
On Wed, 18 Jun 2008 09:02:41 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>As you can see from the code, I also have a die(mysql_num_rows($LoginRS)),
>and that returns a FALSE!

Your die is unconditional. It will happen any time execution reaches
that point in the code. Your die:


die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');

Will display TRUE if any rows are returned by the query, or FALSE is
no rows are returned. Your description would indicate that the query
was successfully executed and it returned zero rows.

Gary
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
But the same query returns 1 row when I do it directly. That's the point.
It's failing on the page, but both the username and password are correctly
entered and are in the database!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Gary White" <reply@newsgroup.please> wrote in message
news:ee8i549e617on9nri1a0hqh2pk5fpr0mq3@4ax.com...
> On Wed, 18 Jun 2008 09:02:41 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>As you can see from the code, I also have a die(mysql_num_rows($LoginRS)),
>>and that returns a FALSE!
>
> Your die is unconditional. It will happen any time execution reaches
> that point in the code. Your die:
>
>
> die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');
>
> Will display TRUE if any rows are returned by the query, or FALSE is
> no rows are returned. Your description would indicate that the query
> was successfully executed and it returned zero rows.
>
> Gary

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
When I do an explicit SQL query with username and password, the query
succeeds, and it says "Showing rows 0 - 0 (1 total, Query took 0.0008 sec)".
Does that mean that mysql_num_rows() will return 0, or 1?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:g3b97l$607$1@forums.macromedia.com...
> But the same query returns 1 row when I do it directly. That's the point.
> It's failing on the page, but both the username and password are correctly
> entered and are in the database!
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> ==================
>
>
> "Gary White" <reply@newsgroup.please> wrote in message
> news:ee8i549e617on9nri1a0hqh2pk5fpr0mq3@4ax.com...
>> On Wed, 18 Jun 2008 09:02:41 -0400, "Murray *ACE*"
>> <forums@HAHAgreat-web-sights.com> wrote:
>>
>>>As you can see from the code, I also have a
>>>die(mysql_num_rows($LoginRS)),
>>>and that returns a FALSE!
>>
>> Your die is unconditional. It will happen any time execution reaches
>> that point in the code. Your die:
>>
>>
>> die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');
>>
>> Will display TRUE if any rows are returned by the query, or FALSE is
>> no rows are returned. Your description would indicate that the query
>> was successfully executed and it returned zero rows.
>>
>> Gary
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
OK - when I do this -

$LoginRS__query="SELECT UserName, UserPassword, UserIsAdmin FROM users
WHERE UserName='sssssss' AND UserPassword='cccccc'";

(where the username and password are CORRECT)
$LoginRS = mysql_query($LoginRS__query, $connADT) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');

the page dies with a return of FALSE!

What the heck?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:g3ba2h$6rb$1@forums.macromedia.com...
> When I do an explicit SQL query with username and password, the query
> succeeds, and it says "Showing rows 0 - 0 (1 total, Query took 0.0008
> sec)". Does that mean that mysql_num_rows() will return 0, or 1?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> ==================
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:g3b97l$607$1@forums.macromedia.com...
>> But the same query returns 1 row when I do it directly. That's the
>> point. It's failing on the page, but both the username and password are
>> correctly entered and are in the database!
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> ==================
>>
>>
>> "Gary White" <reply@newsgroup.please> wrote in message
>> news:ee8i549e617on9nri1a0hqh2pk5fpr0mq3@4ax.com...
>>> On Wed, 18 Jun 2008 09:02:41 -0400, "Murray *ACE*"
>>> <forums@HAHAgreat-web-sights.com> wrote:
>>>
>>>>As you can see from the code, I also have a
>>>>die(mysql_num_rows($LoginRS)),
>>>>and that returns a FALSE!
>>>
>>> Your die is unconditional. It will happen any time execution reaches
>>> that point in the code. Your die:
>>>
>>>
>>> die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');
>>>
>>> Will display TRUE if any rows are returned by the query, or FALSE is
>>> no rows are returned. Your description would indicate that the query
>>> was successfully executed and it returned zero rows.
>>>
>>> Gary
>>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
On Wed, 18 Jun 2008 11:43:28 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>OK - when I do this -
>
> $LoginRS__query="SELECT UserName, UserPassword, UserIsAdmin FROM users
>WHERE UserName='sssssss' AND UserPassword='cccccc'";
>
>(where the username and password are CORRECT)
> $LoginRS = mysql_query($LoginRS__query, $connADT) or die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');
>
>the page dies with a return of FALSE!
>
>What the heck?

Strange. Try this:

$LoginRS__query="SELECT UserName, UserPassword, UserIsAdmin FROM users
WHERE UserName='sssssss' AND UserPassword='cccccc'";

(where the username and password are CORRECT)

$LoginRS = mysql_query($LoginRS__query, $connADT)
or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);

echo "Query $LoginRS__query returned $loginFoundUser rows";
exit;

What do you get there? If it returned zero rows, what does the query
look like? If you copy and paste that query into PHPmyAdmin, what do
you get?

Gary
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
NOTE: To Moderator.

Please remove this thread. The OP obviously has a serious problem between
the keyboard and the chair! 8(

Nevermind!

8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:g3bafv$7cr$1@forums.macromedia.com...
> OK - when I do this -
>
> $LoginRS__query="SELECT UserName, UserPassword, UserIsAdmin FROM users
> WHERE UserName='sssssss' AND UserPassword='cccccc'";
>
> (where the username and password are CORRECT)
> $LoginRS = mysql_query($LoginRS__query, $connADT) or die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');
>
> the page dies with a return of FALSE!
>
> What the heck?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> ==================
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:g3ba2h$6rb$1@forums.macromedia.com...
>> When I do an explicit SQL query with username and password, the query
>> succeeds, and it says "Showing rows 0 - 0 (1 total, Query took 0.0008
>> sec)". Does that mean that mysql_num_rows() will return 0, or 1?
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> ==================
>>
>>
>> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
>> news:g3b97l$607$1@forums.macromedia.com...
>>> But the same query returns 1 row when I do it directly. That's the
>>> point. It's failing on the page, but both the username and password are
>>> correctly entered and are in the database!
>>>
>>> --
>>> Murray --- ICQ 71997575
>>> Adobe Community Expert
>>> (If you *MUST* email me, don't LAUGH when you do so!)
>>> ==================
>>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>>> ==================
>>>
>>>
>>> "Gary White" <reply@newsgroup.please> wrote in message
>>> news:ee8i549e617on9nri1a0hqh2pk5fpr0mq3@4ax.com...
>>>> On Wed, 18 Jun 2008 09:02:41 -0400, "Murray *ACE*"
>>>> <forums@HAHAgreat-web-sights.com> wrote:
>>>>
>>>>>As you can see from the code, I also have a
>>>>>die(mysql_num_rows($LoginRS)),
>>>>>and that returns a FALSE!
>>>>
>>>> Your die is unconditional. It will happen any time execution reaches
>>>> that point in the code. Your die:
>>>>
>>>>
>>>> die(mysql_num_rows($LoginRS)?'TRUE':'FALSE');
>>>>
>>>> Will display TRUE if any rows are returned by the query, or FALSE is
>>>> no rows are returned. Your description would indicate that the query
>>>> was successfully executed and it returned zero rows.
>>>>
>>>> Gary
>>>
>>
>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
On Wed, 18 Jun 2008 13:03:58 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>NOTE: To Moderator.
>
>Please remove this thread. The OP obviously has a serious problem between
>the keyboard and the chair! 8(
>
>Nevermind!
>
>8)

Hmmm ... Saturday night live? Nevermind. ;-)

Gary
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 18, 2008 Jun 18, 2008
LATEST
LOL....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Gary White" <reply@newsgroup.please> wrote in message
news:1bhi54152pm01pbg7t2d0n6p9pbmqh3j1f@4ax.com...
> On Wed, 18 Jun 2008 13:03:58 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>NOTE: To Moderator.
>>
>>Please remove this thread. The OP obviously has a serious problem between
>>the keyboard and the chair! 8(
>>
>>Nevermind!
>>
>>8)
>
> Hmmm ... Saturday night live? Nevermind. ;-)
>
> Gary

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines