By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,534 Members | 1,830 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,534 IT Pros & Developers. It's quick & easy.

Fatal error: Unsupported operand types

P: 2
I am making a simple vote system with yes/no radio buttons and a submit button. On submit it sends users choice to a php file - to be increased by one, related to users input. First it fetches the previous values from database and increases them by one.Second, it puts increased value back into database table.The problem is that my PLUS sign cant be recognized.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $con = mysql_connect("localhost","pinz","password");
  3. if (!$con)
  4.   {
  5.   die('Could not connect: ' . mysql_error());
  6.   }
  7.  
  8. mysql_select_db("pinz_baza", $con);
  9.  
  10. $votey = mysql_query("SELECT VoteYes FROM Votes");
  11. $voten = mysql_query("SELECT VoteNo FROM Votes");
  12.  
  13. $resulty = mysql_fetch_array($votey);
  14. $resultn = mysql_fetch_array($voten);
  15. $resform = $_POST['vote'];
  16.  
  17. if ($resform == 'yes') 
  18.     {
  19.     $resultyn = $resulty + 1; /*error is shown here*/
  20.     mysql_query("UPDATE Votes SET VoteYes = '$resultyn'
  21.     WHERE VoteYes = '$resulty'");
  22.     echo "added one YES vote";
  23.     }
  24. else {
  25.     $resultnn = $resultn + 1; /*and here*/
  26.     mysql_query("UPDATE Votes SET VoteYes = '$resultnn'
  27.     WHERE VoteNo = '$resultn'");
  28.     echo "added one NO vote";
  29.     }
  30.  
  31. mysql_close($con);
  32. ?>
Help me plzzz
Dec 10 '10 #1
Share this Question
Share on Google+
2 Replies


P: 13
I am fairly new to php but you could try this:
Expand|Select|Wrap|Line Numbers
  1. $resultyn = $resulty ++; 
and the same for the other part.

Just my 2 cents
Dec 10 '10 #2

P: 2
nope doesnt work

thx for attention anyways...

Still need help plz
Dec 10 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.