Form/Array Help? :(
Posted: Thu Aug 15, 2002 10:05 pm
I'm getting into arrays today and basically I'm having a brain fart on this one...
what I want to do is take a field from my database which was imploded as an array of peoples favorite bands with a pipe seperator:
IE: nirvana|tool|led zepplin
I want to give them 6 input boxes to add in their bands, but they don't have to do all six and the first time the user goes here, their field is empty because they sign up then add the bands, I keep getting the error:
<br><b>Warning</b>: Uninitialized string offset: 4 in <b>c:\inetpub\wwwroot\dd\st_lists.php</b> on line <b>81</b><br>
thats what I've been working with so far. any thoughts on how to do it right? 
I know the error comes from not having a value there but I'm not sure on how do do value checks for the array
what I want to do is take a field from my database which was imploded as an array of peoples favorite bands with a pipe seperator:
IE: nirvana|tool|led zepplin
I want to give them 6 input boxes to add in their bands, but they don't have to do all six and the first time the user goes here, their field is empty because they sign up then add the bands, I keep getting the error:
<br><b>Warning</b>: Uninitialized string offset: 4 in <b>c:\inetpub\wwwroot\dd\st_lists.php</b> on line <b>81</b><br>
Code: Select all
$result = query_db("select * from st_bands where username = '$valid_user'");
$num_rows = mysql_num_rows($result);
$row = mysql_fetch_array($result);
$bands = explode('|', ($rowї"bandlove"]));
$num = 0;
$ct = 1;
for($i=0; $i < 6; $i++){
echo $ct.". ";
?>
<input type="text" name="favbandї]" size="30" value="<? echo $bandsї$num]; ?>"><BR>
<?
$num++;
$ct++;
}
?>
<BR><BR>
<input type="submit" value="Update ยป" name="submit">
</form>I know the error comes from not having a value there but I'm not sure on how do do value checks for the array