Jump to content

coalduststar

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.wehaveresolve.com

Profile Information

  • Gender
    Not Telling
  • Location
    Northern Ireland

coalduststar's Achievements

Member

Member (2/5)

0

Reputation

  1. bump * database isn't recording anything and it appears the variable aren't being passed in :/
  2. Hi guys I figured out the error- it was because I hadn't used quotes so it wasn't pulling in the email- i rectified that. Got this now- and it's going to yeo.php but not updating the database at all- i've also attached the form under the code- stumped <?php require_once('../Connections/IMAK.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "kill")) { //explode killer $target = $_POST['players']; $weapon = $_POST['weapon']; $killer = $_POST['killer']; $piece = explode(" ", $killer); $piece[0] = $email; $piece[1] = $year; //score = year+weapon+tweet*evidence $youtube = "youtube"; if (stristr($_POST['evidence'], $youtube) == TRUE){ $kill_score = ($year + $weapon + $tweet)*2; }else{ $kill_score = ($year + $weapon + $tweet); } mysql_select_db($database_IMAK, $IMAK); $query_players2 = "SELECT current_target FROM IMAK_player WHERE email = '$target'"; $players2 = mysql_query($query_players2, $IMAK) or die(mysql_error()); $row_players2 = mysql_fetch_assoc($players2); $totalRows_players2 = mysql_num_rows($players2); $row_players2['current_target'] = $current_target; $updateSQL = sprintf("UPDATE IMAK_player SET killer=%s, evidence=%s, weapon=%s, tweet=%s, current_target=%s, kill_score=%s WHERE email=%s", GetSQLValueString($email, "text"), GetSQLValueString($_POST['evidence'], "text"), GetSQLValueString($weapon, "text"), GetSQLValueString(isset($_POST['tweet']) ? "true" : "", "defined","1","0"), GetSQLValueString($current_target, "text"), GetSQLValueString($kill_score, "text"), GetSQLValueString($target, "text")); mysql_select_db($database_IMAK, $IMAK); $Result1 = mysql_query($updateSQL, $IMAK) or die(mysql_error()); $updateGoTo = "yeo.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } //populate player list mysql_select_db($database_IMAK, $IMAK); $query_players = "SELECT * FROM IMAK_player WHERE active = 1"; $players = mysql_query($query_players, $IMAK) or die(mysql_error()); $row_players = mysql_fetch_assoc($players); $totalRows_players = mysql_num_rows($players); ?> here's the form <form action="<?php echo $editFormAction; ?>" method="POST" name="kill"> <li> <select name="players" title="select player"> <?php do { ?> <option value="<?php echo $row_players['email']?> <?php echo $row_players['year']; ?>"><?php echo $row_players['name']?> <?php echo $row_players['surname']?> (<?php echo $row_players['year']; ?>)</option> <?php } while ($row_players = mysql_fetch_assoc($players)); $rows = mysql_num_rows($players); if($rows > 0) { mysql_data_seek($players, 0); $row_players = mysql_fetch_assoc($players); } ?> </select> <img src="../images/murdah.png" alt="has assassinated" width="100" height="49" border="0" align="middle" /> <select name="killer" title="select killer"> <?php do { ?> <option value="<?php echo $row_players['email']?>"><?php echo $row_players['name']?> <?php echo $row_players['surname']?> (<?php echo $row_players['year']; ?>)</option> <?php } while ($row_players = mysql_fetch_assoc($players)); $rows = mysql_num_rows($players); if($rows > 0) { mysql_data_seek($players, 0); $row_players = mysql_fetch_assoc($players); } ?> </select></li> <li> <input name="evidence" type="text" size="30" /></li> <li> <img src="../images/weapons/gun.png" alt="gun" width="70" height="47" align="middle" /> <input name="weapon" type="radio" value="1" checked/> <img src="../images/weapons/dagger.png" alt="dagger" width="50" height="47" align="middle" /> <input name="weapon" type="radio" value="2" /> <img src="../images/weapons/poison.png" alt="poison" width="50" height="47" align="middle" /> <input name="weapon" type="radio" value="3" /> <img src="../images/weapons/garotte.png" alt="garotte" width="50" height="47" align="middle" /> <input name="weapon" type="radio" value="4" /> </li> <li> <img src="../images/twitter.png" alt="twitter" width="50" height="50" align="middle" /> <input name="tweet" type="checkbox" value="1" /> </li> <li><input name="submit" type="submit" value="KILL" /> </li> <input type="hidden" name="MM_update" value="kill" /> <input type="hidden" name="<?php echo $row_players['year']; ?>" value="kill" /> </form>
  3. could that SQL error be a symptom of the database not accepting an email as a primary key? @kworld
  4. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@email.ulster.ac.uk 3' at line 1 i wasn't getting anything- it was just dying and now i have this one above which isn't really pointing at anything
  5. //score = year+weapon+tweet*evidence $youtube = "youtube"; if (stristr($_POST['evidence'], $youtube) === TRUE){ $kill_score = ($year + $weapon + $tweet)*2; }else{ $kill_score = ($year + $weapon + $tweet); } is this more correct or should i still use ==?
  6. yeah the email variable has to be made from another variable as all the info is in a drop down list of players email and what year they're in. the problem is that because it's a drop down list all the calculations have to happen after the submit button is clicked? at least i think so. as for the database- how might that be set up incorrectly? I have email as the primary key etc. i have a strpos but i'm gonna have to use a stristr so thanks for flagging that
  7. in the middle of troubleshooting it now- just wanted to make sure there weren't any glaring disasters. there's no error so my guess is it's dying when it's trying to get the current_target out
  8. I started using dreamweaver to do part of this and now i've made and epic hash up it's for a game of killer- to log a kill you select a player and his killer from the database which is one table with the unique email as a primary key when someone is killed the score has to be calculated and then the dead person's target (also email) has to be reassigned to the killer (hence the select query in the middle of the update) it's not making it through and i was wondering if someone could help me http://www.arts.ulster.ac.uk/IMAK/admin <?php require_once('../Connections/IMAK.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "kill") && ($email != $target)) { //explode killer $target = $_POST['players']; $weapon = $_POST['weapon']; $killer = $_POST['killer']; $piece = explode(" ", $killer); $piece[0] = $email; $piece[1] = $year; //score = year+weapon+tweet*evidence $youtube = "youtube"; $proof = strpos($_POST['evidence'], $youtube); if($proof === true){ $kill_score = ($year + $weapon + $tweet)*2; }else{ $kill_score = ($year + $weapon + $tweet); } mysql_select_db($database_IMAK, $IMAK); $query_players2 = "SELECT current_target FROM IMAK_player WHERE email = $target"; $players2 = mysql_query($query_players2, $IMAK) or die(mysql_error()); $row_players2 = mysql_fetch_assoc($players2); $totalRows_players2 = mysql_num_rows($players2); $updateSQL = sprintf("UPDATE IMAK_player SET killer=%s, evidence=%s, weapon=%s, tweet=%s, current_target=%s, kill_score=%s WHERE email=%s", GetSQLValueString($email, "text"), GetSQLValueString($_POST['evidence'], "text"), GetSQLValueString($weapon, "text"), GetSQLValueString(isset($_POST['tweet']) ? "true" : "", "defined","1","0"), GetSQLValueString($row_players2['current_target'], "text"), GetSQLValueString($kill_score, "text"), GetSQLValueString($target, "text")); mysql_select_db($database_IMAK, $IMAK); $Result1 = mysql_query($updateSQL, $IMAK) or die(mysql_error()); $updateGoTo = "yeo.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } //populate player list mysql_select_db($database_IMAK, $IMAK); $query_players = "SELECT * FROM IMAK_player WHERE active = 1"; $players = mysql_query($query_players, $IMAK) or die(mysql_error()); $row_players = mysql_fetch_assoc($players); $totalRows_players = mysql_num_rows($players); ?>
×
×
  • 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.