Solved

Resource id #5 or Resource id #3

Posted on 2009-07-02
21
1,444 Views
Last Modified: 2012-05-07
evaluating why the print_r command will not work while checking $variables to see if they exist in the database.... spent a couple of hours already on this and the EXPERT there said he didn't know what is wrong.

the results of the print_r on the page are:
Resource id #5 for one
Resource id #3 for another

the original problem was never answered.  but the new problem is below (the code for the new problem)  maybe this will answer the original problem----- why the variables will not print out in the php mail() application on the screen or in the email that is delivered to the customer. (ie: name and password)

<?php

                    $provide_id = "SELECT * FROM dealer_user WHERE d_email = '$d_email'" 

        or die ('ERROR - No ID Possible, contact Network Administrator!' . mysql_error());

        $result = mysql_query($provide_id); 

        //$row = mysql_num_rows($result1);  

        $rowEmail=mysql_fetch_assoc($result); 

        print_r($rowEmail);

            print_r($result);

            //print_r($d_email);

        if (!$result1) {

        print 'ERROR: Dealer Email not retrieved';

        }

//else if (!isset($_POST['submit']))

//{

$provide_pass = "SELECT * FROM dealer_user WHERE d_pass = '$d_pass'"  

        or die ('ERROR: No Dealer Name Possible, contact Network Administrator!' . mysql_error());

        $result2 = mysql_query($provide_pass); 

        //$row2 = mysql_num_rows($result2);

        $rowPass=mysql_fetch_array($result2); 

        //print_r($rowEmail);

            print_r($result1);

            print_r($d_email);  

if (!$result2) {

        print 'ERROR: Dealer Email not retrieved';

        }     

        ?>

Open in new window

0
Comment
Question by:digigirl1124
  • 13
  • 8
21 Comments
 

Author Comment

by:digigirl1124
ID: 24770349
BTW... THANK YOU , IN  ADVANCE!!!

i have been beating my head over this for three days now, and i really need to move on to something more important!!! lol  
0
 

Author Comment

by:digigirl1124
ID: 24770499
$rowEmail=mysql_fetch_array($result1);
        print_r($rowEmail);
            print_r($result1);
         echo date("m/d/y");

THE RESPONSE TO THESE PRINT COMMANDS ARE:
000
Resource id #5
07/02/09         
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24771268
$resul1 is a query resource, which is why print($result1) will resuling "Resource id #xxxxx"

check out
print $rowEmail["column_name_from_table"];
0
 

Author Comment

by:digigirl1124
ID: 24773900
as I said in the beginning of this post... this error was the result of another problem that was never resolved because we couldn't move forward until this error was fixed.  So, I don't think the solution you have given will give us what we need.  But, thank you for taking the time to respond.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24774155
well, I tried to find out what the question is, and could not really find any that I could really answer, missing some input.
so, I tried to answer what I found.

so, what is the "problem" actually?

ie, you write:
>why the variables will not print out in the php mail() application on the screen or in the email that is delivered to the customer. (ie: name and password)

which variable? you mention "name and password", but what variables?
0
 

Author Comment

by:digigirl1124
ID: 24777796
I don't know if I can repeat the same problem here that I have on another post? Can you advise on that?
 What I am trying to do is pass the variables from the database to the mail() application so it will send an email showing the user's log in information (userid and password).  The person who responded to the original question did not provide an answer, but in trying to give an answer asked me to include the print_r function, which i did, but I never received an answer as to what he/she was trying to accomplish, with the results (or non-results) of this print_r, and he/she never responded that evening with any other suggestions.  So, I started another post asking what the print_r results meant, and this is where it came to you.  I feel like I am running in circles.  If I can have two posts with the same question, then I can provide whatever information you need.  Otherwise, I will have to wait and hope someone knows the answer and posts it to the open one for this example.
Thanks so much!
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24777810
>So, I started another post asking what the print_r results meant,
RTFM: http://www.php.net/manual/en/function.print-r.php
it prints out the content of a variable. very useful when the variable is an array of object, as it goes down to the array items and object properties...

> What I am trying to do is pass the variables from the database to the mail() application
in your current code, I can't see any mail() related code, so I don't see where the problem actually is.

anyhow, in your code you will have something like:

 

$row_data = mysql_fetch_array($query_result); 

$user_name = $row_data["user_name"];

$login_name = $row_data["login_name"];

$pass_word= $row_data["pass_word"];

$email_address = $row_data["email_address"];
 

$email_body = "hi, {$user_name},\n here is your login and password information:\nlogin:{$login_name}\npassword:{$pass_word}\n\nif you have any problems connecting, please contact ....  blabla bla";
 

mail($email_address, "LOGIN INFO", $email_body );

Open in new window

0
 

Author Comment

by:digigirl1124
ID: 24777841
thanks so much!  I will try this and let you know!!!
0
 

Author Comment

by:digigirl1124
ID: 24777881
Unfortunately, this did not work either.  I received the email but nothing was included for the variables that are supposed to be passed.  I have tried everything I can think of, everything I have found on the internet, the suggestions given on this forum and so far, it just doesn't work!  I have posted my mail code below to see if it is something there.  If you could take a look at that, It would be very much appreciated!!!!

Email I received as result::::

Dear:
Thank you for registering for an accountl!
To activate your membership, please go to:
http://www.ourcompany.com to Log In
Once you Login, your account will activate.
Your Email is:
Your Password is:

Thank You! From Joe


MAIL CODE BELOW:

$dname = $dNameMail["dealer_name"];
$varFrom = "warrantyrequest@companyname.com";
$emailTo1 = $rowEmail["d_email"];
$emailTo2 = "lmyemail@gmail.com"; // so i get a copy of the email sent to the user
$pass1 = $rowPass["d_pass"];
$varTo = "$emailTo1 , $emailTo2";
$varSubject = "Dealer Portal Registration";
//$msgBody = "";
// main variables above

$varFrom .= "From: warrantyrequest@companyname.com";
$msgBody = "";
$msgBody = "Dear:" ."$emailTo1"."\r\n";
$msgBody .= "Thank you for registering for an account with Our Company!"."\r\n";
$msgBody .= "To activate your membership, please go to:" ."\r\n";
$msgBody .= "http://www.ourcompanyl.com to Log In" ."\r\n";
$msgBody .= "Once you Login, your account will activate." ."\r\n";
$msgBody .= "Your Email is: $goodMail"."\r\n";
$msgBody .= "Your Password is: $pass1"."\r\n";
$msgBody .= "Thank You! From Joe at our Company" ."\r\n";
//"This is an automated activation e-mail, please do not reply!" ."\r\n";
$varMailHeader .= "From: ".$varFrom."\r\n";
$varMailHeader .= "CC: testingemail@aim.com"."\r\n";
$varMailHeader .= "Return-Path: ".$varFrom."\r\n";
$varMailHeader .= "Return-Receipt-To: ".$varFrom."\r\n";
$varMailHeader .= "Reply-To: warrantyrequest@ourcompany.com"."\r\n";
$varMailHeader .= "X-Mailer:PHP/".phpversion()."\r\n";
//$spam_check = strpos($msgBody,"http://");
//If (!$spam_check)
//    {  
$mailsend = mail($varTo, $varSubject, $msgBody, $varMailHeader);
//    }
//echo $mailsend;
if ($mailsend)
    {
    echo "Your registration was successful $emailTo1!  A confirmation is being emailed to the Email address you provided.  Follow the instructions in that email to login to your account";
    }
ANOTHER OPTION I HAVE USED FOR THE MAIL SEND IS:
if (!mailsend){
        echo 'Your mail could not be sent.' . mysql_error();
    }
else    {

    session_write_close();
    echo header("Location: /html/thankyou.html");
}
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 24777888
$msgBody = "Dear:" ."$emailTo1"."\r\n";
seems a bit odd, nevertheless should it work. if you are using string concatenation, you shall remove the double quotes around the variable:
$msgBody = "Dear:" . $emailTo1 ."\r\n";


so, this part seems just fine.
the problem MUST be on the query part.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:digigirl1124
ID: 24777964
this part isn't working.... Dear shows up fine... it is the variable $emailTo1 that doesn't show up.
Also, the other variables do not show up in the email ---;
$msgBody .= "Your Email is: $goodMail"."\r\n";
$msgBody .= "Your Password is: $pass1"."\r\n";

Below is the query for the dealer name....
(( the other query is set up on the first registration page, but it works fine.  The info is posted into the database fine, and when I log in it calls it from the database, so I know it is working INSERT-ing it.))

regPage2:
Gathers the dealer contact information:
:
$query = ("INSERT INTO dealers (dealer_name, dealer_address, dealer_address2, dealer_city, dealer_state, dealer_country, dealer_zipcode,  dealer_Acode, dealer_phone, dealer_AcodeCell, dealer_cell, dealer_AcodeFax, dealer_fax, dealer_contact, dealer_salesContact, dealer_serviceContact, dealer_partsContact, db_password, trackerID)
VALUES ('".$_POST['dealer_name']."', '".$_POST['dealer_address']."', '".$_POST['dealer_address2']."', '".$_POST['dealer_city']."', '".$_POST['dealer_state']."', '".$_POST['dealer_country']."','".$_POST['dealer_zipcode']."', '".$_POST['dealer_Acode']."', '".$_POST['dealer_phone']."', '".$_POST['dealer_AcodeCell']."', '".$_POST['dealer_cell']."', '".$_POST['dealer_AcodeFax']."', '".$_POST['dealer_fax']."', '".$_POST['dealer_contact']."', '".$_POST['dealer_salesContact']."', '".$_POST['dealer_serviceContact']."', '".$_POST['dealer_partsContact']."', '".$_POST['db_password']."', '".$_SESSION['trackerID']."')");
$result = mysql_query($query);
$newDealer = mysql_fetch_array($result);      
if(!$newDealer)
            {
//HERE I CHECK THE SESSION COUNT IF THERE IS AN ERROR
      $count = $_SESSION['COUNT'];
            $moreCount = $count+1;
            echo 'Session' . $moreCount;
            echo "There has been an error creating your account.
            Please contact the webmaster." . mysql_error();
            }
else {
//THIS IS FOR ME TO SEE IF IT WORKS    
echo $newDealer['dealer_name'];
    }
   
//BELOW IS THE QUERY FOR THE USER ID AND PASSWORD:

$query = "SELECT d_email FROM dealer_user, dealers WHERE dealer_user.dealer_id = dealers.trackerID;"
        or die ("ERROR - No user Exists, contact Network Administrator!" . mysql_error());
        $result = mysql_query($query);
        $rowEmail = mysql_fetch_array($result);
        if (!rowEmail)
        {
        echo 'There has been a database error!! Please contact the web administrator.' . mysql_error();
        }
        else
        {
         echo $rowEmail['d_email'];
        }


//FOR PASSWORD
$query = "SELECT d_pass FROM dealer_user, dealers WHERE dealer_user.dealer_id = dealers.trackerID;"
        or die ('ERROR - No ID Possible, contact Network Administrator!' . mysql_error());
        $result = mysql_query($query);
        //$rowPass = mysql_num_rows($result1);  
        $rowPass = mysql_fetch_array($result);      
        if (!rowPass)
        {
        print 'ERROR: Dealer Email not retrieved' . mysql_error();
        }
        else
        {
         echo $rowPass['d_pass'];
         echo $rowPass["$d_pass"];
        }


//ANOTHER ONE I HAVE TRIED TO RETRIEVE THE DEALER NAME;
$dealerName = "SELECT dealer_name FROM dealers";
$result = mysql_query($dealerName);
$dNameMail = mysql_fetch_array($result);      
if(!$dNameMail)
        {
            $count = $_SESSION['COUNT'];
            $moreCount = $count+1;
            echo 'Session' . $moreCount;
            echo "There has been an error sending your mail.
            Please contact the webmaster." . mysql_error();
        }
        else
        {
            echo $dNameMail["$dealer_name"];
            echo $dNameMail['dealer_name'];
        }

THANK YOU FOR HELPING!!!! (-:
0
 

Author Comment

by:digigirl1124
ID: 24777998
just tried registering again.... received an email, but no dealer name, dealer id, dealer password.  HOPELESS?
0
 

Author Comment

by:digigirl1124
ID: 24778085
HAS ANYONE EVER TOLD YOU HOW WONDERFUL YOU ARE???????
OMG!!!!!  IT WORKED... it is now showing in the email (see below!!!)))
I don't know what we did, but it worked!!!!!!!
Thank you , you are wonderful!!!  Would it be sexual harassment if i kiss you??!!!
 mwah! mwah, mwah!!!  (-:

I CHANGED the variables to the below different styles and the email I received is showing below:

$msgBody = "Dear:" .$emailTo1. "AT" .$newDealer["dealer_name"]. "OR". $dname ."WITHOUT USING THE DOUBLE QUOTES"."\r\n";
$msgBody = "Dear: $emailTo1 AT $dname ALL IN THE SAME SENTENCE, NO CONCAT\r\n";
$msgBody .= "Thank you for registering for an account with Bad Boy Dealer Portal!"."\r\n";
$msgBody .= "To activate your membership, please go to:" ."\r\n";
$msgBody .= "http://www.badboydealerportal.com to Log In" ."\r\n";
$msgBody .= "Once you Login, your account will activate." ."\r\n";
$msgBody .= "Your Email is:" .$emailTo1."\r\n";
$msgBody .= "Your Password is:" .$pass1. "\r\n";
$msgBody .= "Thank You! From Joe at Bad Boy Buggies" ."\r\n";

//it appears the concat without the double quotes made it work.  The second one (entire sentence in double quotes) did not!!!
Dear: helen@helen.com AT helen with new variable sets WITHOUT USING THE DOUBLE QUOTES
Thank you for registering for an account with Bad Boy Dealer Portal!
To activate your membership, please go to:
http://www.badboydealerportal.com to Log In
Once you Login, your account will activate.
Your Email is:helen@helen.com
//OH NO!!!  HOW DO I GET THE REAL PASSWORD, INSTEAD OF THE ONE THAT IS ENCRYPED???
Your Password is:7a2eb41a38a8f4e39c1586649da21e5f
Thank You! From Joe at Bad Boy Buggies

I have another question, though... ( a good man's/woman's work is never done!)
 HOW DO I GET THE REAL PASSWORD, INSTEAD OF THE ONE THAT IS ENCRYPED???
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24778097
>Thank you , you are wonderful!!!  Would it be sexual harassment if i kiss you??!!!
if you are a girl, we could discuss :)

> HOW DO I GET THE REAL PASSWORD, INSTEAD OF THE ONE THAT IS ENCRYPED???
$pass1 has the encrypted data. what you need is to decrypt it (or have the data unencrypted passed to the script)
0
 

Author Comment

by:digigirl1124
ID: 24778159
actually... i didn't realize I had changed it around after I posted it here...
it is the line with ALL OF THE VARIABLES AND EVERYTHING IN ONE SENTENCE that works!!!
It appears that the concat DOES NOT work inside the body of the email when using variables!

Again, thank you!  do you know how to show the password before it is encrypted?

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24778165
where do you encrypt it?
you probably need to put the password to the session data.
unless, of course, you can decrypt it.
so, the question is again: how do you encrypt it?

0
 

Author Comment

by:digigirl1124
ID: 24778172
I'm sorry I didn't see your last post answering the password problem.  I will give it a try!!
Now.... there is another issue.  Do we need to start a new forum so you can get new points??? the last one worked, so I can accept and award points, but I want you to help me with the next issue too!!  PLEASE PLEASE PLEASE!! (yes I am a girl, can't you tell!! lol)
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24778176
>but I want you to help me with the next issue too!!
no problem, except that right now, I will get to bed ... (midnight here)...

>yes I am a girl, can't you tell!! lol
:)
0
 

Author Comment

by:digigirl1124
ID: 24778200
ok. how can i find you tomorrow so you can help me?  i am new at this.
also, how do we pay for the answered questions?
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24778202
>how do we pay for the answered questions?
you close the question by awarding the comment(s) that helped you.

then, you should ask a related question.
a3
0
 

Author Closing Comment

by:digigirl1124
ID: 31599465
Another patient and helpful Expert!!!  I am so excited to have found this forum (a referral)!!  Will definitely pass it on to others.  angellll, you are awesome!!  Something that I have been working with for a few days now was answered quickly by a real angel -- angellll-- at EE.  I can't thank you enough!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now