FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » missing variable
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: missing variable [message #175844 is a reply to message #175839] Sun, 30 October 2011 12:59 Go to previous messageGo to previous message
bill is currently offline  bill
Messages: 310
Registered: October 2010
Karma:
Senior Member
On 10/29/2011 5:35 PM, Thomas Mlynarczyk wrote:
> bill schrieb:
>
>> $history = "empty appointment filled ";
>> echo " history: $history\n";
>
> Looks okay to me.
>
>> when it executes I get a PHP Notice
>> PHP Notice: Undefined variable: history in
>> /var/www/MP2010-v2/classes/cSchedule.php on line 108
>
> Assuming the two lines of code above are 107 and 108 (and that
> you indeed copypasted them) I see no reason for this error.
>
>> however if I use:
>> $history = "xxx";
>> echo " history: $history\n";
>> it executes fine.
>
> Just replacing "empty appointment filled " in the above code with
> "xxx" has this effect? That simply cannot be.
>
>> To say I am puzzled is a vast understatement.
>
> From my own experience I can tell that such incomprehensible
> behaviour usually indicates a very simple mistake.
>
>> If I paste it into a test script, it runs fine so it is
>> obviously in the other 200 lines.
>
> So we will obviously need to see those other lines. Maybe you can
> trim them down somewhat. And while doing this you might see the
> cause of the problem yourself.
>
>> If I rename the variable "hist" I get the same error
>
> Global search & replace? Or manually just in those two lines?
>
>> THis is running from the command line.
>
> Shouldn't matter, but one never knows.
>
> Greetings,
> Thomas
>
>

Here is the top half of the function, as it works:
---
public function mCreateAppointment($user, $apptTime, $location,
$duration, $standing, $ptNum, $notify, $comment ) { // create a
new appointment - may be non-pt or empty
// look for identical empty appointment
$sql = "select schedule_id
from schedule
where user='$user' and
apptTime = '$apptTime'and
duration = '$duration' and
appt_status = 'e'
limit 1";
$result =mysql_query( $sql, $this->connection) or
die("MySql ERROR in cSchedule on line " . __LINE__ . " " .
mysql_error()) ;

if (mysql_num_rows($result)) { // found an identical empty
appt, use it
$row = mysql_fetch_array($result);
$id = $row['schedule_id'];
if ($ptNum == "empty") return // do nothing, do not need to
create an empty appointment, as there is already an identical one

$hist = "";
$hist = "empty appointment filled ". nowUS() ." by "
..$_SESSION['current_user'] . "\n";

echo __CLASS__ . "-" . __FUNCTION__ . ": " . __LINE__ . "
history: $hist\n";

$sql = "update schedule set
user = '$user',
location='$location',
standing_script = '$standing',
appt_status = 'a',
patient_number = '$ptNum',
notify = '$notify',
comment = '$comment',
history = concat(history, '$hist')
where schedule_id ='$id' ";
echo __CLASS__ . "-" . __FUNCTION__ . ": " . __LINE__ . "
sql=$sql\n-------------------------------------------------------------\n";

$result = mysql_query( $sql, $this->connection) or die("MySql
ERROR in cSchedule on line " . __LINE__ . " " . mysql_error()) ;
return;
} //found an identical empty appt, use it

note:
$hist = "";
$hist = "empty appointment filled ". nowUS() ." by "
..$_SESSION['current_user'] . "\n";

If I remove the first line ($hist = "") I get the error message.
If I have both line in, the correct text is assigned to hist.

There are only 3 references to hist in the procedure, the two
lines above and the sql.

Although I hate to do this, I am willing to leave the null
assignment to keep the script running, but I sure would like to
know what is going on.

bill
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: json and special chars
Next Topic: integer and string what's the difference ?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 06:54:02 GMT 2024

Total time taken to generate the page: 0.04340 seconds