More login problems


#1

heres the deal, i got this script to add a user to the database (i have other scripts to login n stuff) but the problem is it deletes the original recold and writes over it, being a complete plonker i can’t fix it please help!!!

<?php include("connect2db.php"); $qselect = "Select * from members where id = '1'"; $qadd = " INSERT INTO members (id, password, username) VALUES ('1', 'test', 'test') "; $qupdate = " UPDATE members SET password = '$password', username = '$username' WHERE id = '1'"; $result = mysql_query($qselect); // check the single record exists if (mysql_num_rows($result)) $result = mysql_query($qupdate); // add record else $result = mysql_query($qadd); // if not add an initial record if ($result) mysql_close(); else { echo "ERROR - unable to save new username and password!
"; $SQLError = "SQL ERROR: ".mysql_errno().". ".mysql_error()."

"; echo "$SQLError"; mysql_close(); } include("addauser.php"); ?>

Any idea’s?


#2

Your trying to update a table without a database… You need to add 3 extra characters to your line…


#3

I’d assume include(“connect2db.php”); has that info


#4

$qselect = "Select * from members where id = '1'"; $qadd = " INSERT INTO members (id, password, username) VALUES ('1', 'test', 'test') "; $qupdate = " UPDATE members SET password = '$password', username = '$username' WHERE id = '1'";

If your trying to add a member to a database, then why are you writing over the existing member with id of “1” ?

If you have set ID to auto_increment you don’t have to define it in the values for “members”.