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); ?>
  9. Hi - the address was passing in but the textarea was padded in and it wasn't appearing in my query browser window :/ You've all been pretty much fantastic help- thanks!!
  10. that didn't solve it- the spelling is consistent so it can't be that- i'll have another wee look at the database... <?php require_once('recaptcha/recaptchalib.php'); $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification require_once("../includes/db_connect.php"); if(isset($_POST['Send'])){ $name=$_POST['name']; $address=$_POST['address']; $UCAS=$_POST['UCAS']; $mob=$_POST['mob']; $email=$_POST['email']; $tel=$_POST['tel']; $subject=$_POST['subject']; $interviewdate=$_POST['interviewdate']; $interviewtime=$_POST['interviewtime']; $parents=$_POST['parents']; $addEntry="INSERT INTO UCASinterviews(name,address,UCAS,tel,email,mob,subject,interviewdate,interviewtime,parents)VALUES('$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');"; $addResult=mysql_query($addEntry,$db); } } ?>
  11. You, my friend are a hero- it's passing everything through now but it's leaving out the "address" field :/ For want of sounding thick- at this point i don't care- Why did that make it work? (and thanks)
  12. Query string is getting passed to the thanks3.php and being lost before the INSERT somehow. It won't echo the variables but if I use $_GET, they appear as they should in the query string in the top of the browser. @robert_gsfame - well spotted but that doesn't seem to have changed anything @ litebearer- tried this too- doesn't seem to have any bearing :/
  13. Hi - thanks for the replies but unfortunately that didn't work. It's meant just to add another record everytime, not update an existing one. This is what I attempted: <?php require_once('recaptcha/recaptchalib.php'); $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification require_once("../includes/db_connect.php"); if($_POST['submit']=="true"){ $name=$_POST['name']; $address=$_POST['address']; $UCAS=$_POST['UCAS']; $mobile=$_POST['mob']; $email=$_POST['email']; $tel=$_POST['tel']; $subject=$_POST['subject']; $interviewdate=$_POST['interviewdate']; $interviewtime=$_POST['interviewtime']; $parents=$_POST['parents']; $addEntry="INSERT INTO UCASinterviews(name,address,UCAS,tel,email,mob,subject,interviewdate,interviewtime,parents)VALUES('$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');"; $addResult=mysql_query($addEntry,$db); } } ?>
  14. Hi I'm trying to update a form to a mysql database- it's simply all text fields except for one integer which is the primar key (auto increment etc) http://www.arts.ulster.ac.uk/interviews/test.php http://www.arts.ulster.ac.uk/interviews/thanks3.php test.php holds the form and the recaptcha which all seems to be fine and it posts to thanks3.php which (when i switched to $_GET) is passing the variables to that page but those values are not being stored. I then input my query into the mySQL query browser: INSERT INTO UCASinterviews VALUES ('','$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents'); which updated the values i put in but gave this error: Incorrect integer value: '' for column 'ID' at row 1 thanks3.php just won't transfer that info to the table no matter what I try. I used $_GET, I used PHP_SELF, I stripped the rest of the page away to make sure nothing was conflicting and now I'm totally stumped- please could someone look at this with fresh eyes? test.php: <!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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form action="thanks3.php" method="post" id="form2" style="margin-left:15px; display:;"> <dl id="contform"> <dd><label>Name:</label><br /> <input class="padform" type="text" name="name" size="43" maxlength="20" tabindex="2"/></dd> <label>UCAS ID:</label><br /> <input class="padform" name="UCAS" type="text" id="UCAS" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Email:</label><br /> <input class="padform" name="email" type="text" id="email" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Mobile:</label><br /> <input class="padform" name="mob" type="text" id="mob" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Landline:</label><br /> <input class="padform" name="tel" type="text" id="tel" tabindex="3" size="43" maxlength="30"/></dd> <dd> <label>Subject:</label><br /> <select name="subject" tabindex="1" class="padform"> <option value="English">English</option> <option value="European Studies">European Studies</option> <option selected value="Film Studies">Film Studies</option> <option value="French">French</option> <option value="German">German</option> <option value="History">History</option> <option value="Irish">Irish</option> <option value="Spanish">Spanish</option> <option value="Journalism">Journalism</option> <option value="Photo Imaging">Photo Imaging</option> <option value="Media Studies and Production">Media Studies & Production</option> <option value="Interactive Media Arts">Interactive Media Arts</option> </select></dd> <dd><label>Address:</label><br /> <textarea class="padform"name="address" cols="40" rows="15" id="address" tabindex="5"/> </textarea></dd> <dd> <label>Preferred Interview Date:</label> <select name="interviewdate" class="padform"> <option value="26/02/11">26 February 2011</option> <option selected value="12/03/11">12 March 2011</option> </select> </dd> <dd> <label>Preferred Interview Time:</label> <select name="interviewtime" class="padform"> <option value="AM">Morning (AM)</option> <option selected value="PM">Afternoon (PM)</option> </select> </dd> <dd> <label>Parents/Guardians:</label> <select name="parents" class="padform"> <option value="1">1</option> <option selected value="2">2</option> </select> </dd> <dd> <p> <?php require_once('recaptcha/recaptchalib.php'); $publickey = "6LdU2b4SAAAAAGsh6Z78HjunUL6Mt-ZqCXtIimOs"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> </p> </dd> <dd style="background:none;"><input class="btn" type="submit" name="submit" value="Send" tabindex="6" id="submit" /></dd> </dl> </form> </div> </body> </html> thanks3.php <?php require_once('recaptcha/recaptchalib.php'); $privatekey = "6LdU2b4SAAAAAN_Z9rLyvle0vb4n4EbyAVyXDa6V"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { // What happens when the CAPTCHA was entered incorrectly die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } else { // Your code here to handle a successful verification require_once("../includes/db_connect.php"); if($_POST['submit']=="true"){ $name=$_POST['name']; $address=$_POST['address']; $UCAS=$_POST['UCAS']; $mobile=$_POST['mob']; $email=$_POST['email']; $tel=$_POST['tel']; $subject=$_POST['subject']; $interviewdate=$_POST['interviewdate']; $interviewtime=$_POST['interviewtime']; $parents=$_POST['parents']; $addEntry="INSERT INTO UCASinterviews VALUES ('','$name','$address','$UCAS','$tel','$email','$mob','$subject','$interviewdate','$interviewtime','$parents');"; $addResult=mysql_query($addEntry,$db); } } ?> I have other forms working with this near enough the same structure/layout/code - i'm ready to have a coronary! Is it the database setup? It's same as it ever was myISAM, UTF unicode... [attachment deleted by admin]
×
×
  • 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.