|
-
Apr 1st, 2004, 07:52 PM
#1
Thread Starter
Frenzied Member
Help!!
What is the problem with this script?
PHP Code:
<?php
mysql_connect (localhost, user, password);
mysql_select_db (nz);
$qry = mysql_query("SELECT user_name FROM DB_Wsers WHERE user_name='$user_name' LIMIT 1")
if ($_POST['action'] == 'save') {
if($_POST['user_password'] == $_POST ['user_password_confirm']){
$result = mysql_query ("INSERT INTO DB_Users Values ('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
}else{
echo "Sorry";
}
$arr = mysql_fetch_array($qry);
if($arr[0] == ""){
$result = mysql_query ("INSERT INTO DB_Users Values ('','$user_name','$user_email','$user_password','$user_pending_flag','$user_suspended_flag','$user_moderator_flag','$user_admin_flag','$register_code','$user_real_name','$location','$age','$sex','$season_tkt_no')");
}else{
echo "That username is already in use.\n";
}
} else {
?>
Crap
<?php
}
?>
-
Apr 1st, 2004, 08:51 PM
#2
uh.. if you're posting scripts, don't just ask 'what is wrong with this?'.. give a description of what you want, what you're getting instead, including any parse errors.
-
Apr 1st, 2004, 08:57 PM
#3
nevermind, you're missing a semi-colon on your mysql_query() call in this script too..
add a semi-colon to the end of line 4 after the bracket.
line 4 is this line:
PHP Code:
$qry = mysql_query("SELECT user_name FROM DB_Wsers WHERE user_name='$user_name' LIMIT 1")
change it to:
PHP Code:
$qry = mysql_query("SELECT user_name FROM DB_Wsers WHERE user_name='$user_name' LIMIT 1");
-
Apr 1st, 2004, 09:55 PM
#4
Thread Starter
Frenzied Member
Ok, if both are fine it add the record twice why?
-
Apr 1st, 2004, 11:40 PM
#5
uhh.. really, you should look into actually learning PHP a bit more..
you've got two queries that insert information into the database at two different points.. you only want one instance where you are inserting data, not two.
your script should be structured something like this, fill in the blanks:
PHP Code:
<?
if($action == "save"){
if($password1 == $password2){
if($user[0] == ""){
//insert user information to database
}else{
echo "user already exists";
}
}else{
echo "passwords don't match";
}
}else{
echo "action is not to save";
}
?>
-
Apr 2nd, 2004, 12:11 AM
#6
Thread Starter
Frenzied Member
Originally posted by kows
uhh.. really, you should look into actually learning PHP a bit more..
you've got two queries that insert information into the database at two different points.. you only want one instance where you are inserting data, not two.
your script should be structured something like this, fill in the blanks:
PHP Code:
<?
if($action == "save"){
if($password1 == $password2){
if($user[0] == ""){
//insert user information to database
}else{
echo "user already exists";
}
}else{
echo "passwords don't match";
}
}else{
echo "action is not to save";
}
?>
I don't use it enough to worry about learning a lot about it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|