Re: [PHP] Error while calling a function--Thanks
Hi pals, Thanks a lot for all the PHP pals , I have recoded my script an' now itz working fine. cheers an' regards, - JFK kishor Nilgiri Networks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Error while calling a function
hi all, I have got a problem, when I execute the following script it gives a Fatal error, could any one tell me why is it ?, If this is a silly problem please execuse me but, plz do reply me. The script is - html body ? if(!$Phone) { ? form action=?echo $PHP_SELF? method=post br Telephone Number : input type=text name=Phone value= br input type=submit script language=php } else { function is_allnumbers ($text) { if( (gettype($text)) == integer) { print the value is an integer; return true; } $Bad = $this-strip_numbers($text); if(empty($Bad)) { print the value is empty; return true; } return false; } function clear_error () { $this-ERROR = this is an error; } function is_phone ($Phone =) { if($this-CLEAR) { $this-clear_error(); } if(empty($Phone)) { $this-ERROR = is_phone: No Phone number submitted; return false; } $Num = $Phone; $Num = $this-strip_space($Num); $Num = eregi_replace((\(|\)|\-|\+),,$Num); if(!$this-is_allnumbers($Num)) { $this-ERROR = is_phone: bad data in phone number; return false; } if ( (strlen($Num)) 7) { print the number is less then 7; $this-ERROR = is_phone: number is too short [$Num][$Phone]; return false; } if( (strlen($Num)) 13) { print the number is then 13; $this-ERROR = is_phone: number is too long [$Num][$Phone]; return false; } return true; } } $result = is_phone($Phone); if($result == true) { echo success; } else { echo failure; } /script /body /html The error is Fatal error: Call to undefined function: is_phone() in /home/kuruvi1/kishor/public_html/IMS/ADMIN/test/is_phone.php on line 87 Thanks for your tolerance, - JFK kishor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Error while calling a function
I don't know all the details about how PHP compiles a program, but having your function definitions in an if-else statement that may not be executed looks suspicious to me. You've got if(!$Phone) { do something } else { function is_phone() { ...blah, blah...} } is_phone($Phone); If you don't hit the else block, your is_phone function is probably not defined. -Steve On Tuesday, December 18, 2001, at 07:26 AM, J.F.Kishor wrote: hi all, I have got a problem, when I execute the following script it gives a Fatal error, could any one tell me why is it ?, If this is a silly problem please execuse me but, plz do reply me. The script is - html body ? if(!$Phone) { ? form action=?echo $PHP_SELF? method=post br Telephone Number : input type=text name=Phone value= br input type=submit script language=php } else { function is_allnumbers ($text) { if( (gettype($text)) == integer) { print the value is an integer; return true; } $Bad = $this-strip_numbers($text); if(empty($Bad)) { print the value is empty; return true; } return false; } function clear_error () { $this-ERROR = this is an error; } function is_phone ($Phone =) { if($this-CLEAR) { $this-clear_error(); } if(empty($Phone)) { $this-ERROR = is_phone: No Phone number submitted; return false; } $Num = $Phone; $Num = $this-strip_space($Num); $Num = eregi_replace((\(|\)|\-|\+),,$Num); if(!$this-is_allnumbers($Num)) { $this-ERROR = is_phone: bad data in phone number; return false; } if ( (strlen($Num)) 7) { print the number is less then 7; $this-ERROR = is_phone: number is too short [$Num][$Phone]; return false; } if( (strlen($Num)) 13) { print the number is then 13; $this-ERROR = is_phone: number is too long [$Num][$Phone]; return false; } return true; } } $result = is_phone($Phone); if($result == true) { echo success; } else { echo failure; } /script /body /html The error is Fatal error: Call to undefined function: is_phone() in /home/kuruvi1/kishor/public_html/IMS/ADMIN/test/is_phone.php on line 87 Thanks for your tolerance, - JFK kishor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Error while calling a function
Try putting a closing ? php tag just before the final HTML. Jim - Original Message - From: J.F.Kishor [EMAIL PROTECTED] To: PHP Mailing List [EMAIL PROTECTED] Sent: Tuesday, December 18, 2001 5:26 AM Subject: [PHP] Error while calling a function hi all, I have got a problem, when I execute the following script it gives a Fatal error, could any one tell me why is it ?, If this is a silly problem please execuse me but, plz do reply me. The script is - html body ? if(!$Phone) { ? form action=?echo $PHP_SELF? method=post br Telephone Number : input type=text name=Phone value= br input type=submit script language=php } else { function is_allnumbers ($text) { if( (gettype($text)) == integer) { print the value is an integer; return true; } $Bad = $this-strip_numbers($text); if(empty($Bad)) { print the value is empty; return true; } return false; } function clear_error () { $this-ERROR = this is an error; } function is_phone ($Phone =) { if($this-CLEAR) { $this-clear_error(); } if(empty($Phone)) { $this-ERROR = is_phone: No Phone number submitted; return false; } $Num = $Phone; $Num = $this-strip_space($Num); $Num = eregi_replace((\(|\)|\-|\+),,$Num); if(!$this-is_allnumbers($Num)) { $this-ERROR = is_phone: bad data in phone number; return false; } if ( (strlen($Num)) 7) { print the number is less then 7; $this-ERROR = is_phone: number is too short [$Num][$Phone]; return false; } if( (strlen($Num)) 13) { print the number is then 13; $this-ERROR = is_phone: number is too long [$Num][$Phone]; return false; } return true; } } $result = is_phone($Phone); if($result == true) { echo success; } else { echo failure; } /script /body /html The error is Fatal error: Call to undefined function: is_phone() in /home/kuruvi1/kishor/public_html/IMS/ADMIN/test/is_phone.php on line 87 Thanks for your tolerance, - JFK kishor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Error while calling a function
Steve is right on the money. Your function definitions are inside a conditional if statement which means that they may or may not be parsed. Your call to the function, on the other hand, is not within that same conditional if statement. That means your functions is getting called unconditionally, but the function has not yet been defined because the condition failed (!Phone) and the code was skipped. Rule of thumb: Don't put your function definitions inside of conditionals. Fred Steve Cayford [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I don't know all the details about how PHP compiles a program, but having your function definitions in an if-else statement that may not be executed looks suspicious to me. You've got if(!$Phone) { do something } else { function is_phone() { ...blah, blah...} } is_phone($Phone); If you don't hit the else block, your is_phone function is probably not defined. -Steve On Tuesday, December 18, 2001, at 07:26 AM, J.F.Kishor wrote: hi all, I have got a problem, when I execute the following script it gives a Fatal error, could any one tell me why is it ?, If this is a silly problem please execuse me but, plz do reply me. The script is - html body ? if(!$Phone) { ? form action=?echo $PHP_SELF? method=post br Telephone Number : input type=text name=Phone value= br input type=submit script language=php } else { function is_allnumbers ($text) { if( (gettype($text)) == integer) { print the value is an integer; return true; } $Bad = $this-strip_numbers($text); if(empty($Bad)) { print the value is empty; return true; } return false; } function clear_error () { $this-ERROR = this is an error; } function is_phone ($Phone =) { if($this-CLEAR) { $this-clear_error(); } if(empty($Phone)) { $this-ERROR = is_phone: No Phone number submitted; return false; } $Num = $Phone; $Num = $this-strip_space($Num); $Num = eregi_replace((\(|\)|\-|\+),,$Num); if(!$this-is_allnumbers($Num)) { $this-ERROR = is_phone: bad data in phone number; return false; } if ( (strlen($Num)) 7) { print the number is less then 7; $this-ERROR = is_phone: number is too short [$Num][$Phone]; return false; } if( (strlen($Num)) 13) { print the number is then 13; $this-ERROR = is_phone: number is too long [$Num][$Phone]; return false; } return true; } } $result = is_phone($Phone); if($result == true) { echo success; } else { echo failure; } /script /body /html The error is Fatal error: Call to undefined function: is_phone() in /home/kuruvi1/kishor/public_html/IMS/ADMIN/test/is_phone.php on line 87 Thanks for your tolerance, - JFK kishor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Error while calling a function
Hello Sir, Thanks for spending time for my mail and thanks for you kind response, but sir though php is a server side scripting language it supports the following tag script language=php/script This is mentioned in the php manual, and I have done lot of scripts of same kind using above tags an' all of them are working fine. This is part of php manual --- Migrating from PHP/FI 2.0 to PHP 3.0 Start/end tags The first thing you probably will notice is that PHP's start and end tags have changed. The old ? form has been replaced by three new possible forms: Example A-1. Migration: old start/end tags ? echo This is PHP/FI 2.0 code.\n; As of version 2.0, PHP/FI also supports this variation: Example A-2. Migration: first new start/end tags ? echo This is PHP 3.0 code!\n; ? Notice that the end tag now consists of a question mark and a greater-than character instead of just greater-than. However, if you plan on using XML on your server, you will get problems with the first new variant, because PHP may try to execute the XML markup in XML documents as PHP code. Because of this, the following variation was introduced: Example A-3. Migration: second new start/end tags ?php echo This is PHP 3.0 code!\n; ? Some people have had problems with editors that don't understand the processing instruction tags at all. Microsoft FrontPage is one such editor, and as a workaround for these, the following variation was introduced as well: Example A-4. Migration: third new start/end tags script language=php echo This is PHP 3.0 code!\n; /script Thanking you, cheers :) - JFK kishor Nilgiri Networks On Tue, 18 Dec 2001, Jim Lucas wrote: Plus, what is the script language='php' tag for. PHP is a server side language, not client side. and you have the above mentioned tag inside of an IF statement. so, if the statement doesn't return true, it will never print the openning tag but it will always print the closing /script tag. Jim - Original Message - From: J.F.Kishor [EMAIL PROTECTED] To: PHP Mailing List [EMAIL PROTECTED] Sent: Tuesday, December 18, 2001 5:26 AM Subject: [PHP] Error while calling a function -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]