Jump to content

Dragoonus

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Dragoonus's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Im making a big vote (as you may have noticed in my other post) after managing to get the vote updating I now can't seem to get the cookies working (heh, no doubt I'll be back onces its IP time, lol) anyhoos the problem is that I am allowed to vote even if I do have the cookie. I thinks its something to do with $voteValid <?php require_once('Connections/mysql.php'); ?> <?php if( isset( $HTTP_COOKIE_VARS[ '$IVoted' ] ) ) { // cookie exists, BAD vote! $voteValid = 0; } else { $voteValid = "1"; } ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $HTTP_SERVER_VARS['PHP_SELF']; if($voteValid>0) { if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING']; } } if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE poll_one SET Vote=Vote+1 WHERE lid=%s", GetSQLValueString($HTTP_POST_VARS['title'], "text"), GetSQLValueString($HTTP_POST_VARS[Vote], "int"), GetSQLValueString($HTTP_POST_VARS['lid'], "int")); mysql_select_db($database_mysql, $mysql); $Result1 = mysql_query($updateSQL, $mysql) or die(mysql_error()); $updateGoTo = "/results.php"; if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_mysql, $mysql); $query_Recordset1 = "SELECT * FROM poll_one"; $Recordset1 = mysql_query($query_Recordset1, $mysql) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form method="post" name="form1" action="<?php echo $editFormAction; ?>"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Title:</td> <td> <select name="title" size="15"> <?php do { ?> <option value="<?php echo $row_Recordset1['lid']?>"><?php echo $row_Recordset1['title']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </select> </td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input type="submit" value="Update Record"></td> </tr> </table> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="lid" value="<?php echo $row_Recordset1['lid']; ?>"> </form> <p> </p> </body> </html> <?php mysql_free_result($Recordset1); ?> As you can see this is just the test (hence no proper names or anything) anyhoos any help at all would be appreciated, It seems everytime I take a step forward I have to rewind to nothing 4 days later before I can take the next step... lol o btw setcookie is on another page
  2. I started from scratch and have now managed it, as I found no delete option I thought I'd better tell you
  3. I have made polls in the past no problem, perhaps I forgot how, I dunno, anyhoos I recently decided to make a large poll (and simply call it vote) however after making the options into a select list I have encountered nothing but problems, after solving god knows how many I have ended up with the following code (messy I know... <?php require_once('Connections/myplace.php'); ?> <?php mysql_select_db($database_myplace, $myplace); $query_Vote = "SELECT title FROM links_link"; $Vote = mysql_query($query_Vote, $myplace) or die(mysql_error()); $row_Vote = mysql_fetch_assoc($Vote); $totalRows_Vote = mysql_num_rows($Vote); ?> <?php echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <?php mysql_select_db($database_myplace, $myplace) or die("Couldn't open $db: ".mysql_error()); foreach ($check as $value){ mysql_query("UPDATE links_link SET Vote=Vote+1 WHERE voter =title"); } $result = mysql_query( "SELECT title,Vote FROM links_link" ) or die("SELECT Error: ".mysql_error()); //display the updated results $num_rows = mysql_num_rows($result); print "<html><head><style type=text/css> #poll{border-top :solid #004f9d 2px;border-left :solid #004f9d 2px} #poll tr td {border-bottom :solid #004f9d 2px;border-right :solid #004f9d 2px} #poll tr td {font-family: Small Fonts;font-style : normal;font-size : 7pt; font-weight :bold } h3{font-family: Arial;font-style : normal;font-size : 9pt; font-weight :bold;text-align : center; color :#FFFFFF;background-color :#004f9d }</style> </head> <body> <table width=100%><tr valign=top><td>\n"; print "<table ID=poll cellspacing=0 cellpadding=5 width=125 >\n"; print "<tr valign=top><td colspan=2 bgcolor=#004f9d><h3>Other users chose these options.</h3></td></tr>\n"; while ($get_info = mysql_fetch_row($result)){ print "<tr>\n"; foreach ($get_info as $field ) print "\t<td>$field</td>\n"; print "</tr>\n"; } print "</table> </tr></table></body></html>\n"; mysql_close($link); ?> <table ID="poll" width="125" cellpadding="2" cellspacing="0" border="0"> <tr align="center" valign="top"> <td align="left" colspan="1" rowspan="1"> <h4>Arrrrrgggg!!!</h4> <form action="yh.php" method="GET" name="formvote" id="formvote"> <select name="voter" size="15"> <?php do { ?> <option value="<?php echo $row_Vote['title']?>"<?php if (!(strcmp($row_Vote['title'], $row_Vote['title']))) {echo "SELECTED";} ?>><?php echo $row_Vote['title']?></option> <?php } while ($row_Vote = mysql_fetch_assoc($Vote)); $rows = mysql_num_rows($Vote); if($rows > 0) { mysql_data_seek($Vote, 0); $row_Vote = mysql_fetch_assoc($Vote); } ?> </select> <input type="submit" value="Results"><input type="reset"> </form> </td></tr></table> </body> </html> <?php mysql_free_result($Vote); ?> Everything seems to work, I can choose my options, view the results however once I submit it doesn't update the database... (I even tried onsubmit= blah... blah.. yet no joy) I think it might be something to do with the mysql_query("UPDATE links_link SET Vote=Vote+1 WHERE voter =title"); part perhaps? The code is not mine, i have just edited it, perhaps this is one of the reasons... none the less I'm unsure as to why it won't update the field, its probalby something really simple, but meh I'm new to this (I'm sure you get many of my type lol) Thanks in advance - Confused PHP/MySQL Newb Dragoonus
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.