Jump to content

Need help getting an email in query


monkeybidz

Recommended Posts

I need to get the email for a user using a query. Here is what I have so far:

 

<?php
$query = "SELECT email FROM PHPAUCTIONXL_users WHERE nick='$user_nick'";

$email = mysql_query("email");//<-- <-- This is my problem. 

?>

 

I also tried this:

 

<?php
$query = "SELECT email FROM PHPAUCTIONXL_users WHERE nick='$user_nick'";
$result =mysql_query($query);
$email = mysql_query($result,0,"email");
?>

 

 

Link to comment
Share on other sites

It is defioned all over the page? Sounds interesting. Any reason why its defined moire than once?

 

Anyway, lets try some decent debuging.

 

<?php

$query = "SELECT email FROM PHPAUCTIONXL_users WHERE nick='$user_nick'";
if ($result =mysql_query($query)) {
  if (mysql_num_rows($result)) {
    $record = mysql_fetch_assoc($result);
    $email = $record['email'];
  } else {
    echo "No record found matching $user_nick";
  }
} else {
  echo "Query failed<br />$sql<br />" . mysql_error();
}

?>

Link to comment
Share on other sites

<?php
$query = "SELECT email FROM PHPAUCTIONXL_users WHERE nick='$user_nick'";
$result =mysql_query($query) or die (mysql_error());
$record = mysql_fetch_assoc($result);
$email = $record['email'];
?>

 

This code worked, and so did one of mine. The problem was that I set this query to only work if a form was submitted.

 

I had this above the query.

<?php 
if($_POST['Submit']) {

$query = "SELECT email FROM PHPAUCTIONXL_users WHERE nick='$user_nick'";
$result =mysql_query($query) or die (mysql_error());
$record = mysql_fetch_assoc($result);
$email = $record['email'];
?>

 

It slipped my mind.

 

Thank guys.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.