1

I am trying to make a page for re-sending the activation mail to the a members of my site who have not received it. I'm not able to fetch the required data from mysql. This is what I have tried -

$act = mysql_query("SELECT activate FROM users WHERE email='$mail'");

where users is the table name, activate is the column name from which data is to be fetched. The email address of which the code is to be fetched is stored in $mail and email is a column name in the table.

I want to fetch the data from the column activate and row which is same as the row in which the value of email column is same as the value in $email.

This is the output I am currently getting - Resource id #11

While the correct output must be something like - 55445513

Any help would be greatly appreciated :)

3
  • 1
    you need to pass that resource to $row=mysql_fetch_array($act); $row["activate"] will give you the result Commented Jan 21, 2013 at 11:14
  • Are you using php for front end? If so please retag for php as well.. Commented Jan 21, 2013 at 11:14
  • 1
    and usual blurb about the deprecation of mysql_ Commented Jan 21, 2013 at 11:20

1 Answer 1

1

Use this:

$act = mysql_query("SELECT activate FROM users WHERE email='$mail'");
$act_array = mysql_fetch_array($act);

You can then reference $act_array for your array element results.

Sign up to request clarification or add additional context in comments.

3 Comments

This, and for viewing the array you could use print_r($act_array);
I am getting the output as Array ( [0] => 848526751 [activate] => 848526751 ) but i need the output to be just 848526751
print_r shows you the whole array in a neat way. JUST USE $act_array['activiate'] to display JUST the number.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.