will35010 Posted November 29, 2009 Share Posted November 29, 2009 I'm having a problem with the if at the bottom of the script. The variable $current is set using a select box that has two options: ER & Lobby. The varible comes across ok, but the if always treats the varible as if it's set to lobby. What am I doing wrong? Thanks! <?php /** * @author Will Morris * @copyright 2009 */ //code to receive post data and add it to the database //POST data varible assignment $lname = $_POST['lname']; $fname = $_POST['fname']; $mrn = time(); $room = $_POST['room']; $pmd = $_POST['pmd']; $current_status = "Waiting on Room"; $comment = $_POST['comment']; $regtime = time(); $current = $_POST['current']; $arrive = $_POST['arrive']; $age = $_POST['age']; $sex = $_POST['sex']; $cc = $_POST['cc']; $ccother = $_POST['ccother']; //for testing //echo "Varible Current .'$current'."; require('../db.php'); //Query to insert patient data $query = "INSERT INTO pt_status (PATIENT_LAST_NAME, PATIENT_FIRST_NAME, MRN, ER_ROOM_NUMBER, PMD, CURRENT_STATUS, COMMENT, REG_TIME, CURRENT_LOCATION, ARRIVE, AGE, SEX, CC, CCOTHER) VALUES ('$lname', '$fname', '$mrn', '$room', '$pmd', '$current_status', '$comment', '$regtime', '$current', '$arrive', '$age', '$sex', '$cc', '$ccother')"; //send query to database mysqli_query($conn, $query) or die('Error: ' . mysql_error()); //logic to either assign patient to lobby or room //if to assign pt to lobby if($current = "Lobby") { $sql = "INSERT INTO `TRAX2`.`lobby` (`MRN`, `TIMESTAMP`) VALUES ('$mrn', '$mrn');"; mysqli_query($conn, $sql); //if to assign pt to room } elseif($current = "ER") { //test echo output echo "ER Insert"; $sql = "INSERT INTO rooms ('STATUS', 'MRN') VALUES ('1', '$mrn') WHERE NAME = '$room'"; mysqli_query($conn, $sql); } echo "<a href='../index.php'>Home Page</a>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/183308-if-statement-or-varible-problem/ Share on other sites More sharing options...
.josh Posted November 29, 2009 Share Posted November 29, 2009 = is assignment operator == is equality operator Quote Link to comment https://forums.phpfreaks.com/topic/183308-if-statement-or-varible-problem/#findComment-967586 Share on other sites More sharing options...
will35010 Posted November 29, 2009 Author Share Posted November 29, 2009 = is assignment operator == is equality operator Thanks! I knew it was something easy. lol Quote Link to comment https://forums.phpfreaks.com/topic/183308-if-statement-or-varible-problem/#findComment-967595 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.