austin752 Posted April 5, 2012 Share Posted April 5, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260372-this-is-driving-me-nuts/ Share on other sites More sharing options...
AyKay47 Posted April 5, 2012 Share Posted April 5, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/260372-this-is-driving-me-nuts/#findComment-1334512 Share on other sites More sharing options...
austin752 Posted April 5, 2012 Author Share Posted April 5, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/260372-this-is-driving-me-nuts/#findComment-1334517 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.