I get the following error:
Notice: Array to string conversion in C:\Documents and
Settings\ShepMode\Desktop\Websites\ShareMonkey.net \Web\join.php on line 11
in this code:
$input = array(array("First
Name",$_POST['firstname']),array("Surname"=>$_POST['surname']),array("Compan
y Name"=>$_POST['company_name']),
array("Website / Application
URL"=>$_POST['url']),array("Email
Address"=>$_POST['email']),array("Username"=>$_POST['username']),
array("Password"=>$_POST['password']));
(line 11) if (substr_count($value,"@") != 1) {
$error_message .= "The email address you have
entered is invalid.<br>";
}
Why does substr_count($value,"@") cause this notice? And since it is not an
error as such, how do I rectify it without modifying php.ini?
Thanks,
Keiron 4 66615
On Fri, 29 Aug 2003 21:25:50 +0000 (UTC), "Keiron Waites"
<webmaster@-NOSPAM-sharemonkey.com> wrote: I get the following error:
Notice: Array to string conversion in C:\Documents and Settings\ShepMode\Desktop\Websites\ShareMonkey.ne t\Web\join.php on line 11
in this code:
$input = array(array("First Name",$_POST['firstname']),array("Surname"=>$_POST['surname']),array("Compan y Name"=>$_POST['company_name']), array("Website / Application URL"=>$_POST['url']),array("Email Address"=>$_POST['email']),array("Username"=>$_POST['username']), array("Password"=>$_POST['password']));
(line 11) if (substr_count($value,"@") != 1) { $error_message .= "The email address you have entered is invalid.<br>"; }
Why does substr_count($value,"@") cause this notice? And since it is not an error as such, how do I rectify it without modifying php.ini?
Because $value is an array? Hard to say without seeing where it's assigned...
Don't hide this warning, since you've probably now counting the number of @
characters in the string 'Array', which isn't what you want...
--
Andy Hassall (an**@andyh.co.uk) icq(5747695) ( http://www.andyh.co.uk)
Space: disk usage analysis tool ( http://www.andyhsoftware.co.uk/space)
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:1g********************************@4ax.com... On Fri, 29 Aug 2003 21:25:50 +0000 (UTC), "Keiron Waites" <webmaster@-NOSPAM-sharemonkey.com> wrote:
I get the following error:
Notice: Array to string conversion in C:\Documents and Settings\ShepMode\Desktop\Websites\ShareMonkey.ne t\Web\join.php on line
11
in this code:
$input = array(array("First Name",$_POST['firstname']),array("Surname"=>$_POST['surname']),array("Compa
ny Name"=>$_POST['company_name']), array("Website / Application URL"=>$_POST['url']),array("Email Address"=>$_POST['email']),array("Username"=>$_POST['username']), array("Password"=>$_POST['password']));
(line 11) if (substr_count($value,"@") != 1) { $error_message .= "The email address you have entered is invalid.<br>"; }
Why does substr_count($value,"@") cause this notice? And since it is not
anerror as such, how do I rectify it without modifying php.ini?
Because $value is an array? Hard to say without seeing where it's
assigned... Don't hide this warning, since you've probably now counting the number of
@ characters in the string 'Array', which isn't what you want...
[snip]
Crap sorry, this: foreach ($input as $name => $value) { assigns the
$value.
So:
$input = array(array("First
Name",$_POST['firstname']),array("Surname"=>$_POST['surname']),array("Compan
y Name"=>$_POST['company_name']),
array("Website / Application
URL"=>$_POST['url']),array("Email
Address"=>$_POST['email']),array("Username"=>$_POST['username']),
array("Password"=>$_POST['password']));
foreach ($input as $name => $value) {
(line 11) if (substr_count($value,"@") != 1) {
$error_message .= "The email address you have
entered is invalid.<br>";
}
}
I don't want to hide the error, I want to fix the code :) Is there something
about the foreach that I don't understand?
On Fri, 29 Aug 2003 21:56:50 +0000 (UTC), "Keiron Waites"
<webmaster@-NOSPAM-sharemonkey.com> wrote: "Andy Hassall" <an**@andyh.co.uk> wrote in message news:1g********************************@4ax.com.. . On Fri, 29 Aug 2003 21:25:50 +0000 (UTC), "Keiron Waites" <webmaster@-NOSPAM-sharemonkey.com> wrote:
> I get the following error: > > Notice: Array to string conversion in C:\Documents and Crap sorry, this: foreach ($input as $name => $value) { assigns the $value.
So:
$input = array(array("First Name",$_POST['firstname']),array("Surname"=>$_POST['surname']),array("Compan y Name"=>$_POST['company_name']), array("Website / Application URL"=>$_POST['url']),array("Email Address"=>$_POST['email']),array("Username"=>$_POST['username']), array("Password"=>$_POST['password']));
So $input is an array of arrays...
foreach ($input as $name => $value) {
So each $value is an array.
(line 11) if (substr_count($value,"@") != 1) {
Running substr_count on an array doesn't make sense; the array gets turned
into the string 'Array' and a warning output.
I don't want to hide the error, I want to fix the code :) Is there something about the foreach that I don't understand?
Not sure why you've got a load of single-element arrays inside the outer
array.
Did you want something more like:
$input = array(
"First Name" => $_POST['firstname'],
"Surname" => $_POST['surname'],
"Company Name" => $_POST['company_name'],
"Website / Application URL " => $_POST['url'],
"Email Address" => $_POST['email'],
"Username" => $_POST['username'],
"Password" => $_POST['password'],
);
?
--
Andy Hassall (an**@andyh.co.uk) icq(5747695) ( http://www.andyh.co.uk)
Space: disk usage analysis tool ( http://www.andyhsoftware.co.uk/space)
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:6j********************************@4ax.com... On Fri, 29 Aug 2003 21:56:50 +0000 (UTC), "Keiron Waites" <webmaster@-NOSPAM-sharemonkey.com> wrote:
"Andy Hassall" <an**@andyh.co.uk> wrote in message news:1g********************************@4ax.com.. . On Fri, 29 Aug 2003 21:25:50 +0000 (UTC), "Keiron Waites" <webmaster@-NOSPAM-sharemonkey.com> wrote:
> I get the following error: > > Notice: Array to string conversion in C:\Documents and Crap sorry, this: foreach ($input as $name => $value) { assigns the $value.
So:
$input = array(array("First
Name",$_POST['firstname']),array("Surname"=>$_POST['surname']),array("Compa
ny Name"=>$_POST['company_name']), array("Website / Application URL"=>$_POST['url']),array("Email Address"=>$_POST['email']),array("Username"=>$_POST['username']), array("Password"=>$_POST['password']));
So $input is an array of arrays...
foreach ($input as $name => $value) {
So each $value is an array.
(line 11) if (substr_count($value,"@") != 1) {
Running substr_count on an array doesn't make sense; the array gets
turned into the string 'Array' and a warning output.
I don't want to hide the error, I want to fix the code :) Is there
somethingabout the foreach that I don't understand?
Not sure why you've got a load of single-element arrays inside the outer array.
Did you want something more like:
$input = array( "First Name" => $_POST['firstname'], "Surname" => $_POST['surname'], "Company Name" => $_POST['company_name'], "Website / Application URL " => $_POST['url'], "Email Address" => $_POST['email'], "Username" => $_POST['username'], "Password" => $_POST['password'], );
?
-- Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Aah yes I see the error now (me = retard). Thanks a lot.
Keiron This discussion thread is closed Replies have been disabled for this discussion. Similar topics
8 posts
views
Thread by John van Terheijden |
last post: by
|
3 posts
views
Thread by praba kar |
last post: by
|
9 posts
views
Thread by Ronald Fischer |
last post: by
|
12 posts
views
Thread by Alexander Stippler |
last post: by
|
18 posts
views
Thread by Ger |
last post: by
|
6 posts
views
Thread by Ecohouse |
last post: by
|
2 posts
views
Thread by Dabbler |
last post: by
|
26 posts
views
Thread by drako |
last post: by
|
2 posts
views
Thread by Chris H |
last post: by
| | | | | | | | | | |