Jump to content

Notice: Uninitialized string offset: 0


software4

Recommended Posts

Error Message

Notice: Uninitialized string offset: 0 in C:\wamp\www\vote\view_results.php on line 144

Fatal error: Cannot use string offset as an array in C:\wamp\www\vote\view_results.php on line 144

 

It works fine with no error reporting and on a server, but when i put this in WAMP, i am getting this error. Here is line 135-146

 

                $resultVoting = mysql_query($showVoting); 
                    while($rV = mysql_fetch_array($resultVoting)) 
                        { 
                            $election = $rV[0]; 
                            $position = $rV[1]; 
                            $person = $rV[2]; 
                             
                            //Set array, can you tell I like array's? 
                            $count = 1; 
                            $db_connsCast["$election"]["$position"]["$person"] = $db_connsCast["$election"]["$position"]["$person"] + $count; 
                        } 
	$usedKey = array();

Link to comment
https://forums.phpfreaks.com/topic/191011-notice-uninitialized-string-offset-0/
Share on other sites

Nope, same problem. Here is the full block of code in there if this helps.

 

$showVoting = "SELECT poll.poll_title, voting_result.position, join2.join_candidate
FROM (
`voting_result`
LEFT JOIN `join2` ON voting_result.id = join2.join_id
)
LEFT JOIN `poll` ON poll.poll_id = join2.join_event_id
WHERE poll.poll_id ='$event_id'";                      
                             
                $resultVoting = mysql_query($showVoting); 
                   while(false !== ($rV = mysql_fetch_array($resultVoting)))
                        { 
                            $election = $rV[0]; 
                            $position = $rV[1]; 
                            $person = $rV[2]; 
                             
                            //Set array, can you tell I like array's? 
                            $count = 1; 
                            $db_connsCast["$election"]["$position"]["$person"] = $db_connsCast["$election"]["$position"]["$person"] + $count; 
                        } 
	$usedKey = array();

        if(is_array($db_connsCast))
            {
            //build us a division for the voting results 
            foreach($db_connsCast as $key => $value) 
            { 
                echo '<div>' . '<p align="center">'  
                    . '<span class="style2">' . $key . '</span>' . '</p>' ; 
                 
                 echo '<div bgcolor="#CCCCCC";style="width:100%;text-align:center;"><table border="2" style="margin:0px auto;text-align:left;">';
                        foreach($value as $key2 => $value2) 
                            { 
                                     echo  '<tr class="SubHeaderMain"><td style="background-color:#E3EDEF;width:200px;text-align:left;"><strong>' . $key2 . '</strong></td><td style="background-color:#E3EDEF;width:75px;text-align:left;"><strong>Votes</td></tr>' ;
                                            
										$max = max($value2);
										for($i = $max; $i > 0; $i--)
											{
												foreach($value2 as $key3 => $value3)
													{
														if($value3 == $i) echo '<tr><td style="text-align:left;padding: 3px; ">' . '<span class="text">'.  $key3 . '</span>' . '</td><td style="text-align:left;padding: 3px;">' . '<span class="text">'. $value3  .  '</span>' . '</td></tr>';
													}

                                                } 
                                  
						} 
                echo '</table></div>'; 
                     
            } 
            }
        else echo '<center>No results for this poll!</center>';

Archived

This topic is now archived and is closed to further replies.

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