FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


php array() problem





takashiro
Code:
$zhiyeid=$db->get_one("SELECT field_1 FROM pw_memberinfo WHERE uid='$winduid'");
$zhiyeid=$zhiyeid['field_1'];
$zhiye=array(
    '1'=>"youkai power",
    '2'=>"youkai power",
    '3'=>"miko power",
    '4'=>"youkaidaiji power",
    '5'=>"houshi power",
    '6'=>"houshi power",
    '7'=>"jaki",
    '8'=>"human power"
)
$db_rvrcname=$zhiye['$zhiyeid'];


Look at the code. Some of 'field_1' is blank. Will that cause problem? it does not work well now.
It shows unexpected T_VARIABLE eg.
Code:
Parse error: syntax error, unexpected T_VARIABLE in /home/takashir/domains/inuyasha.frih.net/public_html/template/wind/read.htm on line 176
MrBlueSky
Change

Code:

$db_rvrcname=$zhiye['$zhiyeid'];


to

Code:

$db_rvrcname=$zhiye[$zhiyeid];
kv
MrBlueSky wrote:
Change

Code:

$db_rvrcname=$zhiye['$zhiyeid'];


to

Code:

$db_rvrcname=$zhiye[$zhiyeid];


That might be a logical error, but the syntax error is because of a missing semicolon.

Code:


$zhiyeid=$db->get_one("SELECT field_1 FROM pw_memberinfo WHERE uid='$winduid'");
$zhiyeid=$zhiyeid['field_1'];
$zhiye=array(
    '1'=>"youkai power",
    '2'=>"youkai power",
    '3'=>"miko power",
    '4'=>"youkaidaiji power",
    '5'=>"houshi power",
    '6'=>"houshi power",
    '7'=>"jaki",
    '8'=>"human power"
); //; was missing here
$db_rvrcname=$zhiye[$zhiyeid];
MrBlueSky
Ah yes, I didn't see that. Embarassed
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.