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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:32:52+00:00 2026-06-14T02:32:52+00:00

I have a application which you can view here . When you open the

  • 0

I have a application which you can view here. When you open the app, you will see a submit button, simply click on the button and you will see that it will generate string underneath. If you keep clicking on the button it keeps generating 2 letter strings between letters “A” and “B”.

If in the database under the “SessionId” column, I have in a row string “AB”. Then it would not generate string “AB” when I keep clicking on the submit button. I have tested this and this works fine. So this is not an issue if the string contains no number at the end.

The problem I have is this. If I want to create multiple exams. Lets say the string is “AA” and that I have 3 exams, it does not insert string “AA” in the database as there are multiple “AA”, so instead it concatenate a number after each “AA” in the database so that it displays it as “AA1”, “AA2” and “AA3”.

But the problem is that if it does this then when you use the app again and keep clicking on the “Submit” button, you see that it still generates string “AA” when it shouldn’t do as string “AA” was used in the database as “AA1”, “AA2” and “AA3”. I have these three values in the database at the moment yet it still generates the string in the application.

So my question is that how can I stop it from generating the string in the application if the string is in the database with a number concatenated at the end of it?

Below is the code for the application:

<?php

 // connect to the database
 include('connect.php');

  /* check connection */
  if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    die();
  }


function id_generator(){ 

          $id = ""; 
          $a = array( "A" , "B", "C" ); 

      for( $i = 0 ; $i < 2 ; $i++ ){ $r = rand( 0 , 1 );
       $id .= $a[ $r ]; 

   }

   return $id;

   };

   $is_there = true;

      while( $is_there ){
    $id = id_generator(); // your function to generate id;
    $result = "SELECT SessionId FROM Session WHERE SessionId LIKE CONCAT(?, '%')";

    $stmt=$mysqli->prepare($result);
    // You only need to call bind_param once
    $stmt->bind_param("1",$id);
    // execute query
    $stmt->execute(); 
    // get result and assign variables (prefix with db)
    $stmt->bind_result($dbSessionId);

    $stmt->store_result();

    $stmtnum = $stmt->num_rows();

    if($stmtnum == 0) {
    $is_there = false;
}
}

 ?>

    <h1>CREATING A NEW ASSESSMENT</h1>

        <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
        <p>
        <input id="courseSubmit" type="submit" value="Submit" name="submit" />
        </p>
        </form>

        <?php
if (isset($_POST['submit'])) {

        ?>




        <br/>

         <form action="QandATable.php" method="post" id="sessionForm">
         <p><strong>1: Your Assessment ID: </strong><span id="idFont"><?php echo $id; ?></span></p>
         <input type='hidden' name='id' value='<?php echo $id; ?>' />


        </form>



        <?php

        }
        ?>

    </body>
</html>
  • 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-06-14T02:32:53+00:00Added an answer on June 14, 2026 at 2:32 am
    // You only need to call bind_param once
    $stmt->bind_param("1",$id);
    

    Change this to:

    // You only need to call bind_param once
    $stmt->bind_param("s",$id);
    

    The first argument of the bind_param function tells the parser what type of parameter it is (ie. string, int etc): http://php.net/manual/en/mysqli-stmt.bind-param.php

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

Sidebar

Related Questions

I have a console application which can also open winform under certain conditions.Processing(its a
I have two async classes in my application which you can see below class
I just want to know that can i make an application which have some
In my application I have an edit profile page which you can see below;
i have an Android open source application published here https://github.com/evilsocket/dsploit ... as you can
I have an application which you can view by clicking on this link application
I have an application which requires authentication, but has some related services which can
We have a delphi application which can also run as a sevice . We
I have a socket application which I can use in local network, at home.
I have an application in which you can accept friend request. For this purpose

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.