Jump to content


Photo

PHP Newb Here


  • Please log in to reply
2 replies to this topic

#1 Btown2

Btown2
  • Members
  • PipPipPip
  • Advanced Member
  • 35 posts

Posted 23 October 2006 - 12:40 AM

Just wondering how i can pull data out of my DB. Heres what i attempted so far, but it returns "Resource id#4"


<?php
include "mysql_connect.php";

$username=$_POST['namebox'];
$entered_password=$_POST['pbox'];

$query ="SELECT password FROM users WHERE (name = \"$username\")";

$password = mysql_query($query);

echo $password;

?>


#2 extrovertive

extrovertive
  • Members
  • PipPipPip
  • Advanced Member
  • 235 posts

Posted 23 October 2006 - 12:54 AM

$username=$_POST['namebox'];
$entered_password=$_POST['pbox'];

$query ="SELECT password FROM users WHERE name = '$username' LIMIT 1";

//mysql_query will execute your SQL query and return the resource
$result = mysql_query($query);

//then you need to use a query function to retrive all the rows based on your query result
list($password) = mysql_fetch_row($result);

//output your password
echo $password;



#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 24 October 2006 - 02:28 AM

You'll probably want to iterate through the result set:

while( list($password) = mysql_fetch_row($result) ) {
echo $password;
}
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users