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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:07:36+00:00 2026-05-27T15:07:36+00:00

I am dynamically creating variable to check the check boxes using loop. Actually the

  • 0

I am dynamically creating variable to check the check boxes using loop. Actually the I am creating variable using string that is combination of 1 & 0. viz..1010101000110. Its like this. My string length is 50.

$user_authorisation = fetch_table_user($uid, '1', '12');
for ($j = 0; $j <= 49; $j++) {
    if (substr($user_authorisation, $j, 1) == '1') {
        $user_authorisation_field_ . $j = 'checked="checked"';
    }
}

My error is:
Warning: substr() expects parameter 2 to be long, string given in C:\xampp\htdocs\shadaab\user_auth.php on line 38

  • 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-27T15:07:37+00:00Added an answer on May 27, 2026 at 3:07 pm

    They’re right, the best solution is to simply use an array:

        for ($j = 0; $j <= 49; $j++)
            if (substr($user_authorisation, $j, 1) == '1')
                $user_authorisation_field[$j] = 'checked="checked"';
    

    But, specifically your problem lies in how you concatinate your variable: $user_authorisation_field_ . $j

    @Dong shows how to do it correctly in his answer.

    The reason the concatination is incorrect is because you want to treat "user_authorisation_field_" as a string and combine it with a number, but you are unintentially using it as a variable $user_authorisation_field_ which is UNDEFINED. So what you’re doing is basically evaluates as:

    UNDEFINED . 0 = 'string';
    UNDEFINED . 1 = 'string';
    UNDEFINED . 2 = 'string';
    

    etc. Doesn’t work.

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

Sidebar

Related Questions

Using DTS I'm dynamically creating an access database. After the file is created (which
i am dynamically creating radio using jquery as shown belown. but they value only
I have an ASPX page that is dynamically creating a gridview from a database
I just found out that in FF, if you are dynamically creating an OPTION
I am creating a few pictureboxes dynamically, then assigning the following: // class variable
I am creating an app that needs to know the current status of dynamically
I am trying to create a class that holds a dynamically created variable. My
I´m dynamically creating an instance of a class with reflection and this works fine,
I am dynamically creating a table which I want to have clickable rows. When
i am dynamically creating sql query for inserting multiple records in one hit.Suppose no

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.