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
https://forums.phpfreaks.com/topic/93467-need-help-getting-an-email-in-query/
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();
}

?>

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.