Jump to content

Archived

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

justlukeyou

Frustrating = Sign Insert

Recommended Posts

FIX YOUR STRING CONCATENATION.

 

You can't just throw single quotes, double quotes, and random text around and expect it to be interpereted.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

							 }
		 }

		 }

Share this post


Link to post
Share on other sites

According to the logic in your code, why do you think that error might be displayed?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

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.