cohan1279 Posted September 11, 2006 Share Posted September 11, 2006 hi, i need a little help please! In this code all but on thing is working.----mysql_query("UPDATE $playerdb SET pvote=(pvote+1) WHERE num=$member_vote;");-----all the rest is working fine. but i cant seem to figure this one out >:(im still very new to this so please help, sadly, ive been trying to figure this out for days![code]if ($do_vote) { global $users; mysql_query("UPDATE $playerdb SET pvote=(pvote+1) WHERE num=$member_vote;"); mysql_query("UPDATE $playerdb SET pvoted=(1) WHERE num=$users[num];"); TheEnd("You have now voted for <b>$listcountry[empire]for your President.</b>."); } ?></table><br>Vote for your President.<br><br><form method="post" action="<?=$config[main]?>?action=country"><table class="inputtable"><tr><th class="acenter">Vote For: <a href=countrys.html></a></th> <td><select name="$member_vote" size="1"><?$pvotes = mysql_query("select num,empire from $playerdb WHERE country=$ucountry[id];");while ($pvote = mysql_fetch_array($pvotes)){?> <option value="<?=$pvote[num]?>"<?if ($pvote[num] == 1) print " selected";?>><?=$pvote[empire]?></option><?}?> </select></td></tr><tr><td colspan="2"> </td></tr><tr><td><input type="submit" name="do_vote" value="Vote"></td> </table></form><?}TheEnd("");?>[/code] Quote Link to comment Share on other sites More sharing options...
kayess2004 Posted September 11, 2006 Share Posted September 11, 2006 Hi,Is $playerdb a table name or the name of the database? Quote Link to comment Share on other sites More sharing options...
cohan1279 Posted September 11, 2006 Author Share Posted September 11, 2006 $playerdb is a table, theres more code (that calls the db) i only included the problem area. ;) Quote Link to comment Share on other sites More sharing options...
cohan1279 Posted September 11, 2006 Author Share Posted September 11, 2006 mysql_query("UPDATE $playerdb SET pvote=(pvote+1) WHERE num=$member_vote;");why does this not work? Quote Link to comment Share on other sites More sharing options...
btherl Posted September 11, 2006 Share Posted September 11, 2006 First, you need to check for errors from mysql_query(). For example:[code]$result = mysql_query( ... )if ($result === false) die("Mysql error " . mysql_error());[/code]Second, if you aren't already you should check the values of $playerdb and $member_vote to make sure they are valid.Then post back here if you are still having trouble :)I think it's likely your problem is here:[code]<td><select name="$member_vote" size="1">[/code]Should that be "member_vote" instead of "$member_vote" ? Quote Link to comment Share on other sites More sharing options...
cohan1279 Posted September 11, 2006 Author Share Posted September 11, 2006 thanks for the reply ,but it hasnt helped >:([code]$result = mysql_query( ... )if ($result === false) die("Mysql error " . mysql_error());[/code]fisrt i tried this, and got an error. wouldnt load my page.also $member_vote is not a table in my db, just the name of the selection to my dropdown selection box. now i could very well be wrong,as im just now learning php, but using this this way has worked before as in this code with $signup_country[code]if ($do_signup){ mysql_query("INSERT INTO $playerdb (num) VALUES (NULL);"); $users = loadUser(mysql_insert_id());$users[country] = $signup_country;<? EndNow("");}?><form method="post" action="<?=$config[main]?>?action=signup"><table class="inputtable"><tr><th class="aright">Your Country: <a href=countrys.html>Help</a></th> <td><select name="signup_country" size="1"><?$countrys = mysql_query("select id,name from $countrydb;");while ($country = mysql_fetch_array($countrys)){?> <option value="<?=$country[id]?>"<?if ($country[id] == 1) print " selected";?>><?=$country[name]?></option><?}?> </select></td></tr><tr><td colspan="2"> </td></tr><tr><td><input type="submit" name="do_signup" value="Sign Me Up!"></td> <td class="aright"><input type="reset" value="Reset Form!"</td></tr></table></form><?HTMLendcompact();?>[/code]and as far as checking the values of $playerdb and $member_vote to make sure they are valid.??? well i know the $playerdb values and the dropdown box is loading the correct users from $playerdb to the page so $member_vote value should be right, its just not updating the $playerdb. as it should be adding 1 to pvote in $playerdb ( -- SET pvote=(pvote+1) -- ) the query should be doing this in the $playerdb where num value in $playerdb matches the num value of $member_vote. how can i check the value of $member_vote as its not really in the db,well not under that name anyway.so i ask agian, any idea why this is not working???? Quote Link to comment Share on other sites More sharing options...
cohan1279 Posted September 12, 2006 Author Share Posted September 12, 2006 Help! lol Quote Link to comment Share on other sites More sharing options...
cohan1279 Posted September 12, 2006 Author Share Posted September 12, 2006 ;D ok I got it. [code]<form method="post" action="<?=$config[main]?>?action=country">[/code]needed to change to [code]<form method="post" action="<?=$config[main]?>?action=vote">[/code]oops .....I cant believe how many times i over looked that! 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.