You should have your conditional in this way;
if (sql === FALSE) {
echo '<script type="text/javascript"> myIdNo();</script>';
}
not as you have it;
if (sql) === FALSE) {
echo '<script type="text/javascript">
myIdNo();
</script>';
}
First of all, your if
has a redundant parenthesis just after the "variable" sql
and the chain of your echo
should be on 1 line.
Based on the fact that the previous example did not work, I mention something I did based on your problem, declare the function before the code exited, I'll give you an example:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
function myIdNo(){};
</script>
</head>
<body>
</body>
<?=
$sql = true;
if ($sql) {
echo '<script type="text/javascript"> myIdNo();</script>';
}
?>
</html>
In the end the error is because the variable has not been declared and this is why the console throws you the error you mention;