PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 26th, 2000, 06:08 AM
mmccue mmccue is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Posts: 43 mmccue User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Send a message via ICQ to mmccue
This may turn out to be a lengthy post, but I think I am a little confused on Mysql results. Actually, I know I am because I can never seem to get them right... Thanks in advance for any help.

Here's the scenario... I am having trouble understanding what is returned when I do a MYSQL_QUERY() and how to handle it in the program... I know it returns an array, but I don't know how to get what I want out of the array.

I know how to do a MYSQL_QUERY looking for a bunch of values, using :
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
while ($return=MYSQL_FETCH_ARRAY($return_array)) {
...do this...
}
[/code]

What if I am only expecting one return? Obviously I do not want to do a WHILE loop for the one return.. So in the instance of :
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$return_array=MYSQL_QUERY("SELECT userid, password FROM table WHERE userid='$user_name'");
[/code]

I am only expecting one result, how do I get it out? I tried :
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$return=MYSQL_FETCH_ARRAY($return_array);
echo $return['userid'];
echo $return['password'];
[/code]
but that doesn't seem to work either... I don't know how to use MYSQL_FETCH_ROW (I looked on php.net and couldn't see a real difference in .._ROW and .._ARRAY but I still could never get ROW to work... Also, in the code above (fetching the userid/password) I get a MYSQL error if there is no matching userid... do I have to account for this possibility in my code, or am I just possibly doing something wrong with my usage?

I guess what I'm fetching for is information regarding returns from a QUERY, and how to handle them, a website would be nice if there is one out there... also, if you know of somewhere to find a bit of information on cookies in php... I got the setcookie part, and I understand the majority of that, but I'm reading about some browsers not handling this and that, and people using a header() function for their cookies, and I would like to know what that is all about... if anyone knows of a site that details that kind of information (again, been to php.net, that wasn't too helpful...)



Reply With Quote
  #2  
Old April 27th, 2000, 03:39 AM
closecut closecut is offline
worshipper of DOT
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Halmstad, Sweden
Posts: 35 closecut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 5 m 13 sec
Reputation Power: 14
Send a message via ICQ to closecut
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by mmccue:

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$return_array=MYSQL_QUERY("SELECT userid, password FROM table WHERE userid='$user_name'");
[/code]

I am only expecting one result, how do I get

[/quote]

With that query? No ..

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>

it out? I tried :
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$return=MYSQL_FETCH_ARRAY($return_array);
echo $return['userid'];
echo $return['password'];
[/code]

[/quote]

"userid" will be in $return[0] and "password" in $return[1] ..

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>

but that doesn't seem to work either... I don't know how to use MYSQL_FETCH_ROW (I looked on php.net and couldn't see a real difference in .._ROW and .._ARRAY but I still could never get ROW to work... Also, in the code above (fetching the userid/password) I get a MYSQL error if there is no matching userid... do I have to account for this possibility in my code, or am I just possibly doing something wrong with my usage?

[/quote]

If I'm not totally wrong, in which case some of the "gurus" around here will surely notice, using mysql_fetch_row() and the above query would result in $return["userid"] and $return["password"] ..

Forgive me if I'm wrong ..

Anyways, get a copy of "PHP3: Programming Browser Based Applications" by David Medinets, it's a good book if you need the fundamentals of stuff like queries and cookies ..



------------------
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Linux, the operating system with a clue - Command Line User Environment.[/quote]

geeee... thanks!

/closecut

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > A better understanding of mysql results...

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap