Jump to content

Pulling a value from mysql


Rifts

Recommended Posts

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

$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

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.