inserting some not all values into a row of a database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Akwebby
Forum Newbie
Posts: 15
Joined: Wed Sep 17, 2003 5:47 pm

inserting some not all values into a row of a database

Post by Akwebby »

I would like to insert 4 values into a database row that has 10+ fields. How might I go about doing this?

Currently I am trying...

"INSERT INTO $user_tablename2 (idnumber, userid, memberpassword, swgname) VALUES(NULL, $user_id, password($user_password), '$swg_name')"

as the query string but i get an sql error message saying that the userid entered in the form is not a recognized field.

Anyone?
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Code: Select all

"INSERT INTO $user_tablename2 (idnumber, userid, memberpassword, swgname) VALUES('', '$user_id', password('$user_password'), '$swg_name')"
Changed NULL to ''
added some single quotes around $variables

Does that work?
Akwebby
Forum Newbie
Posts: 15
Joined: Wed Sep 17, 2003 5:47 pm

Post by Akwebby »

alright now it is kind of working, like the userid and the swgname are set to the correct values but the password is either not passed at all or not set, but it doesn't seem to be in the database at all, and thus my log in pages aren't working and this starts a domino effect, so any ideas on how to get the password to stay?
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post by igoy »

before the query... create a new variable and get the value of $user_password in there.

Code: Select all

<?
$upass = $_GET['user_password'];
$myQuery = "INSERT INTO $user_tablename2 (idnumber, userid, memberpassword, swgname) VALUES('', '$user_id', password('$upass'), '$swg_name')" 
?>
technically I doesn't make sense since the senario is not changes much.... but I had faced smilar problem once and this is how it was solved.. I couldn't understand why, thus couldn't explain why yuo should do it... but try as you might.
Akwebby
Forum Newbie
Posts: 15
Joined: Wed Sep 17, 2003 5:47 pm

Post by Akwebby »

the _GET is not working correctly, it doesn't put anything into the $upass variable
Akwebby
Forum Newbie
Posts: 15
Joined: Wed Sep 17, 2003 5:47 pm

Post by Akwebby »

Alright I am not seeing any change whatsoever. I can get values into every other field in the table, but not the password one, even when I go straight in without the password function it doesn't hold. Any suggestions?
Akwebby
Forum Newbie
Posts: 15
Joined: Wed Sep 17, 2003 5:47 pm

Post by Akwebby »

Alright i fnially got the password to stick in the table by changing the table definition. Now on my log in page I can't get it to say that the specified pass is correct for the given userid. Any help?
Post Reply