PDA

View Full Version : one simple line


Lionel
04-01-2005, 05:52 AM
in register php,right after:


$DB_site->query("INSERT INTO " . TABLE_PREFIX . "userfield $userfieldsnames VALUES ($userid$userfields)");


I'd like to add
$DB_site->query("UPDATE userfield SET field10 = SUBSTRING(MD5(userid) FROM 10 FOR 5)");



but just for the user who is registering. That code does it for every body.

can someone please just tell me that WHERE statement for the new userid?

$DB_site->query("UPDATE userfield SET field10 = SUBSTRING(MD5(userid) FROM 10 FOR 5) WHERE ????");

Simple, but I haven't slept for two days, can't figure it out and I don't want a trial and error on a live board where I get people registering constantly.

Thank you.

cinq
04-01-2005, 05:57 AM
I dun have access to see how the userfield table looks like now, but I believe you can obtain the userid of the person who is only just registering by using :


$newuser = $DB_site->insert_id();

Lionel
04-01-2005, 06:06 AM
I am looking for the where statement UPDATE userfield SET field10 = SUBSTRING(MD5(userid) FROM 10 FOR 5) WHERE insert_id()");

So it would be like that?

Marco van Herwaarden
04-01-2005, 06:10 AM
WHERE userid = $useridtry that one, but best would be to add the field10 to $userfieldnames and $userfields before the original query, so it would already get updated there. No need for an extra query then.

PS You should never experiment with coding on a live board.

Lionel
04-01-2005, 06:13 AM
Thanks Marco. I got burnt a couple times with experiments. Thank God for backups.

That did not insert anything.

Duh, that's exactly what I meant. I was sleeping. That was field15 instead of field10. Field10 is for the weather. I got it set default to Miami. I registered and the weather displayed for Chad Nigeria. hahaha

cinq
04-01-2005, 12:42 PM
Sorry just reread your query.
I think you should be doing this, like Marco mentioned.

UPDATE userfield SET field10 = SUBSTRING(MD5(userid) FROM 10 FOR 5) WHERE userid = $userid