Jump to content

array_push error :'(


Demonic

Recommended Posts

I get this warning:

 

Warning: array_push() [function.array-push]: First argument should be an array in /home/**********/public_html/N***********/battle.php on line 69

 

what this does if it doesn't have any voters it seralises the voter who just voted then if it has voters i unserialize it then array_push the next voter on the end of the array then update the sql. Any help on why It won't update?

 

			if($voteinfo[whovoted] == ""){

				$voter = serialize($username);

			}else{

			$whovotedonthis = unserialize($voteinfo[whovoted]);
				$voter = array_push($whovotedonthis,"$username");

			}

Link to comment
https://forums.phpfreaks.com/topic/38067-array_push-error/
Share on other sites

you should use single quotes to identify an array index (if its a string that is and i your case it loks to be.

 

$voteinfo must have been an array initially check its NOT an object.

 

if there is only one value in there it may retun as a scalar value and not be an array at all so you must check that it is an array first. (use either count() or better is_array())

 

if its just a scalar then you must make an array otherwsie your code should work.

Link to comment
https://forums.phpfreaks.com/topic/38067-array_push-error/#findComment-182247
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.