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 6648773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:41:41+00:00 2026-05-26T00:41:41+00:00

Interesting. I have 2 links calling 2 JS functions – the first works ,

  • 0

Interesting. I have 2 links calling 2 JS functions – the first works , the second – doesn’t. It only calls function addns() when the argument is empty. Otherwise nope…

PHP:

 while ($row_mem = mysqli_fetch_array($mem)) { 
 $membs[] = $row_mem['username'];
 $membs_id[] = $row_mem['user_id'];

 }

 }  

 //FIRST FOREACH CALL PROPERLY
 foreach($membs_id as $val_id) {
 echo"<a href='javascript:addms($val_id)'><img src='$pcheck' width='66' height='68'
 border='1' class='currmem'/></a>&nbsp;";
 }


//THIS ONE DOESN'T 
foreach($membs as $mes_id) {
echo"<a href='javascript:addns($mes_id)'>$mes_id</a>&nbsp;";
}

JS:

 function addms(msid) { 
 var addm = msid;
 alert(addm);
 }

function addns(nsid) { 
var addn = nsid;

alert(addn);




}

I cannot see any error – thanks for comments !

  • 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-26T00:41:42+00:00Added an answer on May 26, 2026 at 12:41 am

    Update to match new answer:

    you need to put quotes around your variables. ($val_id) probably works because you’re retrieving an id which I’m guessing is an integer, so it’s a valid JavaScript literal.

    ($mes_id) probably doesn’t work because you’re getting strings back but not wrapped with quotes, so they aren’t valid JavaScript literals.

    so usernames will be joe and shmoe, javascript becoems
    addns(joe) and addns(shmoe), which is probably not what you want. You want addns("joe") and addns("shmoe").

    Also note once you fix this is an XSS vulnerability if users can choose their username.

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

Sidebar

Related Questions

I've got an interesting box-model problem here. I have a header full of links,
I have this interesting jQuery function. It basically adds a click handler to link,
I have a view controller and I am intercepting the touches on links within
I always have found the open source space interesting but have never actually participated
I have somewhat interesting development situation. The client and deployment server are inside a
I have an interesting problem and would appreciate your thoughts for the best solution.
I have an interesting situation where I need to deploy an ASP.NET MVC app
I have one interesting problem. I must parse mail body (regular expression), get some
I have an interesting query to do and am trying to find the best
I have an interesting question. Imagine I have a lot of data changing in

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.