Jump to content

updating database


DarthViper3k

Recommended Posts

ok

 

I\'ve got this update profile page

 

all my books tell me I\'ve got this right

but I keep getting an error

 

Parse error: parse error in c:apachehtdocs3kphpprofile.php on line 16

 

well

heres line 17

 

?>

 

heres my code

 

please tell me what I\'m doin wrong

 

[php:1:0691e56a93]<?php

//check to see if Username, email, and password have values

if(empty($password) || empty($email))

{

if(empty($password))

{

print(\"Sorry, your password CANNOT be blank.. please try again<BR>\");

}

if(empty($email))

{

print(\"Sorry, your email CANNOT be blank.. please try again<BR>\");

//if its passed the check update their information

} else

{

mysql_query(\"UPDATE users SET password=\'$password\' WHERE username=\'$username\'\");

}

?>[/php:1:0691e56a93]

Link to comment
Share on other sites

you\'re going to kick yourself. if you tab your code you\'ll see you\'re missing a }

 

here\'s the \"repaired\" code:[php:1:252e080791]<?php

 

//check to see if Username, email, and password have values

if(empty($password) || empty($email)) {

if(empty($password)) {

print \"Sorry, your password CANNOT be blank.. please try again<BR>\";

}

if(empty($email)) {

print \"Sorry, your email CANNOT be blank.. please try again<BR>\";

//if its passed the check update their information

} else {

mysql_query(\"UPDATE users SET password=\'$password\' WHERE username=\'$username\'\");

}

}

 

?>[/php:1:252e080791]

 

ALWAYS TAB YOUR CODE ;)

 

Hope that helps.

Link to comment
Share on other sites

I code my php in PHP Coder, it has a great function called \'find matching brace\' . If goes all the way down your script, you know you forgot one.

 

When the error tells you it\'s the last line of your code, or the one before, it is always a missing brace, or you forgot ?> .

 

Just a tip...

 

One more thing, you might want to use

.... password = PASSWORD($password) WHERE... etc.

 

It encrypts the password. You don\'t want to know all your friends / clients passwords now do you?

 

When they log in, just match it like this:

 

SELECT COUNT(*) FROM user_table WHERE password = PASSWORD($password) AND user_name = \'$user_name\'

 

Good practise for privacy in your coding..

Link to comment
Share on other sites

you\'re going to kick yourself. if you tab your code you\'ll see you\'re missing a }

 

here\'s the \"repaired\" code:[php:1:5943dbd32d]<?php

 

//check to see if Username, email, and password have values

if(empty($password) || empty($email)) {

if(empty($password)) {

print \"Sorry, your password CANNOT be blank.. please try again<BR>\";

}

if(empty($email)) {

print \"Sorry, your email CANNOT be blank.. please try again<BR>\";

//if its passed the check update their information

} else {

mysql_query(\"UPDATE users SET password=\'$password\' WHERE username=\'$username\'\");

}

}

 

?>[/php:1:5943dbd32d]

 

ALWAYS TAB YOUR CODE ;)

 

Hope that helps.

 

 

ohhh

shit

I hate that

 

I do tab my code

I just tab it differently than most

:?

I\'m just gonna tab it a lil differently than I normaly do so I don\'t miss that

heh

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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