This topic is locked

need help with update After Successful Registration

4/25/2007 4:33:03 AM
PHPRunner General questions
D
datapimp author

Hi just want to know if someone can point me in the right direction
After a customer registers a new account I want to update there information but im running into a error :
Unknown column 'test9' in 'where clause'
Test9 is an example username. Here is the code I'm using. Also as a new can someone tell me how I can improve my update string .. as I can only update 1 thing at a time ...
thanks
[codebox]function :unsure:AfterSuccessfulRegistration ()

{

global $conn,$strUsername,$values;
$caccstat=now();

$newabin = mysql_insert_id($conn);

$cnabin = "cus00".$newabin;
// generate 6 letters length activation code

$actcode="";

for($i=0;$i<6;$i++)

{

$j=rand(0,35);

if($j<26)

$actcode.=chr(ord('a')+$j);

else

$actcode.=chr(ord('0')-26+$j);

}
$strUpdate33 = "update _cdws set accstat='$caccstat' where uname=".$strUsername;

$strUpdate34 = "update _cdws set abin='$cnabin' where uname=".$strUsername;

$strUpdate35 = "update _cdws set usertype='n2ba' where uname=".$strUsername;

$strUpdate36 = "update _cdws set data_id='$actcode' where uname=".$strUsername;
db_exec($strUpdate33,$conn);

db_exec($strUpdate34,$conn);

db_exec($strUpdate35,$conn);

db_exec($strUpdate36,$conn);

}

[/codebox]

kujox 4/25/2007

[codebox]function :unsure:AfterSuccessfulRegistration ()

{

global $conn,$strUsername,$values;
$caccstat=now();

$newabin = mysql_insert_id($conn);

$cnabin = "cus00".$newabin;
// generate 6 letters length activation code

$actcode="";

for($i=0;$i<6;$i++)

{

$j=rand(0,35);

if($j<26)

$actcode.=chr(ord('a')+$j);

else

$actcode.=chr(ord('0')-26+$j);

}
$strUpdate33 = "update _cdws set accstat='$caccstat' where uname=".$strUsername;

$strUpdate34 = "update _cdws set abin='$cnabin' where uname=".$strUsername;

$strUpdate35 = "update _cdws set usertype='n2ba' where uname=".$strUsername;

$strUpdate36 = "update _cdws set data_id='$actcode' where uname=".$strUsername;
db_exec($strUpdate33,$conn);

db_exec($strUpdate34,$conn);

db_exec($strUpdate35,$conn);

db_exec($strUpdate36,$conn);

}

[/codebox]
try this..
$strUpdate = "update _cdws set accstat='$caccstat',abin='$cnabin',data_id='$actcode',usertype='n2ba', where uname=".$strUsername;

D
datapimp author 4/25/2007

try that mate but no good ..... got this error
description: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where uname=testuser' at line 1
looks like to me the user has not been added to the table ... but im not sure

Alexey admin 4/25/2007

Hi,
character values must be enclosed in quotes.

I.e.

... where uname='".$strUsername."'";

D
datapimp author 4/25/2007

Thank you <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=17285&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' /> as always you guys r a great help
just one more small request is there anyway u can make all this into just one string.. i've tryed soo many times but my syntax smells like noob <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=17285&image=2&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
$strUpdate33 = "update _cdws set accstat='$caccstat' where uname='".$strUsername."'";

$strUpdate34 = "update _cdws set abin='$cnabin' where uname='".$strUsername."'";

$strUpdate35 = "update _cdws set usertype='n2ba' where uname='".$strUsername."'";

$strUpdate36 = "update _cdws set data_id='$actcode' where uname='".$strUsername."'";
db_exec($strUpdate33,$conn);

db_exec($strUpdate34,$conn);

db_exec($strUpdate35,$conn);

db_exec($strUpdate36,$conn);

kujox 4/25/2007

$strUpdate = "update _cdws set accstat='".$caccstat."',abin='".$cnabin."',usertype='n2ba',data_id='".$actcode."' where uname='".$strUsername."'";

db_exec($strUpdate,$conn);
try this, I think i checked all the quotes