PHPStudent Posted September 9, 2020 Share Posted September 9, 2020 Hi, I'm trying to get this voting script to work but I keep getting the following error A critical error has occurred, and page execution has stopped. Below are the details: 1136: Column count doesn't match value count at row 1 Action taken: Attempted to execute query: INSERT INTO votes values (1,1) voted.php <?php require "globals.php"; $_GET['ID'] = abs((int) $_GET['ID']); $q=$db->query("SELECT * FROM votes WHERE userid=$userid AND site='{$_GET['ID']}'"); if(mysqli_num_rows($q) > 0) { print "You have already voted on this site today!"; die(""); } else { $blak=$db->query("SELECT * FROM votingsites WHERE id={$_GET['ID']}",$c); if(mysqli_num_rows($blak) == 0) { print"<center>This voting site does not exist!</center>"; die(""); } else { $r=mysqli_fetch_array($blak); } $id=$_GET['ID']; $reward=$r['reward']; if($r['rewardtype'] == 1) { $muneh=money_formatter($reward); $db->query("INSERT INTO votes values ($userid,$id)"); event_add($userid,"Thank you for voting! You have receieved $muneh!"); $db->query("UPDATE users SET money=money+$reward WHERE userid=$userid"); } if($r['rewardtype'] == 2) { $db->query("INSERT INTO votes values ($userid,$id)"); if($reward > 1) { event_add($userid,"Thank you for voting! You have receieved $reward crystals!"); } else { event_add($userid,"Thank you for voting! You have receieved $reward crystal!"); } $db->query("UPDATE users SET crystals=crystals+$reward WHERE userid=$userid"); } if($r['rewardtype'] == 3) { $juk=$db->query("SELECT * FROM items WHERE itmid=$reward"); $item=mysql_fetch_array($juk); $db->query("INSERT INTO votes values ($userid,$id)"); $db->query("INSERT INTO inventory values ('',$reward,$userid,1)"); event_add($userid,"Thank you for voting! You have receieved a/an {$item['itmname']}!"); } if($r['rewardtype'] == 4) { $db->query("INSERT INTO votes values ($userid,$id)"); event_add($userid,"Thank you for voting! You have receieved $reward energy!"); $db->query("UPDATE users SET energy=energy+$reward WHERE userid=$userid"); } if($r['rewardtype'] == 5) { $db->query("INSERT INTO votes values ($userid,$id)"); event_add($userid,"Thank you for voting! You have receieved $reward brave!"); $db->query("UPDATE users SET brave=brave+$reward WHERE userid=$userid"); } if($r['rewardtype'] == 6) { $db->query("INSERT INTO votes values ($userid,$id)"); event_add($userid,"Thank you for voting! You have receieved $reward will!"); $db->query("UPDATE users SET will=will+$reward WHERE userid=$userid"); } print"<meta http-equiv='refresh' content='0;url={$r['url']}' />"; exit; } ?> Quote Link to comment Share on other sites More sharing options...
URBANZ Posted September 9, 2020 Share Posted September 9, 2020 thats to do with my mysql table, the data you are trying to insert dont match the amount of columns in the database. could you post the `votes` table from your database Quote Link to comment Share on other sites More sharing options...
ags_cs4 Posted September 9, 2020 Share Posted September 9, 2020 Yes the sql query is wrong all together Quote Link to comment Share on other sites More sharing options...
PHPStudent Posted September 9, 2020 Author Share Posted September 9, 2020 7 hours ago, urbanmafia said: thats to do with my mysql table, the data you are trying to insert dont match the amount of columns in the database. could you post the `votes` table from your database I fixed it, thank you for pointing me in the right direction There was a extra table called "list" in the votes table that didnt need to be there. Ty again. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.