Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-04-2008, 09:10 AM   #1
Registered: Oct 2008
Posts: 39

Rep: Reputation: 15
PHP Problem ('undefined index', 'undefined function')


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:

[client] PHP Notice:  Undefined index:  q in /web/html/acad/dict/includes/search-commands.php on line 12, referer:
[client] PHP Fatal error:  Call to undefined function:  mb_strlen() in /web/html/acad/dict/includes/search-commands.php on line 15, referer:
The lines in the file referenced are the following:

Line 12:
$search_str = strtr($_GET['q'], array("*" => ".*"));
Line 15:
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:

[client] PHP Notice:  Undefined variable:  prefix in /web/html/acad/dict/includes/searchbox.php on line 5, referer:
[client] PHP Notice:  Undefined variable:  no_real_results in /web/html/acad/dict/includes/searchbox.php on line 80, referer:
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.

Old 12-04-2008, 09:29 AM   #2
Senior Member
Registered: Apr 2004
Location: Potchefstroom, South Africa
Distribution: Fedora 17 - 3.3.4-5.fc17.x86_64
Posts: 1,481

Rep: Reputation: 88
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?
Old 12-04-2008, 10:18 AM   #3
LQ Newbie
Registered: Dec 2008
Distribution: fedora,rhel
Posts: 18

Rep: Reputation: 1
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent PHP problem with "undefined function: domxml_open_mem()"! Recomplie php? Oskare100 Linux - Server 0 12-27-2006 12:28 PM
weird PHP problem: Call to undefined function mysql_connect() Shioni Linux - Server 4 12-22-2006 05:26 AM
undefined function scandir() in php tooparam Linux - Newbie 1 01-22-2006 01:03 AM
Need help with PHP and MySQL: Undefined function... Mega Man X Programming 12 09-15-2004 11:07 PM
PHP Undefined index Error Gerardoj Programming 1 05-30-2004 03:30 AM

All times are GMT -5. The time now is 06:17 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration