Hello All,
So when I "Add New Story" while adding a chapter I get this message...
Array to string conversion in /home2/****/public_html/fanfiction/includes/storyform.php on line 77
Here is what is on lines 76-78 of this page:}
$output .= "</select></label>
<input type='hidden' name='coauthors' id='coauthors' value='$couids'></div>";
}
Could someone be so kind as to tell me what is wrong with this code and how to fix it?
π
Hello Tammster,
If I check the current storyform.php I see the following code:
$couids = array() ;
if(is_array($stories['coauthors']) && count($stories['coauthors'])) {
$coauths = dbquery("SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." WHERE FIND_IN_SET("._UIDFIELD.", '".implode(",", $stories['coauthors'])."') > 0");
while($c = dbassoc($coauths)) {
if($c['uid'] == $stories['uid']) continue;
$output .= "<option label='".$c['penname']."' value='".$c['uid']."'>".$c['penname']."</option>";
$couids[] = $c['uid'];
}
$couids = implode(",", $couids);
}
$output .= "</select></label>
<input type='hidden' name='coauthors' id='coauthors' value='$couids'></div>";
}
Your error simple means that $couids is an array (a list) while it should be a string (simple text).
Try moving line 74 to line 75, like this:
$couids = array() ;
if(is_array($stories['coauthors']) && count($stories['coauthors'])) {
$coauths = dbquery("SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." WHERE FIND_IN_SET("._UIDFIELD.", '".implode(",", $stories['coauthors'])."') > 0");
while($c = dbassoc($coauths)) {
if($c['uid'] == $stories['uid']) continue;
$output .= "<option label='".$c['penname']."' value='".$c['uid']."'>".$c['penname']."</option>";
$couids[] = $c['uid'];
}
}
$couids = implode(",", $couids);
$output .= "</select></label>
<input type='hidden' name='coauthors' id='coauthors' value='$couids'></div>";
}
Could you let me know if this works? If you still get an error you can try this:
$couids = '' ;
if(is_array($stories['coauthors']) && count($stories['coauthors'])) {
$couids = array() ;
$coauths = dbquery("SELECT "._PENNAMEFIELD." as penname, "._UIDFIELD." as uid FROM "._AUTHORTABLE." WHERE FIND_IN_SET("._UIDFIELD.", '".implode(",", $stories['coauthors'])."') > 0");
while($c = dbassoc($coauths)) {
if($c['uid'] == $stories['uid']) continue;
$output .= "<option label='".$c['penname']."' value='".$c['uid']."'>".$c['penname']."</option>";
$couids[] = $c['uid'];
}
$couids = implode(",", $couids);
}
$output .= "</select></label>
<input type='hidden' name='coauthors' id='coauthors' value='$couids'></div>";
}
Very belated, but I just wanted to say that I tried this solution and it appears to have worked. Thank you!
