Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3627
| Date | 2011-10-30 08:59 -0400 |
|---|---|
| From | bill <nobody@spamcop.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: missing variable |
| References | <-4adnYXjVd2CyjHTnZ2dnUVZ_oudnZ2d@cablespeedmi.com> <j8hrj3$tls$1@news.albasani.net> |
| Message-ID | <BdCdneCS9Orf1zDTnZ2dnUVZ_vGdnZ2d@cablespeedmi.com> (permalink) |
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
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
missing variable bill <nobody@spamcop.net> - 2011-10-29 15:42 -0400
Re: missing variable Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2011-10-29 23:35 +0200
Re: missing variable bill <nobody@spamcop.net> - 2011-10-30 08:59 -0400
Re: missing variable Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-30 19:57 +0000
Re: missing variable Jerry Stuckle <jstucklex@attglobal.net> - 2011-10-30 19:29 -0400
Re: missing variable Denis McMahon <denismfmcmahon@gmail.com> - 2011-10-31 00:37 +0000
Re: missing variable bill <nobody@spamcop.net> - 2011-10-31 06:30 -0400
csiph-web