I hate to say this, but I have never been able to take a bit of packaged code and make it work. I tried a few times early on but I always ended up rewriting it so much that I might have been better off starting from scratch.
I just don't see this scheme. I'm sorry, I really am trying to say something helpful, but it's so full of questions I just can't take it on. My advice would be to figure out the methodology and recode it from scratch, testing step by step.
I immediately noticed this:
- PHP: Select all
echo "<img src=vote_pie.php?one=".$one."&two=".$two."><br>";
A small thing, but there is no sense in concatenating the variables.
- PHP: Select all
echo "<img src=vote_pie.php?one=$one&two=$two><br>";
Also, If this is
XHTML you might need to code the ampersand.
Does the table have columns named 'first', 'sec', and 'third', or are these supposed to be rows? Okay, I see, you have a single row with these three field names and increase the proper field by one to reflect each vote
.
Since you are using an associative array, don't you need to put the associative key name in single quotes? I think this is mandatory, but I always use numerical keys so I've lost touch, LOL. Also, I like to get my resources into variable values ASAP. That might be your problem.
I'm sorry this post is so wordy and I'm not sure what isn't working, but if it helps, I'd handle the query return like so (using the correct key number if you use a different query such as "SELECT *"):
- PHP: Select all
$query = "SELECT first, sec, third FROM votes";
$result = mysql_query($query);
$data = mysql_fetch_row($result);
$one = $data[0];
$two = $data[1];
$three = $data[2];
Now, echo each of the variables to see if you are getting the right value. If you are, remove the echo and you can proceed knowing you have correct variables. If not, you know that the query return is incorrect.