Jessica Posted September 23, 2012 Share Posted September 23, 2012 FIX YOUR STRING CONCATENATION. You can't just throw single quotes, double quotes, and random text around and expect it to be interpereted. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380383 Share on other sites More sharing options...
Christian F. Posted September 23, 2012 Share Posted September 23, 2012 I believe I've told you many times how to fix this: Learn how to actually write PHP. You clearly do not know the basics even, neither are you paying attention to what you're doing. To build upon Jessica's earlier comment: What you're doing is akin to trying to build a skyscraper, without knowing how to use a hammer even, while wearing a blind fold. Since you refuse to listen to what we're saying, we cannot help you. The only option available for us, is to write the code for you. If you want someone to do that, you'll need to pay. Simple as that. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380385 Share on other sites More sharing options...
JLT Posted September 23, 2012 Share Posted September 23, 2012 (edited) I cannot be bothered to read the whole post. You pretty much ask us to fix it for you, that isn't our job. We guide you in the right direction on fixing things yourself. Based on the change of syntax highlighting I've seen on the forums, everything that's green should be a string. 'mysql_real_escape_string()' is a function, and there for should be black. Go figure. Everything we've said (or almost) is there to help you. If you decide not to listen, then it isn't going to help you is it? Edited September 23, 2012 by JLT Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380387 Share on other sites More sharing options...
kicken Posted September 23, 2012 Share Posted September 23, 2012 How strings work String concatenation INSERT syntax Read each of those manual pages, then try writing your code again. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380388 Share on other sites More sharing options...
justlukeyou Posted September 23, 2012 Author Share Posted September 23, 2012 (edited) Dont understand them. With this code that works I have a comma at the end. When I try to add a comma to the end of the code I am trying to join together it creates an errror. I just dont get it!!! $query = 'INSERT INTO users SET email = "' . mysql_real_escape_string($registerEmail) . '", password = MD5("' . mysql_real_escape_string($registerPassword) . '"), date_registered = "' . date('Y-m-d H:i:s') . '"'; If its BASIC why not just point out what the error is. This is getting silly. Edited September 23, 2012 by justlukeyou Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380395 Share on other sites More sharing options...
justlukeyou Posted September 23, 2012 Author Share Posted September 23, 2012 (edited) Right, after playing about with it for around 50 times I have got it so it is no longer generating an error. However whenever I try to insert it now creates the error "There was a problem registering you. Please check your details and try again." Like having a tooth extracted but getting there! if(!$errors){ $query = mysql_query("INSERT INTO users SET email (firstname, surname) VALUES ('" . $firstname . "', '" . $surname . "')"); "' . mysql_real_escape_string($registerEmail) . '"; 'password = MD5("' . mysql_real_escape_string($registerPassword) . '")'; 'date_registered = "' . date('Y-m-d H:i:s') . '"'; if(mysql_query($query)){ $success['register'] = 'Thank you for registering. You can now log in on the left.'; }else{ $errors['register'] = 'There was a problem registering you. Please check your details and try again.'; } } } Edited September 23, 2012 by justlukeyou Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380399 Share on other sites More sharing options...
Pikachu2000 Posted September 23, 2012 Share Posted September 23, 2012 According to the logic in your code, why do you think that error might be displayed? Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380401 Share on other sites More sharing options...
justlukeyou Posted September 23, 2012 Author Share Posted September 23, 2012 (edited) No idea, but I shall pull my hair out for the next 3 days trying to find out why. According to the logic in your code, why do you think that error might be displayed? Not another rhetorical question. Dont worry I shall spend another 3 days pulling my hair out trying to find out why. And please dont come back and say "well if thats your attitude I wont tell you. I was going to tell you." because that would mean you genuinely have something useful to say like answering your own question. Edited September 23, 2012 by justlukeyou Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1380402 Share on other sites More sharing options...
justlukeyou Posted October 10, 2012 Author Share Posted October 10, 2012 When I use the vardump as below: var_dump($_SESSION) ; If get this code: array(1) { ["userID"]=> string(3) "test" } I take it this is competely wrong. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1384263 Share on other sites More sharing options...
ManiacDan Posted October 10, 2012 Share Posted October 10, 2012 (edited) The bug in reply #10 was a missing comma. I got too annoyed reading the thread to see if I'm the first person to spot it. Edit: Holy crap turn on error_reporting. Reply #31 would throw at least 6 PHP errors. Edited October 10, 2012 by ManiacDan Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1384269 Share on other sites More sharing options...
justlukeyou Posted October 10, 2012 Author Share Posted October 10, 2012 Apologies, replied to the wrong post. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1384270 Share on other sites More sharing options...
Pikachu2000 Posted October 10, 2012 Share Posted October 10, 2012 Edit: Holy crap turn on error_reporting. Reply #31 would throw at least 6 PHP errors. He's been told that dozens of times and continues to ignore it. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1384273 Share on other sites More sharing options...
ManiacDan Posted October 10, 2012 Share Posted October 10, 2012 Then stop helping him so he can go somewhere else. I don't understand the people who say: I know we've had this before but I really cant see the point of a forum that tells you to go somewhere else. while simultaneously ignoring everything we say. This code is a random slapping together of disparate elements with no consistent style, random indentation, invalid SQL syntax, strings that exist for no reason as bare non-operations, poor concatenation, no security, and will never improve from us simply repeating good advice over and over. Stop what you're doing. Start this section of code over. Turn on error reporting. Handle your SQL errors. In fact, do this: $result = mysql_query( $sql ); if ( $result === false ) { die("Fatal SQL error for: {$sql}<P />MySQL Server returned: <br />" . mysql_error()); } If you use mysql_query anywhere else but in that exact block we can't help you. Copy and paste that. Copy and paste this as well: error_reporting(E_ALL); Error_reporting should be the very first line in your script. Quote Link to comment https://forums.phpfreaks.com/topic/268666-frustrating-sign-insert/page/2/#findComment-1384278 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.