my sql insert query not working
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)开发者_StackOverflow中文版or die(mysql_error());
echo "Done";
}
Output : pi203713 Done
But is database it is inserting "0"???
And what datatype is the userid column in ruser?
Have you verified that your variable's value is not zero?
Perhaps there's an assignment mistake further up your code?
Try this:
$sql = "INSERT INTO `pnpdb`.`ruser` (`userid`) VALUES ('".$userIDToCheck."');";
精彩评论