TheBudgie Posted March 28, 2010 Share Posted March 28, 2010 Okay i'm having a problem with my code. I try not to resort to forums just requesting answers but i've been hammering at this for hours :'( Wasn't sure whether to put this on a flash help site or a php one, but i think this mainly consists of php so here goes. From data input in flash, Im trying to check my database if an email is present, and if it is offer to overwrite data and if it isn't then add it. However whenever i type in an e-mail address it adds a space after it and places it in my database. The code on my button in flash is: on (press) { _root.cancelAction._alpha = 0; _root.statusBooking = ""; varSender = new LoadVars(); varReceiver = new LoadVars(); varSender.nameOfGroup = nameOfGroup.text; varSender.emailAddress = emailAddress.text; varSender.addLine1 = addLine1.text; varSender.addLine2 = addLine2.text; varSender.town = townName.text; varSender.postCode = postCode.text; varSender.phoneNumber = phoneNumber.text; varSender.mobileNumber = mobileNumber.text; varSender.emailErrorIgnoreFlag = emailErrorIgnoreFlag; varSender.sendAndLoad("http://localhost/hbs/hbsfiles/finishBooking.php", varReceiver, "POST"); varReceiver.onLoad = function() { diffDetails = this.diffDetails; success = this.success; if (diffDetails == 1) { _root.statusBooking = "E-Mail information is different. Click again to Confirm or 'Cancel action' to Cancel."; emailErrorIgnoreFlag = 1; _root.cancelAction._alpha = 100; } else if (success == 1) { _root.statusBooking = "Action Complete."; } }; } And in finishBooking.php: <?php include 'SQLlogin.php'; $nameOfGroup=$_POST['nameOfGroup']; $emailAddress=$_POST['emailAddress']; $addLine1=$_POST['addLine1']; $addLine2=$_POST['addLine2']; $town=$_POST['town']; $postCode=$_POST['postCode']; $phoneNumber=$_POST['phoneNumber']; $mobileNumber=$_POST['mobileNumber']; $emailErrorIgnoreFlag=$_POST['emailErrorIgnoreFlag']; $diffDetails = 0; $success = 0; if($emailErrorIgnoreFlag == 0){ $query = "SELECT AddLine1, AddLine2, Town, PostCode, phoneNumber, mobileNumber, email FROM customerinfo WHERE email = '$emailAddress'"; $result = mysql_query($query); $count = mysql_num_rows($result); if($count == 0){ $emailErrorIgnoreFlag = 1; }else{ $info = mysql_fetch_assoc($result); if($addLine1 == $info[AddLine1] and $addLine2 == $info[AddLine2] and $town == $info[Town] and $postCode == $info[PostCode] and $phoneNumber == $info[phoneNumber] and $mobileNumber == $info[mobileNumber]){ $success = 1; }else{ $diffDetails = 1; }; }; }; if($emailErrorIgnoreFlag == 1){ $query = "DELETE FROM customerinfo WHERE email = '$emailAddress'"; $result = mysql_query($query); $query = "INSERT INTO customerinfo (AddLine1, AddLine2, Town, PostCode, phoneNumber, mobileNumber, email) VALUES ('$addLine1', '$addLine2', '$town', '$postCode', '$phoneNumber', '$mobileNumber','$emailAddress')"; echo "&emailAddi=" . $emailAddress; $result = mysql_query($query); $success = 1; }; echo "&diffDetails=" . $diffDetails; echo "&success=" . $success; echo "&emailAddi=" . $emailAddress; // or die("Query error: ". mysql_error()) //SELECT TIME_TO_SEC(TIMEDIFF('2007-01-09 10:24:46','2007-01-09 10:23:46')); mysql_close(); ?> Any help would be massively appreciated. Thankyou. Link to comment https://forums.phpfreaks.com/topic/196776-php-adding-space-i-think/ Share on other sites More sharing options...
cags Posted March 29, 2010 Share Posted March 29, 2010 I don't really see how the space is appearing, my guess is perhaps it's not a space but a newline character that's getting converted at some point along the way. In either case, you should be able to solve it by simply using... $emailAddress=trim($_POST['emailAddress']); Link to comment https://forums.phpfreaks.com/topic/196776-php-adding-space-i-think/#findComment-1033443 Share on other sites More sharing options...
TheBudgie Posted March 29, 2010 Author Share Posted March 29, 2010 thank you man. i love you. it works. Link to comment https://forums.phpfreaks.com/topic/196776-php-adding-space-i-think/#findComment-1033617 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.