Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4246044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:55:15+00:00 2026-05-21T03:55:15+00:00

Below is my code in a single PHP file named testOne.php <html> <head> <script

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:55:16+00:00Added an answer on May 21, 2026 at 3:55 am

    Most likely the values of $One[2] and $Two[2] are strings, so the generated HTML is:

    <input type = "button" onclick = "testAlert(string one, string two)">Click Here!</input>
    

    Which is obviously invalid javascript.

    Enclose the parameters in quotes:

    echo "<input type = \"button\" onclick = \"testAlert('$One[2]', '$Two[2]')\">Click Here!</input>";
    

    You should also correctly escape the of $One[2] and $Two[2] values for HTML and JavaScript, so that you don’t introduce XSS flaws or errors when a string contains an apostraphe. I’ll leave that up to you to figure out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Network protocol parser code, parse below layers in single thread. After parsing some procotol
Below code makes form to be submitted without html5 validation... $j(document).on(click, #client_entry_add, function(event){ ajax_submit();});
The below code doesn't it print the value. function go(x) { alert(x.options.selectedIndex.value); //location=document.menu.student.options[document.menu.student.selectedIndex].value }
I want to use two independent $_SESSIONs in a single PHP script. I have
How can I turn the code below into a single array when its in
Okay right now I have too include the code below on every single page
i have the below code and find that the text value represented in Server.GetLastError
I am trying to create a single php file I can use to display
Got a bunch of letter buttons in code below: Code: <?php $a = range(A,Z);
I have a PHP installation running 5.3.3 and when I use the code below:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.