Rifts Posted March 13, 2010 Share Posted March 13, 2010 Hey guys i'm pretty new to php and I think this is a pretty simple question im just trying to pull a value from my database and display that value (in the end i actually want to see if the value =1 or =0) the db name is "clients" the table name is "members" and value is named "active" here is the code i tried without success : (above the code is all the connect info for the database so i didnt think you really needed that) $memberid = $_SESSION['SESS_MEMBER_ID']; $sql = "UPDATE members " . "SELECT active " . "WHERE member_id = '$memberid';"; $result = mysql_query($sql); //Check whether the query was successful or not if($result = 1) { header("location: index.php"); exit(); }else { header("location: www.google.php"); } when i run this no matter what is just goes to index.php Thanks Link to comment https://forums.phpfreaks.com/topic/195091-pulling-a-value-from-mysql/ Share on other sites More sharing options...
Rustywolf Posted March 13, 2010 Share Posted March 13, 2010 $memberid = $_SESSION['SESS_MEMBER_ID']; $sql = "UPDATE members " . "SET active=TRUE " . "WHERE member_id = '$memberid'"; $result = mysql_query($sql) OR DIE('<meta http-equiv="refresh" content="0;url=http://www.google.com/">'); echo '<meta http-equiv="refresh" content="0;url=index.php">'; when i run this no matter what is just goes to index.php Thanks Link to comment https://forums.phpfreaks.com/topic/195091-pulling-a-value-from-mysql/#findComment-1025516 Share on other sites More sharing options...
Rifts Posted March 13, 2010 Author Share Posted March 13, 2010 ok well i got it to display either a 0 or a 1 using this code $memberid = $_SESSION['SESS_MEMBER_ID']; $sql = ("SELECT active FROM members WHERE member_id='$memberid'"); $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { echo $row["active"]; now i just need to figure out how to check to see if its a 1 or a 0 and if its a 1 go to index if its a 0 go to xxxxxx.com Link to comment https://forums.phpfreaks.com/topic/195091-pulling-a-value-from-mysql/#findComment-1025518 Share on other sites More sharing options...
Rifts Posted March 13, 2010 Author Share Posted March 13, 2010 i figured it all out thanks for future when i was comparing the value i was using "=" instead of "==" lol beginner mistake Link to comment https://forums.phpfreaks.com/topic/195091-pulling-a-value-from-mysql/#findComment-1025537 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.