null values being inserted into database

I have a REST API that should save the contents of a json into a mysql database however it’s inserting everything as null? However its weird because whenever the json is sent from the swift sdk it works just fine.

 public function saveTracking($request, $response, $args) {
        if(!$this->validToken($response)) {
            return $response;
        }
        $data = $request->getParsedBody();
        $tracking_data = json_decode(json_encode($data['tracking']), FALSE);
        $total_records = 0;
          //error_log(print_r($tracking_data, true));

        foreach($tracking_data as $key => $value) {
            $tracking = new EstablishmentTracking();
            $tracking->mobile_user_id = $this->authUser->id;
            $tracking->report_date = $value->report_date;
            $tracking->establishment_id = $value->establishment_id;
            if ($value->platform == MobileUser::ANDROID || $value->platform == MobileUser::IOS) {
                $tracking->platform = $value->platform;
            }
            $tracking->purchase_id = $value->purchase_id;

            error_log(print_r($tracking, true));
            $this->establishmentService->saveEstablishmentTracking($tracking);
            $total_records++;
        }
        $arr = array("status" => "ok"
                    ,"total_records" => $total_records
                    );
        print_r($arr);
        $newResponse = $response->withJson($arr);
        return $newResponse;
    }

After adding a line that prints the contesnts of the variable, i got the following:

stdClass Object
(
    [establishment_id] => 39
    [report_date] => 2018-05-31 18:45:05
    [platform] => android
    [purchase_id] => 0

Is it not sending the json correctly as an array? or what seems to be the issue.

Advertisements

Converting smart quotes in Wordpress content

I parse post content in WordPress

Some content {field:"value"} some other content.

…and whenever I find a JSON-object like string like this, I try to decode and run some other function with the value.

Problem is WordPress saves user input {field:”value”} as {field:&#8220value&#8221}

I know that I can simply convert content with a function like this…

$content = str_replace(
        array('“','”'), array('"', '"'), $content
    );

I also know that I can extent this code by replacing chr(147), chr(148) and strtr “\xC2\xAB” and “\xC2\xBB”

…but I’m still not sure if it’s still a universal solution for all browsers, operating systems or keyboards.

Should I simply leave this idea of parsing JSONs this way?

Error when Running Codecept

I am trying to run a test and when I use the codecept command I get this error. Does anyone know how to resolve this issue?

Error: Internal script failure

codecept run tests/acceptance/RequestCept.php --steps
==== Redirecting to Composer-installed version in vendor/codeception 
====
<br />
<b>Error</b>: <font color="FF0000"><b>Internal script failure</b><br />

Wordpress blog’s featured image showing on other pages

I adopted a site to help revise from the web company that created it and I’ve been having issues getting the featured image for the posts page to show up. I added code to the index file due to the site not having a front-page.php. It works (link here), but I see it appear on some of the about pages (link here). I’m unsure if the code I’m using is incorrect or in the wrong place.

Code of the header output

<?php  $page_id = get_query_var('1056');

    if (has_post_thumbnail( 1056 ) ) : 
     $image = wp_get_attachment_image_src( get_post_thumbnail_id( 1056 ), 'single-post-thumbnail' );?>

    

entire index page with my header code

<?php if ( have_posts() ) : ?>

    <?php if ( is_home() && ! is_front_page() ) : ?>

    <?php endif; ?>

    <?php  $page_id = get_query_var('1056');

    if (has_post_thumbnail( 1056 ) ) : 
     $image = wp_get_attachment_image_src( get_post_thumbnail_id( 1056 ), 'single-post-thumbnail' );?>

    
    <?php

    // Start the loop.

    while ( have_posts() ) : the_post();

        get_template_part( 'content', get_post_format() );

    endwhile;



    // Previous/next page navigation.

    the_posts_pagination( array(

        'prev_text'          => __( 'Previous page', 'twentysixteen' ),

        'next_text'          => __( 'Next page', 'twentysixteen' ),

        'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',

    ) );



// If no content, include the "No posts found" template.

else :

    get_template_part( 'content', 'none' );

endif;

?>

How to passing data to model in Codeigniter?

I need to pass data to a model. that model is form to edit data.
I have make array data in the controller for passing the data to models, but im still confusing to passing data to the models in codeigniter.

this is my controller :

public function edit($id_ekspor){
    $eks = $this->m_ekspor->GetDataEkspor("where id_ekspor = '$id_ekspor'");
    $data = array(
        "id_ekspor" => $eks[0]['id_ekspor'],
        "e_berat" => $eks[0]['e_berat'],
        "e_nilai" => $eks[0]['e_nilai'],
        "tahun" => $eks[0]['tahun'],
        "id_industri" => $eks[0]['id_industri'],
        "nm_industri" => $eks[0]['nm_industri']
    );

}

this is my models :

How to passing that data array in controller to models ?

Table and buttons in html and php with bootstrap

In this code that have to print a table and 3 buttons, the 3 buttons appear above the table but i want them under the table. What can I fix?
And how can i print them inline? I tried with a div with style display inline but doesn’t work.

echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
Modifica Informazioni
</div>"; echo "
Aggiungi Esperienze
</div>"; echo "
Compagnie in cui i nostri iscritti lavorano
</div>";

I’m using bootstrap.

Back to top

Esperienze di Lavoro

Username Password Nome Cognome Data di Nascita Email Foto
".$_COOKIE["username"]."".$_COOKIE["password"]."".$_COOKIE["name"]."".$_COOKIE["surname"]."".$_COOKIE["birth"]."".$_COOKIE["mail"]."