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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:04:24+00:00 2026-06-02T11:04:24+00:00

Updated Problem: print_r($_POST); in the php file outputs after I type something in the

  • 0

Updated Problem: print_r($_POST); in the php file outputs after I type something in the box.

Array
(
    [q] => running
)

print json_encode($jsonArray); however is printing []

The php which queries Interest table for the bound parameter

    $interestValue = $_POST['interestVal']; //////
    $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
    $sth = $dbh->prepare(
'SELECT interestID, interestVal FROM Interest WHERE interestVal = ?');
    $sth->bindParam(1, $interestValue);
    $sth->execute();
    $jsonArray = array();
    while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
     $jsonArray[] = array(
      'ID' => $result['interestID'], 
          'Value' => $result['interestVal']); 
    }

    print_r($_POST);

    print json_encode($jsonArray); // json encode that array 

HTML

<input id="interest" name="interest" value="What are your interests?" />

JS

//Get interests
        $(document).ready(function() {
            $("input#interest").tokenInput("../../src/php/registration/interest/getInterest.php");
        });

The JS of the framework(http://loopj.com/jquery-tokeninput/)

(function ($) {
// Default settings
var DEFAULT_SETTINGS = {
    // Search settings
    method: "POST",
    contentType: "json",
    queryParam: "interestVal",
    searchDelay: 300,
    minChars: 1,
    propertyToSearch: "name",
    jsonContainer: null,

    // Display settings
    hintText: "Type in a search term",
    noResultsText: "No results",
    searchingText: "Searching...",
    deleteText: "&times;",
    animateDropdown: true,

    // Tokenization settings
    tokenLimit: null,
    tokenDelimiter: ",",
    preventDuplicates: false,

    // Output settings
    tokenValue: "name", // orig "id"
}

Why is this array empty??

  • 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-02T11:04:28+00:00Added an answer on June 2, 2026 at 11:04 am

    Don’t use mysql_real_escape_string with prepared statements – binding parameters takes the user data out of the SQL code, so there are no SQL injection vulnerabilities. More importantly, mysql_real_escape_string only works AFTER you connect to the DB, not before, which is turning your value into false.

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

Sidebar

Related Questions

I have the following code. PHP side: <?php print_r($_POST); print_r($_GET); die(); ?> In JavaScript:
I have into $_POST array all the data i need. If I print_r the
Updated Problem solved, I have some design problem here. The directory looks like that:
[Updated, sorry about the change but now to the real problem] I cannot include
I have a big big problem. Yesterday I updated the Android SDK and, since
I have a problem. When I updated Android SDK tool to version 17 and
I have a website that is updated regularly and I am having a problem
Recently I updated my computer to Ubuntu 11.10 64-bits. I have a problem when
[Update]: my initial example doesn't reflect my problem. Updated the sample, hopfully it is
I've recently updated 1 logging component to log Exception.ToString rather than Exception.Message.ToString(), the problem

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.