SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sending multiple emails

    Hi guys

    Im getting this error when sending multiple emails. It sends the first one ok
    its the second one im getting the error


    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/notexper/public_html/apply.php on line 277

    line 277
    PHP Code:
       $emailrow2 mysql_fetch_array($emailresult2); 


    PHP Code:

    <?php
    session_start
    () ;



    if (
    $_SESSION["seeker"]) {
    header("location: ");
    }

    elseif (
    $_SESSION["loggedin"]) {
    header("location: error.php");
    }

    else{
    header('Location: login.php?return='.$_SERVER['REQUEST_URI']);
                    
    }

    ?>
    <!-- saved from url=(0022)http://internet.e-mail -->
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Not Experienced</title>

    <link rel="stylesheet" type="text/css" href="style.css" />

    </head>

    <body>

    <?php include ("header.php"?>
    <?php 
    include ("nav.php"?>
    <div id="main">
     
         <div class="featured">
           <p>Recruiting now...</p>
               <font size="4" face="century gothic">
            
          </div>

          <div id="content">
            <p class="title"><font color="white"> </font></p>
    <?PHP


    $id 
    $_GET['id'];


    $con mysql_connect("localhost","notexper_two","three");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("notexper_one"$con);



    $cv mysql_query("SELECT * FROM CV where user_id = '"$_SESSION['seeker'] ."'");
    if (
    mysql_num_rows($cv) == 0) {
        echo 
    '<font size="4">
        <b>Error</b><br>
        You need to add your CV before applying for jobs.
        <bR>
        <bR>
        <a href="addmycv.php">Add a CV</a>
        <br>
        <a href="myaccount.php">Return To My Account</A>'
    ;
        
        
        include 
    "footer.php";

        
        
        
    // there's already one entry by $user
    }




    $result mysql_query("SELECT * FROM applications where user_id = '"$_SESSION['seeker'] ."' AND id=$id ");
    if (
    mysql_num_rows($result) == 1) {
        echo 
    '<font size="4">
        <b>Error</b><br>
        You have already sent a application for this job.
        <bR>
        <bR>
        <a href="applications.php">View My Application</a>
        <br>
        <a href="search.php">Search Other jobs</A>'
    ;
        
        
        include 
    "footer.php";

        
        
        
    // there's already one entry by $user
    } else { ?>
    <?php

    //connect to your database ** EDIT REQUIRED HERE **
    mysql_connect("localhost","notexper_two","three"); //(host, username, password)
    //specify database ** EDIT REQUIRED HERE **
    mysql_select_db("notexper_one") or die("Unable to select database"); //select which database were using


      
    $id $_GET["id"];

    $sql = ("select * from   jobs where id=$id"); 


                  
    $result mysql_query ($sql);

                  while (
    $row mysql_fetch_array($result))
                  {
                  
    $field13$row["applications"]; 
                                               
    }
    ?>










    <?php

    // Change these two variables to meet your needs.


    $op $_POST[op];

    if(
    $op == 'contact')
    {
        
    $coverletter stripslashes($_POST[coverletter]);


        if(!
    $coverletter)
        {
            
    $status .= "<font color=red size=3>- Please enter a cover letter.</font><br>";
        }


    if(!
    $status)
        {
           



    session_start();

    $con mysql_connect("localhost","notexper_two","three");
    if (!
    $con){ die('Could not connect: ' mysql_error()); }
    mysql_select_db("notexper_one"$con);


    $formofcontact $_POST['formofcontact'];
    $id $_POST['id'];
    $coverletter $_POST['coverletter'];
    $sql "
            INSERT INTO
                applications
        (coverletter,id,formofcontact,user_id)
            VALUES
        ('"
    $coverletter ."','"$id ."','"$formofcontact ."','".$_SESSION['seeker']."')";

    $query mysql_query($sql,$con) or die('Error: ' mysql_error());








     
    //Add 1 to application field and save the listing


      
    $qry "UPDATE jobs SET applications = applications + '1'  WHERE id=$id";


    $result mysql_query($qry,$con) or die(mysql_error());






    echo(
    "application sent");






    // Send Password to email

    //connect to your database ** EDIT REQUIRED HERE ** 

    mysql_connect("localhost","notexper_two","three"); //(host, username, password) 



    //specify database ** EDIT REQUIRED HERE ** 

    mysql_select_db("notexper_one") or die("Unable to select database"); //select which database we're using 



         



    $sendemail = ("select * from jobseekers where user_id = '"$_SESSION['seeker'] ."'"); 



                 
    $emailresult mysql_query ($sendemail); 



                 
    $emailrow mysql_fetch_array($emailresult);



    // send email 



    $to      $emailrow["user_email"];





    $subject 'Your have applied for job'



    $message 'Thank you for adding your job to Not Experienced'



    $headers 'From: support@notexperienced.co.uk'


    if(!
    mail($to$subject$message$headers))











    $sendemail2 " select * from members where id=$id";



                 
    $emailresult2 mysql_query ($sendemail2); 



                 
    $emailrow2 mysql_fetch_array($emailresult2);



    // send email 



    $to1      $emailrow2["user_email"];





    $subject1 'Your have recieved a application'



    $message1 'Thank you for adding your job to Not Experienced'



    $headers1 'From: support@notexperienced.co.uk'


    if(!
    mail($to1$subject1$message1$headers1))










    mysql_close($con);




    include 
    'footer.php';



    exit();

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    cange your query line to:
    PHP Code:
    $emailresult2 mysql_query ($sendemail2) or die(mysql_error()); 
    and see what the message is
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It says

    Query was empty

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    ok, now change it to:
    PHP Code:
    $emailresult2 mysql_query ($sendemail2) or die(mysql_error() . 'QUERY=> '$sendemail2); 
    Is the query line as it should be?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Guru
    Join Date
    Oct 2004
    Location
    uk
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Query was empty QUERY=>

    PHP Code:
    $sendemail2 = ("select * from members INNER JOIN jobs  ON members.user_id= jobs.user_id WHERE jobs.id='$id'"); 
    is my query seems to be correct

    weird thing is I tried a different one which does 100% work and I got same error


    could it be something to do with the first email that im sending above the current one

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    possibly, change your code to:
    PHP Code:
    /// - same for both
    $subject 'Your have applied for job'
    $message 'Thank you for adding your job to Not Experienced'
    $headers 'From: support@notexperienced.co.uk'
    ///

    $sendemail = ("select * from jobseekers where user_id = '"$_SESSION['seeker'] ."'"); 
    $emailresult mysql_query ($sendemail); 
    if(
    mysql_num_rows($sendemail) > 0) {
        
    $emailrow mysql_fetch_array($emailresult);
        
    $to $emailrow['user_email'];    
    } else {
        
    $sendemail2 " select * from members where id=$id";
        
    $emailresult2 mysql_query ($sendemail2); 
        
    $emailrow mysql_fetch_array($emailresult);
        
    $to $emailrow2["user_email"];
    }
    if(!
    mail($to$subject$message$headers)) {
        echo 
    "No Mail Sent";

    Can you clarify for me, is it that if the SESSION variable is set - use that members email address otherwise use the one associated with $id?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •