LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PHP Problem ('undefined index', 'undefined function') (https://www.linuxquestions.org/questions/programming-9/php-problem-undefined-index-undefined-function-688299/)

zokken 12-04-2008 09:10 AM

PHP Problem ('undefined index', 'undefined function')
 
Hi,

I'm moving a website with PHP content from a Mac server to a Linux server (Redhat AS4), but at least one page is not working on the Linux host. Unfortunately, I know next to nothing about PHP. The problem page is showing up blank and Apache's error_log shows the following:

Code:

[client 1.2.3.4] PHP Notice:  Undefined index:  q in /web/html/acad/dict/includes/search-commands.php on line 12, referer: http://ourhost.com/problem/path/
[client 1.2.3.4] PHP Fatal error:  Call to undefined function:  mb_strlen() in /web/html/acad/dict/includes/search-commands.php on line 15, referer: http://ourhost.com/problem/path/

The lines in the file referenced are the following:

Line 12:
Code:

$search_str = strtr($_GET['q'], array("*" => ".*"));
Line 15:
Code:

if (mb_strlen($search_str, 'UTF-8') > 0) {
If I comment out line 15 (and the closing curly brace) it *appears* to work properly -- the page appears and I'm able to get results from the mysql database the page queries against -- but then new errors occur:

Code:

[client 1.2.3.4] PHP Notice:  Undefined variable:  prefix in /web/html/acad/dict/includes/searchbox.php on line 5, referer: http://ourhost.com/problem/path/dict...est&fields=all
[client 1.2.3.4] PHP Notice:  Undefined variable:  no_real_results in /web/html/acad/dict/includes/searchbox.php on line 80, referer: http://ourhost.com/problem/path/dict...est&fields=all

Resolving the first set of errors may resolve these errors as well, though.

This machine is running PHP 4.3.9 (also has php-mysql-4.3.9 and php-devel 4.3.9). The Mac server that it works on is running PHP 4.4.8. And another Linux machine it works on is running PHP 4.3.2 (also php-mysql and php-imap; same versions).

Anyone have any ideas? I can provide more info about the PHP implementation or the system if needed, just let me know what you need.

Thanks.

rylan76 12-04-2008 09:29 AM

Well, the first thing I'd try is to have the versions of all the involved software (Apache, MySQL, PHP) -EXACTLY- the same. I know the PHP docs say the the mb_str function should be available, but my guess is that at least some (but not neccesarily all) your problems originate from having two different versions that try to run code that appears to be version specific?

Additionally, it could also be character encodings, which almost certainly is handled differently on OSX vs. Linux...? Since the functions complaining seem to be codepage specific functions?

judge312 12-04-2008 10:18 AM

just replace (mb_strlen($search_str, 'UTF-8') > 0)
with (strlen($search_str) > 0)

your php doesn't support mb_strlen.
you might have problem with non-utf characters


All times are GMT -5. The time now is 07:47 PM.