This is my first ever mysql query that I have written and after some trial and error it works. The echo part is just for testing purposes. I will assign that to another variable for the actual script. $result = mysql_query( "SELECT * FROM user WHERE user_name='$user_name'" ) or error( mysql_error() ); $row = mysql_fetch_array($result, MYSQL_NUM); echo $row[2]; PHP: Is there anything wrong with using the $row[#] method to retrieve a single item from a db row? Is there a better way to do the same thing.
You can call the row header itself such as $row['blahh'] if your column header is blahh. Makes your code a little more readable. As a coder your job is to make your code as readable as possible. I can't count how many times I've gone back to something I wrote and spent a good while trying to figure out what the hell I was trying to do.
I think you said, "if my row header is named email, then I can use instead of [2]" ???????????? This works no matter whee in the row it is?
I tried it with ' ' and with " " and niether worked. Both of course were inside the [ ]. Maybe I did something wrong. Okay I tried this and it worked: It was the that made it fail to work. Green for you and thanks for your help.