I have the following string which i need to convert to integer or bigint.
$test=\"99999977706\";
I tried:
echo (int)$test;
MySQL isn't going to know the difference. Just feed the string into your query as though it is a number without first type casting it in PHP.
For example:
$SQL = "SELECT * FROM table WHERE id = $test";