Clinton Posted April 22, 2008 Share Posted April 22, 2008 Here's the code that I am using to basically verifiy someone's information and change stuff in the database. There is a double verification part that selects * from the database. How can I extract that information, and put it into variables? (In my DB I have first, middle, and last. How do I extract that and put into first = $first format?) $id = $_REQUEST['id']; $code = $_REQUEST['code']; $sql = mysql_query("UPDATE usert SET activated='1' WHERE id='$id' AND password='$code'"); $sql_doublecheck = mysql_query("SELECT * FROM usert WHERE id='$id' AND password='$code' AND activated='1'"); $doublecheck = mysql_num_rows($sql_doublecheck); if($doublecheck == 0){ echo "<strong><font color=red>Your account could not be verified! Please contact the Administrator.</font></strong>"; } elseif ($doublecheck > 0) { echo "<strong>Your e-mail address has been verified!</strong> Your will be contact shortly by the administrator for account activation.<br />"; Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/ Share on other sites More sharing options...
GingerRobot Posted April 22, 2008 Share Posted April 22, 2008 Either do something like: $row = mysql_fetch_assoc($sql_doublecheck); $first = $row['first']; Or: extract(mysql_fetch_assoc($sql_doublecheck)); echo $first;//assuming your field is called first See the manual for what happens when you use extract and there is already a variable with the field name. Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524072 Share on other sites More sharing options...
jonsjava Posted April 22, 2008 Share Posted April 22, 2008 <?php session_start(); $_SESSION['last_querry'] = 0; $id = $_REQUEST['id']; $code = $_REQUEST['code']; $sql = mysql_query("UPDATE usert SET activated='1' WHERE id='$id' AND password='$code'"); $sql_doublecheck = mysql_query("SELECT * FROM usert WHERE id='$id' AND password='$code' AND activated='1'"); $row = mysql_fetch_assoc($sql_doublecheck); $firstname = $row['first']; $middle = $row['middle']; $last = $row['last']; $doublecheck = mysql_num_rows($sql_doublecheck); if($doublecheck == 0){ echo "<strong><font color=red>Your account could not be verified! Please contact the Administrator.</font></strong>"; } elseif ($doublecheck > 0) { echo "<strong>Your e-mail address has been verified!</strong> Your will be contact shortly by the administrator for account activation.<br />"; Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524075 Share on other sites More sharing options...
947740 Posted April 22, 2008 Share Posted April 22, 2008 If you have multiple rows of data you want, you can do this: while($row = mysqli_fetch_row($doublecheck)) { // Code goes here that processes information } Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524078 Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 Never use $_REQUEST. Just don't. =( Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524080 Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 Thanks for the help folks. The only reason I'm using request is because the individual was mailed a link to basically verify their address. The only way to do pass the information via link is REQUEST. It's the only time that I use it. Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524084 Share on other sites More sharing options...
DarkWater Posted April 22, 2008 Share Posted April 22, 2008 Thanks for the help folks. The only reason I'm using request is because the individual was mailed a link to basically verify their address. The only way to do pass the information via link is REQUEST. It's the only time that I use it. Use $_GET. $_REQUEST is a combination of Get, Post, and Cookie, so it's not too safe. Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524087 Share on other sites More sharing options...
Clinton Posted April 22, 2008 Author Share Posted April 22, 2008 Ok. Didn't know that. Thank you. Link to comment https://forums.phpfreaks.com/topic/102348-solved-variable-question/#findComment-524093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.