Jump to content

[SOLVED] Use of undefined constant


jeff5656

Recommended Posts

I dont know what happened.  This code used to work.  When I process my form with the commit.php I get this:

Notice: Use of undefined constant problist - assumed 'problist' in C:\wamp\www\mc\commit.php on line 23

Notice: Use of undefined constant anticipate - assumed 'anticipate' in C:\wamp\www\mc\commit.php on line 30

Notice: Undefined index: anticipate in C:\wamp\www\mc\commit.php on line 30

Notice: Use of undefined constant comments - assumed 'comments' in C:\wamp\www\mc\commit.php on line 38

Notice: Use of undefined constant todo - assumed 'todo' in C:\wamp\www\mc\commit.php on line 45

Notice: Undefined index: race in C:\wamp\www\mc\commit.php on line 63

Notice: Undefined index: meds in C:\wamp\www\mc\commit.php on line 68

Notice: Undefined index: anticipate in C:\wamp\www\mc\commit.php on line 71

Notice: Undefined index: antic2 in C:\wamp\www\mc\commit.php on line 72

Notice: Undefined index: antic3 in C:\wamp\www\mc\commit.php on line 73

Notice: Undefined index: antic4 in C:\wamp\www\mc\commit.php on line 74

Notice: Undefined index: todo2 in C:\wamp\www\mc\commit.php on line 75

Notice: Undefined index: todo3 in C:\wamp\www\mc\commit.php on line 76

Notice: Undefined index: todo4 in C:\wamp\www\mc\commit.php on line 77

Notice: Undefined variable: vent in C:\wamp\www\mc\commit.php on line 96

Notice: Undefined variable: ventever in C:\wamp\www\mc\commit.php on line 96

Notice: Undefined variable: vent_exp in C:\wamp\www\mc\commit.php on line 96

 

I'm sorry to put the whole code here, but I don't know where the problem is.

If I echo $problist, it echos the correct value so now I'm confused. :

 

<?php
error_reporting (E_ALL);

include "connectdb.php";

$newdate = date("Y-m-d", strtotime($_POST['rcf_date']));

$current_date = date ("m/d/y");

$query = "SELECT * FROM `icu` WHERE `id_incr` = '".$_POST['id_incr']."' ";
$result = mysql_fetch_array(mysql_query($query)) or die(mysql_error());

$problist = $result['problist'];
$anticipate = $result['anticipate'];


$vent_exp = $result['vent_exp'];

$check = strtotime("now");
//if vent_exp date is older (less) than current time ($check), the user must have changed it, so reset the vent_exp date
if ($check > $vent_exp){
$vent_exp = strtotime("+6 hours");
}

$vent = $_POST['vent'];
if ($vent=='y'){
$ventever='y';
}

$comments = $result['comments'];
$todo = $result['todo'];


if($problist != $_POST[problist]) {
$problist_date = date("Y-m-d H:i:s");
}
else {
$problist_date = $result['problist_date'];
}

if($anticipate != $_POST[anticipate]) {
$anticipate_date = date("Y-m-d H:i:s");
}
else {
$anticipate_date = $result['anticipate_date'];
}


if($comments != $_POST[comments]) {
$comments_date = date("Y-m-d H:i:s");
}
else {
$comments_date = $result['comments_date'];
}

if($todo != $_POST[todo]) {
$todo_date = date("Y-m-d H:i:s");
}
else {
$todo_date = $result['todo_date'];
}

$id_incr = mysql_real_escape_string($_POST['id_incr']);


$rm_loc_pre = mysql_real_escape_string($_POST['rm_loc']);
$rm_loc = ereg_replace("[^A-Za-z0-9]", "", $rm_loc_pre);
$resident = mysql_real_escape_string($_POST['resident']);
$pulmonologist = mysql_real_escape_string($_POST['pulmonologist']);

$patient = mysql_real_escape_string($_POST['patient']);
$mrn = mysql_real_escape_string($_POST['mrn']);
$age =mysql_real_escape_string($_POST['age']);
$race = mysql_real_escape_string( $_POST['race']);
$gender = mysql_real_escape_string( $_POST['gender']);
$pod = mysql_real_escape_string( $_POST['pod']);
$rcf_date = mysql_real_escape_string($_POST['rcf_date']);
$dx = mysql_real_escape_string( $_POST['dx']);
$meds = mysql_real_escape_string( $_POST['meds']);
$pmhx = mysql_real_escape_string( $_POST['pmhx']);
$problist = mysql_real_escape_string( $_POST['problist']);
$anticipate = mysql_real_escape_string( $_POST['anticipate']);
$antic2 = mysql_real_escape_string( $_POST['antic2']);
$antic3 = mysql_real_escape_string( $_POST['antic3']);
$antic4 = mysql_real_escape_string( $_POST['antic4']);
$todo2 = mysql_real_escape_string( $_POST['todo2']);
$todo3 = mysql_real_escape_string( $_POST['todo3']);
$todo4 = mysql_real_escape_string( $_POST['todo4']);
$comments = mysql_real_escape_string( $_POST['comments']);
$code = mysql_real_escape_string( $_POST['code']);
$allergy = mysql_real_escape_string( $_POST['allergy']);
$todo = mysql_real_escape_string($_POST['todo']);
$signoff_status = mysql_real_escape_string( $_POST['signoff_status']);
$rcf_date2 = $newdate;

$current_date = date ("m/d/y");

$timestamp1 = strtotime($_POST['rcf_date']); 
$timestamp2 = strtotime($current_date); 

$diffrenc = $timestamp2-$timestamp1; 

$icudays = round(($diffrenc/86400));



$sql = "UPDATE icu SET rm_loc = '$rm_loc', patient = '$patient', vent='$vent', ventever = '$ventever',vent_exp='$vent_exp',pulmonologist = '$pulmonologist', mrn = '$mrn', age = '$age',  icudays = '$icudays', race='$race', gender='$gender', pod='$pod', resident = '$resident',rcf_date='$rcf_date', dx='$dx', meds='$meds', pmhx='$pmhx', problist='$problist', problist_date= '$problist_date', anticipate='$anticipate', anticipate_date = '$anticipate_date', comments='$comments', comments_date = '$comments_date', code='$code', allergy='$allergy', todo='$todo', todo_date='$todo_date', signoff_status='$signoff_status', rcf_date2='$rcf_date2' WHERE id_incr = '$id_incr'";



if (isset($sql) && !empty($sql)) {
$result = mysql_query($sql) or die ("Invalid query: " . mysql_error());


}
header("Location: displayactive.php#mm".$id_incr);

?>

Link to comment
Share on other sites

$_POST[anticipate])

will give that notice message

$_POST['anticipate'])

will not.

It's most commonly encountered when associative keys for array entries aren't quoted.

PHP assumes that a "name" without quotes (to identify it as a string) or a $ (to identify it as a variable) is a constant. Because there is no constant called "anticipate" in your code, it issues this notice. It then treats the text as though it was a quoted string, so the code will still work correctly (in this case). To get rid of the messages, simply quote your associative keys

Link to comment
Share on other sites

I went back and put the quotes in:

if($anticipate != $_POST['anticipate']) {
$anticipate_date = date("Y-m-d H:i:s");
}
else {
$anticipate_date = $result['anticipate_date'];
}

 

And still got:

Notice: Undefined index: anticipate in C:\wamp\www\mc\commit.php on line 40

Notice: Undefined index: race in C:\wamp\www\mc\commit.php on line 73

Notice: Undefined index: meds in C:\wamp\www\mc\commit.php on line 78
etc...

 

This code is cut and paste from other form processing code that DOES work.  SO with all these erros I don't think it is the actualy code - it must be something else - like not connecting to the database (although in this case I think I am).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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