php - Code works locally, but gives: expects parameter to be array, boolean given when run online -
i have used code this blackjack game build own total version.
everything works locally using xampp, when uploaded total version get: expects parameter array, boolean given.
i'm new php, understand, have defined array. why giving me boolean online, , array offline?
here full game wrote.(the site little nsfwish, page clean)
the problem seems here:
function evaluatehand($hand) { $ace=0; global $faces; $value = 0; foreach ($hand $card) { if ($card['face'] == 'ace') $ace++; $value = intval($value) + intval($faces[$card['face']]); while ($ace>0 && $value >21) { $value = intval($value) - 10; $ace--; } }
specifically - foreach ($hand $card) { part.
i remember reading else having same problem, , solution seemed switiching double single quotations here.
<input type='hidden' name='handstr' value = '<?php echo $handstr ?>' />
but have single quotations.
what confuses me, guy wrote script seems have running fine.
if alter .php .txt can see total game code (from link above... sorry 2 link max)
anyone know why offline different online, , how prepare problem?
you need aware output of serialize()
not suitable direct inclusion in html form fields; may contain characters not allowed in html, such null bytes, single , double quotes etc.
i suggest wrap output of serialize()
in base64, such this:
<input type='hidden' name='dealerstr' value = '<?php echo base64_encode($dealerstr) ?>' />
of course, need base64_decode()
post info before unserializing, too.
php
No comments:
Post a Comment