Jump to content

Archived

This topic is now archived and is closed to further replies.

justlukeyou

Frustrating = Sign Insert

Recommended Posts

Hi,

 

I am trying to put together the insert code for a form however what ever I try the = sign here password = MD5 creates an error.

 

I have tried around 10 variations such as placing the line in brackets but whatever I try it creates an error. When I remove this code it enters the firstname and surname but I cant get the password part to enter. Any suggestions please?

 

 

	    $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.';  

          		  }  
    }  

           }   

Share this post


Link to post
Share on other sites

Hi,

 

Yes deja vu. Im not trying to make a secure login system. Im trying to make a login system that works and then make it secure.

 

Apart from email authorisation I almost have a login system. Just need to finish this and create an update page to add details to a members profile. The first phase is getting there.

 

But thanks for link. I shall check that out once I have completed the first phase.

Share this post


Link to post
Share on other sites

I'm not trying to build a house that can stand up, I just want to build a house and then I'll make it stand up later.

Share this post


Link to post
Share on other sites

This is the two options I have:

 

1. Spend 2 months buidling a membership system that works. Spend a further 2 months making it safe.

 

2. Spend 6 months learning upto date PHP and security code. Spend a further 2 months building a membership system that works and is safe.

 

What option would you take?

Share this post


Link to post
Share on other sites

Anything worth having is worth working for.

 

Your options aren't correct. It's more like this.

 

1. Keep banging your head against a wall for 2 months, then spend a year fixing all the holes, cleaning up after problems, loosing members, and generally making a fool of yourself.

2. Do it right the first time, regardless of how long it takes. Which will be less time than it takes to do it wrong and then half-ass fix it, over and over again.

 

To answer your question, I take the option which gets things done the right way. Are you serious? There are plenty of people here who are professionals. If my boss asked me this question (but phrased in a way that makes sense) and I *didn't* answer that I would do things the best possible way, I'd be out of a job. Sometimes in an emergency you have to take a shortcut. But if you set out to do things the lazy way in life, you will never get ahead.

 

There's a reason that literally a dozen or more people here have told you you're going about things the wrong way. We know what we are talking about.

Share this post


Link to post
Share on other sites

 

That said looking at the actual post, what you have is such a basic syntax error that I can't comprehend how you don't get it at this point. The syntax highlighting shows it so clearly that all I can say is LOOK AT WHAT YOU WROTE.

 

SLOW down, learn what you're doing, and do it RIGHT.

Share this post


Link to post
Share on other sites

A truly lazy programmer would make sure he did everything right the first time, as then he'd know that he doesn't have to spend any more time on the code in the future. A sloppy programmer wouldn't care, and thus create loads more work for him as described by Jessica.

That's why I make sure to do everything right the first time around.

 

Remember that we all started out where you are now, and we've gone through all of the steps that you need to take. So the advice we're giving is not only to ensure that everything is correct, but they are the most efficient way of going about things. This we know from experience, personal experience.

 

Right now you're not nearly paying enough attention to what you're doing, and your planning is severely lacking. Meaning that you're programming by coincidence, as you have no real knowledge of what your code does (and why it does this). This means that any code you're currently producing, that's working the first time around, is purely accidental. Meaning you'll have to spent an absurd amount of time rewriting your code repeatedly to find something that (seemingly) works, and even then there might be hidden bugs that crop up in the future. Requiring you to go back, and start the whole rewrite-until-works process again.

The fact of the matter is, doing it this way the amount of work needed is always unknown and always greater than what it would be using the proper method. So saying that you're saving time is a falsehood, brought on by a lack of understanding.

 

Here's some articles on the programming-by-coincidence problem:

http://pragprog.com/the-pragmatic-programmer/extracts/coincidence

http://www.hanselman.com/blog/CargocultProgramming.aspx

http://www.codinghorror.com/blog/2008/03/the-first-rule-of-programming-its-always-your-fault.html

 

PS: As you might notice all of these links are referencing the book "The Pragmatic Programmer". A book I highly recommend for anyone working with code. ;)

Share this post


Link to post
Share on other sites

That said looking at the actual post, what you have is such a basic syntax error that I can't comprehend how you don't get it at this point. The syntax highlighting shows it so clearly that all I can say is LOOK AT WHAT YOU WROTE.

 

SLOW down, learn what you're doing, and do it RIGHT.

 

Its a basic error!? I asked on another forum and they couldn't fix it either lol

 

Could you please point out what the error is. I've got the system working, now Im just trying to add more columns such as first name and surname.

Share this post


Link to post
Share on other sites

This code works btw but when I try to add to it creates an error on the = MD5 point.

 

 

$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') . '"'; 

Share this post


Link to post
Share on other sites

           $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') . '"';  

 

Do you understand the point of syntax highlighing?

 

Or any of the code you wrote? Just READ IT.

 

Share this post


Link to post
Share on other sites

There's nothing technically wrong with the query you just posted, in reply #10.

 

Since you didn't post the error you got, there's no way anyone here can help you with the error. :psychic:

Share this post


Link to post
Share on other sites

Like I've said I can get it to work when I insert two sets of information so I am learning something!!! But when I try to insert both it creates an error on the = sign.

 

This is the error message syntax error, unexpected '='

 

I have read the code and tried to edit it around 20 times but I still cant get it to work.

 

I know there is only one open bracket but whatever I try it still wont work.

Share this post


Link to post
Share on other sites

           $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') . '"';  

 

Do you understand the point of syntax highlighing?

 

Or any of the code you wrote? Just READ IT.

Seriously. THE COLORS.

Share this post


Link to post
Share on other sites

<?php
echo "Hello";
world";
?>

Is what you're doing in your code.

 

See the difference between that and

<?php
echo "Hello 
world";
?>

Share this post


Link to post
Share on other sites

Its helps a little bit but the code Im trying to do is more complex than that. Your example is incredibly obvious.

 

Could you PLEASE outline in detail what I am doing wrong.

Share this post


Link to post
Share on other sites

NO BECAUSE IT'S THE SAME FING THING!!!!

Share this post


Link to post
Share on other sites

This creates syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

 

Im going in round in circles and need some help to fix this problem. I was hoping someone with more skills would help put the two peices of working code I have toghether.

 

 

	 $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') . '"; ")

Share this post


Link to post
Share on other sites

I was hoping someone with more skills would help put the two peices of working code I have toghether.

 

No.

 

Right now you're not nearly paying enough attention to what you're doing, and your planning is severely lacking. Meaning that you're programming by coincidence, as you have no real knowledge of what your code does (and why it does this). This means that any code you're currently producing, that's working the first time around, is purely accidental. Meaning you'll have to spent an absurd amount of time rewriting your code repeatedly to find something that (seemingly) works, and even then there might be hidden bugs that crop up in the future. Requiring you to go back, and start the whole rewrite-until-works process again.

The fact of the matter is, doing it this way the amount of work needed is always unknown and always greater than what it would be using the proper method. So saying that you're saving time is a falsehood, brought on by a lack of understanding.

 

Here's some articles on the programming-by-coincidence problem:

http://pragprog.com/the-pragmatic-programmer/extracts/coincidence

http://www.hanselman.com/blog/CargocultProgramming.aspx

http://www.codinghorror.com/blog/2008/03/the-first-rule-of-programming-its-always-your-fault.html

Share this post


Link to post
Share on other sites

I know we've had this before but I really cant see the point of a forum that tells you to go somewhere else. Its like a supermarket that tells you to go to a farm.

 

I have got the code working seperately so I have done some work and learnt how to do that.

 

Where can I specifically learn how to solve this problem?

Share this post


Link to post
Share on other sites

You're walking in to a supermarket with 20 pounds of random manure and asking them to exchange it for a whole, live cow.

Share this post


Link to post
Share on other sites

You're walking in to a supermarket with 20 pounds of random manure and asking them to exchange it for a whole, live cow.

 

Hahaha thats very funny.

 

I see as a long line of hurdles. Some I can jump over myself some I need a hand with. Can I have a hand with this hurdle please?

Share this post


Link to post
Share on other sites

No. Because you don't learn that way. As evidenced time and time again. The problem you are having is BASIC syntax. You don't even know how to do string concatenation and you think it will be easy for you to make a secure login system.

Share this post


Link to post
Share on other sites

No. Because you don't learn that way. As evidenced time and time again. The problem you are having is BASIC syntax. You don't even know how to do string concatenation and you think it will be easy for you to make a secure login system.

 

PLEASE CAN YOU ANSWER HOW TO FIX THIS PROBLEM. TO SAY I HAVEN'T LEARN ANYTHING IS QUITE UNFAIR.

Share this post


Link to post
Share on other sites

×
×
  • 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.