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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.