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

  • Home
  • SEARCH
  • 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 1103709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:22:45+00:00 2026-05-17T01:22:45+00:00

as the title specifies, my hosting provider does not have support for json_decode, so

  • 0

as the title specifies, my hosting provider does not have support for json_decode, so I need to find a way to adapt my code to achieve the same effect, but without using JSON, here is my code,

jQuery:

    var allLocations = [];

    $(".locations").each( function(i, location) {
        // for each location block
        location = $(location);
        var loc = {
            'province' : $("select[data-loc*='province']", location).val(),
            'town' : $("select[data-loc*='town']", location).val()
        };
        allLocations.push( loc );
    });

        //POST the locations information
        $.ajax({
                type: 'POST',
                url: 'locations.php',
                dataType: 'json',
                data: { locations: JSON.stringify(allLocations), uid: uid },
                success: function(data){
                    //alert(data)
                }
        });

PHP:

$json = $_POST['locations']; 
$uid = $_POST['uid']; // $json is a string
$json_array = json_decode($json, true); 

mysql_connect('localhost','user','pass') or die(mysql_error());
mysql_select_db('eskom_products') or die(mysql_error());

//insert the locations into the database
while($json_array as $key){
    $query = mysql_query("INSERT INTO suppliersLocations (supplier_id, province, town) VALUES('".$uid."', '".$key['province']."', '".$key['town']."' ) ") or die(mysql_error());
}

echo $text;

So as you can see, I am getting the province and town values of each location and creating a JSON object with it, which I then send off via $.ajax to a PHP file, but now since json_decode doesn’t work, I need to try and find another way of fixing the problem, I was thinking of trying to pass an associative array to the php file, but I wanted to see what your guy’s input would be, and if there might be a better way of achieving the desired result.

Thanx in advance!

  • 1 1 Answer
  • 1 View
  • 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-17T01:22:45+00:00Added an answer on May 17, 2026 at 1:22 am

    Seems that it was an obscure setting in the php config file that was messing with json_decode, once I disabled it, everything worked fine, Thanx for all of your help guys! I will edit this answer asap to describe how I got it working.

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

Sidebar

Related Questions

The title is a bit blur here, I didn't find a way to say
I have the following JavaScript code: function createNotification(title, body, canDismiss, callback) { //create the
I am getting the error specified in the question title for the following code
Sorry if the title is not that specific, but I don't know how else
Here is ALL my code for this specific view controller. As the title of
Title pretty much describes it, I just need to get all the order numbers
I have specified userdata in JSON response. Depending on the value of the title
I have a nant build script that specifies the compilation of various Visual Studio
Someone please recommend a better title for this question. I'm not sure what to
I have a table which each td has title, id, and lang attributes. I

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.