[PHP-DB] A newbie in deep need for help

2002-12-27 Thread Ehab El Maraghy
Hi everybody
I have installed php4 and mysql on IIs winxp 
I am trying to retrieve a password and print it using a query which is written as 
followos

$query2 = select passwd from user where username = '$username';
$result = mysql_result($query2);
echo centerBOld Password was $result /B/center;

am I using mysql_result right or is there another function to print this password 
taking in consideration that it just prints Old Password was and that's it




[PHP-DB] a newbie in deep need for help

2002-12-27 Thread Ehab El Maraghy
Hi everybody
I have installed php4 and mysql on IIs winxp
I am trying to retrieve a password and print it using a query which is
written as followos

$query2 = select passwd from user where username = '$username';
$result = mysql_result($query2);
echo centerBOld Password was $result /B/center;

am I using mysql_result right or is there another function to print this
password taking in consideration that it just prints Old Password was and
that's it




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] A newbie in deep need for help

2002-12-27 Thread Rich Hutchins
Nope. Use this statement:

$result = mysql_query($query2);

The mysql_query() function actually performs the query to the db for you and
returns a resource with your result set contained within.

The mysql_result() function extracts the contents of a given cell from your
result set; it does not actually execute the query to the db. Essentially
you use mysql_result() to operate on a result set. Other things you can use
on your result set include, but are not limited to: mysql_fetch_array(),
mysql_fetch_row() and mysql_fetch_object, but again, they are operating on
the result set retrieved by the mysql_query() function.

Here's a good overview of the above functions:
http://www.php.net/manual/en/function.mysql-result.php

Hope this helps

-Original Message-
From: Ehab El Maraghy [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 27, 2002 4:17 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] A newbie in deep need for help


Hi everybody
I have installed php4 and mysql on IIs winxp
I am trying to retrieve a password and print it using a query which is
written as followos

$query2 = select passwd from user where username = '$username';
$result = mysql_result($query2);
echo centerBOld Password was $result /B/center;

am I using mysql_result right or is there another function to print this
password taking in consideration that it just prints Old Password was and
that's it



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] A newbie in deep need for help

2002-12-27 Thread Ehab El Maraghy
Rich
thanx for answering
I did what you said yesterday before using mysql_resut it returns   resource
id#3 didn't know what is it and how can i transform it it the data inside
the cell
i corrected the situation and i waited to give me res.id#3   but it doesn't
write anythingany suggestions  ? from my part i will revise the code
once again
waiting for your reply   thanx



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] a newbie in deep need for help

2002-12-27 Thread janet
In a message dated 12/27/02 8:26:10 AM Pacific Standard
Time, [EMAIL PROTECTED] writes:

 I am trying to retrieve a password and print it using
a query which is
  written as followos
  
  $query2 = select passwd from user where username =
'$username';
  $result = mysql_result($query2);
  echo centerOld Password was $result /center;
  
  am I using mysql_result right or is there another
function to print this
  password taking in consideration that it just prints
Old Password was and

Actually, it would go like this:

$query2 = select passwd from user where username =
'$username';
$result = mysql_query($query2);
$row = mysql_fetch_array($result);
extract($row);
echo centerOld Password was $passwd /center;

There are other ways. And shorter ones for this
particular task. But this is kind of a general purpose
set of statements that will usually do what you need. 

The mysql_query function sends the SQL query to the
database and puts the data returned into a temporary
table. mysql_fetch_array gets a row of data from the
temporary table and puts it into an array that you can
then process. The extract function creates separate
variables from the array. 

If you are getting more than one row from the database,
you can use the extract statement in a loop and process
each row.

Janet


Janet Valade
Author, PHP  MySQL for Dummies

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] A newbie in deep need for help

2002-12-27 Thread Rich Hutchins
Yes, first you use:

$result = mysql_result($query2);

That will return something like resourceID #3. That's right. What you need
to do now is to use a function to access the resource. For example, if you
have a table named User with the following columns:
ID
username
passwd

and you want to perform a query that just returns the password, your code
would look like something like this:

$query2 = select passwd from user where username = '$username';//query
$result = mysql_query($query2);//perform the query and return result set
$thisPass = mysql_result($result);//return one column (passwd) from result
set
echop.$thisPass./p; //this line would just echo out the variable
$thisPass to the browser to show you what it contains.

Try that code and see if it works for you. If not, respond and paste all of
the code you're working with and I'll see if I can find what's going wrong.

Rich

-Original Message-
From: Ehab El Maraghy [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 27, 2002 12:24 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] A newbie in deep need for help


Rich
thanx for answering
I did what you said yesterday before using mysql_resut it returns   resource
id#3 didn't know what is it and how can i transform it it the data inside
the cell
i corrected the situation and i waited to give me res.id#3   but it doesn't
write anythingany suggestions  ? from my part i will revise the code
once again
waiting for your reply   thanx



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] A newbie in deep need for help

2002-12-27 Thread Ehab El Maraghy
man  i have tried everything   the sentece is always printed without the
variable
don't know what is happening



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] a newbie in deep need for help

2002-12-27 Thread John Coder
On Fri, 2002-12-27 at 04:19, Ehab El Maraghy wrote:
 Hi everybody
 I have installed php4 and mysql on IIs winxp
 I am trying to retrieve a password and print it using a query which is
 written as followos
 
 $query2 = select passwd from user where username = '$username';
 $result = mysql_result($query2);
 echo centerBOld Password was $result /B/center;
 
 am I using mysql_result right or is there another function to print this
 password taking in consideration that it just prints Old Password was and
 that's it
 
If I'm not mistaken mysql_result() takes 3 arguments. try:

$select = select passwd from user where username = '$username';
$query2 = mysql_query($select);
$result=mysql_result($query2,0,0);
//the zeroes being the position of row and column i.e. row0 and column 0
echo $result;

John


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] a newbie in deep need for help

2002-12-27 Thread Rich Hutchins
Aha! John, you're right. I remember stumbling over this the first time I
used it. Sorry for any confusion,  Ehab.

More info here:
http://www.php.net/manual/en/function.mysql-result.php

-Original Message-
From: John Coder [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 27, 2002 2:09 PM
To: Ehab El Maraghy
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] a newbie in deep need for help


On Fri, 2002-12-27 at 04:19, Ehab El Maraghy wrote:
 Hi everybody
 I have installed php4 and mysql on IIs winxp
 I am trying to retrieve a password and print it using a query which is
 written as followos

 $query2 = select passwd from user where username = '$username';
 $result = mysql_result($query2);
 echo centerBOld Password was $result /B/center;

 am I using mysql_result right or is there another function to print this
 password taking in consideration that it just prints Old Password was
and
 that's it

If I'm not mistaken mysql_result() takes 3 arguments. try:

$select = select passwd from user where username = '$username';
$query2 = mysql_query($select);
$result=mysql_result($query2,0,0);
//the zeroes being the position of row and column i.e. row0 and column 0
echo $result;

John


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php