roN @ work
Jun 30 2005, 01:59 PM
Hi,
I got an array and want to define it global, now I get the Warning:
Warning: array_push(): First argument should be an array in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 53
and I already placed global $Array in my function. So what to do? Thank you!
Steve
Jun 30 2005, 02:27 PM
QUOTE |
Warning: array_push(): First argument should be an array in
|
Post full actual code or a minimal executable example that demonstrates
the problem (but I bet you have mispelt the name of the array).
---
Steve
Stefan Rybacki
Jun 30 2005, 03:13 PM
roN @ work wrote:
QUOTE |
Hi,
I got an array and want to define it global, now I get the Warning: Warning: array_push(): First argument should be an array in /srv/www/htdocs/web2/html/php/nospam/pop.php on line 53 and I already placed global $Array in my function. So what to do? Thank you!
global $array means that you import a global called $array to a local |
function.
globals are defined outside of any function.
Regards
Stefan
roN @ work
Jul 1 2005, 05:38 AM
Steve wrote:
QUOTE |
Warning: array_push(): First argument should be an array in
Post full actual code or a minimal executable example that demonstrates the problem (but I bet you have mispelt the name of the array). Ok:
function echoStuff($emailArray, $subjectArray) |
{
global $spamMail;
echo "<br>".count($emailArray);
$base = InitDesign(BASEDESIGN, 0, 0);
$count=count($emailArray);
$outSender="";
for($j=0; $j<$count; $j++ )
{
$outSender.="<tr>n<td bgcolor="#FFFF00">".$j."</td>";// Mailnummer
$outSender.="<td bgcolor="#FF8800">".$emailArray[$j]."</td>n";//
Mailabsender
$outSender.="<td bgcolor="#0088FF">".$subjectArray[$j]."</td>n";//
Mailbetreff
// [berprfen ob mail-adrese bereits auf blacklist ist]
if (OnBlacklist($emailArray[$j]))
{
$outSender.="<td bgcolor="#00FF00"><a
href="".$_SERVER['PHP_SELF']."?remove=".$emailArray[$j]."">remove from
blacklist</a></td>n</tr>n";
array_push($spamMail,$j+1); // Nummer des E-Mails welches auf der
blacklist steht zum 'lsch-Array' hinzufgen
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--That's line 53 and the array $spamMail is
declared like this at the top: ($spamMail="";
$spamMail==array(); )
*/
}
else
$outSender.="<td bgcolor="#00FF00"><a
href="".$_SERVER['PHP_SELF']."?spam=".$emailArray[$j]."">report</a></td>n
</tr>n";
// [/berprfen ob mail-adrese bereits auf blacklist ist]
}
echo str_replace("<!--Sender-->",$outSender,$base);
}
Hilarion
Jul 1 2005, 08:23 AM
QUOTE |
Warning: array_push(): First argument should be an array in
$spamMail=""; $spamMail==array();
|
It should be:
$spamMail = array();
Your code initialized $spamMail as empty string ($spamMail="";)
and then compared it to empty array ($spamMail==array();).
Hilarion
roN @ work
Jul 1 2005, 08:28 AM
Hilarion wrote:
QUOTE |
Warning: array_push(): First argument should be an array in
$spamMail=""; $spamMail==array();
It should be:
$spamMail = array();
Your code initialized $spamMail as empty string ($spamMail="";) and then compared it to empty array ($spamMail==array();).
|
Oh yes right, I've written down one '=' too much. Thank you! :)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.