•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,994 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 225 | Replies: 8
![]() |
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
I had my server upgraded to php 5.2 and included error messages for debugging. Not a good thing - as they are all over the place with scripts that have been in place for years.
So, I need some help knowing how things need to be written differently in php 5.2 that are no longer valid from earlier versions of 4.
For example, I get this notice: Notice: Undefined index: submit in /var/www/vhosts/domain/httpdocs/Directory/form.php on line 270
line 270 reads: if ($_POST['submit'] == "Submit Search") {
list_matches ("42directory");
}
What need to change here?
Also, after submitting a form that inputs to a database, I get this notice:
Notice: Array to string conversion in /var/www/vhosts/domain/httpdocs/Directory/search.inc.php on line 23
That line is part of a clean array function:
function clean_array ($array, $remove='submit') {
// global $remove;
$remove = array ('submit' => '');
if (is_array ($array)) {
$array = array_filter ($array, "strlen");
$array = array_filter ($array, "addslashes");
while (list ($key, $val) = each ($array)) {
if (!trim_array ($key, $remove)) {
$clean_array[$key] = $val;
}
}
return $clean_array;
} else {
return 0;
}
}
What is wrong with this one?
I know these are just notices, not errors, but it would be nice to clean all this up, and leanr a little more about php 5 in the process.
Rick
So, I need some help knowing how things need to be written differently in php 5.2 that are no longer valid from earlier versions of 4.
For example, I get this notice: Notice: Undefined index: submit in /var/www/vhosts/domain/httpdocs/Directory/form.php on line 270
line 270 reads: if ($_POST['submit'] == "Submit Search") {
list_matches ("42directory");
}
What need to change here?
Also, after submitting a form that inputs to a database, I get this notice:
Notice: Array to string conversion in /var/www/vhosts/domain/httpdocs/Directory/search.inc.php on line 23
That line is part of a clean array function:
function clean_array ($array, $remove='submit') {
// global $remove;
$remove = array ('submit' => '');
if (is_array ($array)) {
$array = array_filter ($array, "strlen");
$array = array_filter ($array, "addslashes");
while (list ($key, $val) = each ($array)) {
if (!trim_array ($key, $remove)) {
$clean_array[$key] = $val;
}
}
return $clean_array;
} else {
return 0;
}
}
What is wrong with this one?
I know these are just notices, not errors, but it would be nice to clean all this up, and leanr a little more about php 5 in the process.
Rick
•
•
Join Date: Apr 2005
Location: New York state
Posts: 442
Reputation:
Rep Power: 5
Solved Threads: 65
Make sure you go over to http://www.php.net/releases/ and check the changelogs for compatibility and major upgrades that can break code. Checking changelogs is always good practice when making an upgrade to prevent things like this.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Apr 2005
Location: New York state
Posts: 442
Reputation:
Rep Power: 5
Solved Threads: 65
Well both errors are pretty helpful since they explain in plain English exactly what is going wrong.
The first
Tells you that there is an Undefined index. In this line
The
For the second could you show the definition of your trim_array function because it isn't a built in PHP function unless it's new to 5.2
The first
Notice: Undefined index: submit in /var/www/vhosts/domain/httpdocs/Directory/form.php on line 270
php Syntax (Toggle Plain Text)
if ($_POST['submit'] == "Submit Search") {
'submit' is called an index as it is an index to the location in the array. So what the notice is saying that there is nothing defined in the 'submit' position in the $_POST array.For the second could you show the definition of your trim_array function because it isn't a built in PHP function unless it's new to 5.2
Last edited by ShawnCplus : Apr 22nd, 2008 at 2:02 pm.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Okay - thanks on the first response, although I am not sure why it worked before, if there is nothing defined in the submit position, what did it do before the upgrade?
The function is not new to php 5, it was written a number of years ago by a friend of mine in Latvia. He is now doing IT in Sweden, and works for a school that gives him no time to freelance.
His description of it is:
Adds slashes and filters out entries that
don't have values, plus deletes values you
don't want to update against database fields.
Returns array with elements that have values and fileds
as counterparts in the database.Submit button entry.
The function is not new to php 5, it was written a number of years ago by a friend of mine in Latvia. He is now doing IT in Sweden, and works for a school that gives him no time to freelance.
His description of it is:
Adds slashes and filters out entries that
don't have values, plus deletes values you
don't want to update against database fields.
Returns array with elements that have values and fileds
as counterparts in the database.Submit button entry.
•
•
Join Date: Apr 2005
Location: New York state
Posts: 442
Reputation:
Rep Power: 5
Solved Threads: 65
It works because it's not an error since PHP is capable of implicit initialization meaning a variable is declared as soon as you use it if it was not declared before as opposed to C or C++ which requires explicit initialization.
Aside from that I meant the actual code for the function, the description of it doesn't really help when debugging it
Aside from that I meant the actual code for the function, the description of it doesn't really help when debugging it
Last edited by ShawnCplus : Apr 22nd, 2008 at 2:19 pm.
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
•
•
Join Date: Apr 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Okay - I thought I had included the code in the first posting:
function clean_array ($array, $remove='submit') {
// global $remove;
$remove = array ('submit' => '');
if (is_array ($array)) {
$array = array_filter ($array, "strlen");
$array = array_filter ($array, "addslashes");
while (list ($key, $val) = each ($array)) {
if (!trim_array ($key, $remove)) {
$clean_array[$key] = $val;
}
}
return $clean_array;
} else {
return 0;
}
}
I'm not sure what more you are asking for.
Thanks for your quick responses!
function clean_array ($array, $remove='submit') {
// global $remove;
$remove = array ('submit' => '');
if (is_array ($array)) {
$array = array_filter ($array, "strlen");
$array = array_filter ($array, "addslashes");
while (list ($key, $val) = each ($array)) {
if (!trim_array ($key, $remove)) {
$clean_array[$key] = $val;
}
}
return $clean_array;
} else {
return 0;
}
}
I'm not sure what more you are asking for.
Thanks for your quick responses!
•
•
Join Date: Apr 2005
Location: New York state
Posts: 442
Reputation:
Rep Power: 5
Solved Threads: 65
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
- Programming FAQ - Updated 1/March/2005 (Computer Science and Software Design)
- Php version upgrade issue (PHP)
- PHP installation possible errors? (PHP)
- Email piping to script problem (PHP)
- Apache and PHP (PHP)
- Please Help Header Error (PHP)
- Disappearing Drive in Win XP (Storage)
Other Threads in the PHP Forum
- Previous Thread: Photo Gallery
- Next Thread: Redirect Output


Linear Mode