Jump to content

Trying to extract an email address from an array for mail


damion

Recommended Posts

I have a function that is supposed to find the email address of the user that's logged in my application. going by their ID:

function getUserEmail($userID){
    $sqll="SELECT id,email FROM users WHERE id='".$userID."'";
    $result1=mysql_query($sqll);
    $row11=mysql_fetch_assoc($result1);
    $processor=$row11["email"]; 
    return $processor;
}

What I'm trying to do is incorporate that into sending a simple email to the person that's logged in after they submit a file. But the email is not being sent and I'm getting this message:

Warning: mail() expects parameter 1 to be string, array given

 

Here is what I have for sending the email :

$sendto = getUserInfo($_REQUEST[1][email]);
$subject = "File recieved";
$message = "Hello " . getUser($_REQUEST["user"]) . ". you successfully submitted: $title";
mail($sendto, $subject, $message);

How do I extract just the email address to prevent giving the array?

 

Link to comment
Share on other sites

In your first code your function name is getUserEmail, but that function is never called in the second code. We might need more info to help you solve this.

 

Have you tried debugging the code, looking at the values of the variables at certain places? You might try FirePHP for Firefox or FirePHP for Chrome. (or perhaps ChromePHP). These tools will help you debug and make your job super easy.

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.