defroster Posted September 27, 2010 Share Posted September 27, 2010 Hello, I have a voting system on my website which works well. Now I just wanted to add another different voting system to the site so I took all voting files and also made new table everything starts with 'x' in front to differentiate between the two voting system. But there must be something I am missing, because the votes in the 'new voting system' keeps adding votes to the 'other voting system' . In the index.php file the only things I changed in the javascript where the name of the pages (added x in front of filename), but I suspect I need to change more.. Any ideas? - Thanks a million, I am completely stuck File: index.php contains this script <script type="text/javascript"> $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var dataString = 'id='+ id ; var parent = $(this); if(name=='up') { $(this).fadeIn(200).html('<img src="incl/dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "xup_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } else { $(this).fadeIn(200).html('<img src="incl/dot.gif" align="absmiddle">'); $.ajax({ type: "POST", url: "xdown_vote.php", data: dataString, cache: false, success: function(html) { parent.html(html); } }); } return false; }); }); </script> Calling for the vote: echo "<div class='votingarea'>"; echo "<div class='up'><a href='' class='vote' id='". $row['id'] ."' name='up'>".$row['xup']."</a></div>"; echo "<div class='down'><a href='' class='vote' id='". $row['id'] ."' name='down'>".$row['xdown']."</a></div>"; $id=$row['id']; $up=$row['xup']; $down=$row['xdown']; echo "</div>"; //closes votingarea file: xup_vote.php <?php include("incl/config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Could not connect database"); mysql_select_db($dbdatabase, $db) or die("Could not select database"); $ip=$_SERVER['REMOTE_ADDR']; if($_POST['id']) { $id=$_POST['id']; $id = mysql_escape_String($id); //Verify IP address in Voting_IP table $ip_sql=mysql_query("select ip_add from xvoting_ip where id_fk='$id' and ip_add='$ip'"); $count=mysql_num_rows($ip_sql); if($count==0) { // Update Vote. $sql = "update videos set xup=xup+1 where id='$id'"; mysql_query( $sql); // Insert IP address and Message Id in Voting_IP table. $sql_in = "insert into xvoting_ip (id_fk,ip_add) values ('$id','$ip')"; mysql_query( $sql_in); #echo "<script>alert('Thanks for the vote');</script>"; } else { echo "<script>alert('You have already voted');</script>"; } $result=mysql_query("select xup from videos where id='$id'"); $row=mysql_fetch_array($result); $up_value=$row['xup']; echo $up_value; } ?> file: xdown_vote.php <?php include("incl/config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Could not connect database"); mysql_select_db($dbdatabase, $db) or die("Could not select database"); $ip=$_SERVER['REMOTE_ADDR']; if($_POST['id']) { $id=$_POST['id']; $id = mysql_escape_String($id); //Verify IP address in Voting_IP table $ip_sql=mysql_query("select ip_add from xvoting_ip where id_fk='$id' and ip_add='$ip'"); $count=mysql_num_rows($ip_sql); if($count==0) { // downdate Vote. $sql = "update videos set xdown=xdown+1 where id='$id'"; mysql_query( $sql); // Insert IP address and Message Id in Voting_IP table. $sql_in = "insert into xvoting_ip (id_fk,ip_add) values ('$id','$ip')"; mysql_query( $sql_in); #echo "<script>alert('Thanks for the vote');</script>"; } else { echo "<script>alert('You have already voted');</script>"; } $result=mysql_query("select xdown from videos where id='$id'"); $row=mysql_fetch_array($result); $down_value=$row['xdown']; echo $down_value; } ?> Link to comment https://forums.phpfreaks.com/topic/214556-duplicate-script-code-however-data-posted-to/ Share on other sites More sharing options...
defroster Posted September 27, 2010 Author Share Posted September 27, 2010 Ok, I have been sitting countless hours trying to resolve this. As soon as I write the post here and go back to the code it all of a sudden works. Strange things happen. Anyways, problem solved! Link to comment https://forums.phpfreaks.com/topic/214556-duplicate-script-code-however-data-posted-to/#findComment-1116476 Share on other sites More sharing options...
Pikachu2000 Posted September 27, 2010 Share Posted September 27, 2010 It must be our magicalness!!!!!11!eleventy-one!!1 Link to comment https://forums.phpfreaks.com/topic/214556-duplicate-script-code-however-data-posted-to/#findComment-1116489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.