Jump to content
MakeWebGames

Voting Script Help


PHPStudent

Recommended Posts

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;
}
?>

 

 

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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.   Paste as plain text instead

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