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
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>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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