Below is my code in a single PHP file named testOne.php
<html>
<head>
<script type="text/javascript">
function testAlert(firstValue, secondValue)
{
alert ("Passed: "+firstValue+secondValue);
}
</script>
</head>
<body>
....
</body>
</html>
<?php
function testPassedValues($One, $Two)
{
echo "<input type = \"button\" onclick = \"testAlert($One[2], $Two[2])\">Click Here!</input>";
}
$link = mysql_connect("localhost", "root", "");
if (mysql_select_db("myDatabase", $link))
{
$result = mysql_query("SELECT * FROM MYTABLE");
while($currRowOne = mysql_fetch_row($result) &&
$currRowTwo = mysql_fetch_row($result))
{
testPassedValues($currRowOne, $currRowTwo);
}
}
?>
To help in understanding, I am calling a javascript method testAlert()
from the PHP function testPassedValues()
. However, I am not sure what the issue is since the call is not successful. In Mozilla(Firebug), I don't find any issues and in Chrome->Developer Tools, I get the error Uncaught Syntaxerror: Unexpected token ILLEGAL
in the console.
Can anyone please help me as to the root cause here?