tags:

views:

42

answers:

3

I am inserting userId.It is displaying correct but inserting 0 in spite of actual userId. mycode-

If(! empty($userIDToCheck) || $userIDToCheck != '' )
{
echo $userIDToCheck;  
$sql = "INSERT INTO `pnpdb`.`ruser` (`userid`) VALUES ('$userIDToCheck');";  
mysql_query($sql)or die(mysql_error());  
echo "Done";  
}

Output : pi203713 Done

But is database it is inserting "0"???

A: 

And what datatype is the userid column in ruser?

Mark Baker
@Mark Baker: This would have been a good comment, but it is not an answer...
Peter Lang
this is an answer because I made a datatype mismatch mistake.
nectar
A: 

Have you verified that your variable's value is not zero?

Perhaps there's an assignment mistake further up your code?

Andrew Heath
A: 

Try this:

$sql = "INSERT INTO `pnpdb`.`ruser` (`userid`) VALUES ('".$userIDToCheck."');";  
LucaB