Jump to content

This is driving me nuts


austin752

Recommended Posts

I have been coding in circles and I can't take it anymore!

 

This is my code:

 

$sqlid = "select * from temp where Email='".$a[8]."'";

$idresult = mysql_query($sqlid);

$res  =  mysql_fetch_assoc($idresult);

  if ($idresult > 0)

  {

$tempid = $res['ID'];

die('sql id:' . $tempid . 'or' . $res['ID']. 'or ' . $sqlid );

  }elseif (!$idresult) {

die('there is no sql id');

  }

 

I am trying to populate the variable $tempid with the ID from the temp table.

I know i am not the best coder but I thought I was close.

 

I keep getting different errors.

Some errors simply print out the sql select statement to the screen

Other errors give me a resource #10.

 

Please help. I can't think straight anymore. Im sure it's something simple.

 

 

Link to comment
Share on other sites

you are trying to compare a resource to an integer, the code should read:

 

$sqlid = "select * from temp where Email='".$a[8]."'";
$idresult = mysql_query($sqlid) or die(mysql_error());
$res  =  mysql_fetch_assoc($idresult); 
if (mysql_num_rows($idresult) > 0)
{
   $tempid = $res['ID'];
   die('sql id:' . $tempid . 'or' . $res['ID']. 'or ' . $sqlid );
}

 

also, don't use die()'s to display messages, they are very user unfriendly.

Link to comment
Share on other sites

That didnt work.

 

With all of my extra code stripped out, the basic function I need is to pass the

ID of the member into a variable that populates a field in an email to validate the email address.

 

$sqlid = "select * from temp where Email='".$a[8]."'";

$idresult = mysql_query($sqlid) or die(mysql_error());

$res  =  mysql_fetch_assoc($idresult);

if (mysql_num_rows($idresult) > 0)

{

  $tempid = $res['ID'];

}

 

 

      $message = "Dear member,<BR><BR>";

      $message = $message . "Welcome to " . $sitename . ".<BR>";

      $message = $message . "Thank you for registering.<br />

  Please click the button below to activate your account. You will not be able to access the download area, the member benefits, or be eligible for earnings until you activate your account.<br /><br />";

      $message = $message . "<a href=" . $siteurl . "/activate.php?e=".$a['8']."&b=verify&id=".$tempid."> Click here to finish activating your account -></a><BR>";

 

When I added your snippet it still didn't insert the ID into the right place.

 

Just before this code is:

 

include "config.php";

$sql_i="insert into temp(Name,Address,City,State,Zip,Country,Phone,Email,Password,PaymentDetails,ref_by,IP,Date) values

              (

              '$a[1]',

              '$a[2]',

              '$a[3]',

              '$a[4]',

              '$a[5]',

              '$a[6]',

              '$a[7]',

              '$a[8]',

              '$a[9]',

              '$a[10]',

              '$a[11]',

              '$a[12]',

              now()

              )";

 

I am guessing this is when the id is created. then I want  to pull the ID out right after the fields are populated. Make sense?  :confused:

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.