Re: php 4 script with php 5.
| From: | Torgny Bjers | Date: | Sat, 24 Sep 2005 12:36:19 +0000 |
| Subject: | Re: php 4 script with php 5. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-223118@lists.php.net to get a copy of this message | ||
Dwayne Hottinger wrote:
>I am trying to transfer some databases and php scripts that populate them to a
>new server. Server is running Fedora core 4 with mysql 4.x and php 5.0.5.
>Original scripts were writen with php 4.x and worked fine. I get a PHP Notice:
> Undefined variable: return_array when running them on the new server and the
>database doesnt get populated. Mysql database and mysql user rights seem to be
>correct. Do I have to rewrite the script for php 5.x or should it work and I
>need to dig for another problem? Im quite new to php and dont know quite which
>way to go for help. I hope I have posted this on the right list.
>
>ddh
>
Hello Dwayne,
This is easy enough, all you need to do is define return_array. I've
included an example here, it's mailer code, but, should illustrate what
you need to do.
function test()
{
$return_array = null;
if (...) {
$return_array = $db->getAll("SELECT * FROM table", DB_FETCHMODE_ASSOC);
}
return $return_array;
}
That means, you need to assign or indicate that return_array exists
before you use it in something like return or other PHP function. Your
php.ini file for PHP 4 could have been more forgiving coming to these
notices/warnings.
Warm Regards,
Torgny Bjers