Jump to content


Photo

updating database


  • Please log in to reply
4 replies to this topic

#1 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 03 March 2003 - 02:00 AM

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]
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#2 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 03 March 2003 - 02:30 AM

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.

#3 NL_Johan_UK

NL_Johan_UK
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 03 March 2003 - 02:50 PM

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

#4 DarthViper3k

DarthViper3k
  • Members
  • PipPipPip
  • Advanced Member
  • 50 posts

Posted 03 March 2003 - 09:58 PM

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
[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]
switch($php) {
    case = \"given\" : {
       $website = 1;
       break;
    }     case = \"taught\" : {        $website = lifetime;        break;     } } [/span][!--PHP-Foot--][/div][!--PHP-EFoot--] The lazy never learn. The lazy are the downfall of many great things. Take the time to learn.

#5 metalblend

metalblend
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationCalifornia, USA

Posted 03 March 2003 - 11:05 PM

;) glad it worked




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users