Uncaught TypeError: Cannot set properties of undefined (setting ‘innerHTML’)

I am trying to create a web page using php that, on the elements of class “continut-text-box” (a defined by my class), on click has to launch a Javascript function that should change the contents of another element of id “harta-modal”, but this does not happen. I keep getting the same error and that is “Uncaught TypeError: Cannot set properties of undefined (setting ‘innerHTML’)”, even though the function is declared after the element that it is supposed to change, and the console log that I wrote in the function does not return null.
What did I do wrong?

<?php
    session_start();
    if (!isset($_SESSION['username']) && !isset($_SESSION['password'])){
        echo "<script>location.href='loginPage.html'</script>";
    }
?>
<!DOCTYPE html>
<html lang="en"> 
<head>
    <title>Crisis Containment Service</title>
    <link rel="icon" href="https://www.pinclipart.com/picdir/middle/344-3442781_tornado-icon-animated-natural-disaster-png-clipart.png">
    <link href="style1.css" rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <h1 id="titlu-pagina">Crisis Containment Service Web App</h1>
    
    <div id="slider">
        <figure>
            <img src="Images/wildfire.jpg">
            <img src="Images/furtuna.jpg">
            <img src="Images/hurricane.jpg">
            <img src="Images/landslide.jpg">
            <img src="Images/tornada.jpg">
            <img src="Images/vulcan.jpg">
            <img src="Images/inundatie.jpeg">
            <img src="Images/wildfire.jpg">
        </figure>
    </div>

    <div id="text-box">
        <?php
            $url = 'http://localhost/Proiect/API/getVerifiedEvents.php';

            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

            $headers = array("Accept: application/json",);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            $resp = curl_exec($curl);
            curl_close($curl);

            $json = json_decode($resp);

            $i = 0;

            while($i < sizeof($json)){
                //if (substr($json[$i]->name, 0, 5) == date("m-d")){
        ?>
            <div class="continut-text-box" id="open" onclick="makeMap(<?php echo $json[$i]->longitude?>, <?php echo $json[$i]->latitude?>)"><h2><?php echo $json[$i]->description;?></h2></div>
        <?php /*}*/$i = $i + 1;}?>
    </div>

    <div class="modal-container" id="modal-container">
        <div class="modal">
            <!--<h1>Hi!</h1>!-->
            <div id="harta-modal"><p>te rog functioneaza<!--to be generated by javascript!--></div>
        </div>
        <button id="close">X</button>
    </div>

    <iframe id="harta-europa" src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d47139330.24912588!2d-12.8611109417314!3d43.85258716626324!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x46ed8886cfadda85%3A0x72ef99e6b3fcf079!2sEurope!5e0!3m2!1sen!2sro!4v1649962131724!5m2!1sen!2sro" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
    
    <button id="buton-about" onclick="window.location.href='about.html';">About</button>
    <button id="buton1" onclick="myFunction1()">Log Out</button>
    <button id="buton2" onclick="myFunction2()">Report Event</button>

    <select id="type-event">
        <option selected>All</option>
        <option>Tornadoes</option>
        <option>Hurricanes</option>
        <option>Floods</option>
        <option>Wildfires</option>
        <option>Earthquakes</option>
        <option>Droughts</option>
        <option>Volcanic erruptions</option>
        <option>Tsunamis</option>
        <option>Landslides</option>
        <option>Sink holes</option>
      </select>

      <input type="datetime-local" name="datetime" id="datetime">
     
    <script src="myScript.js"></script>
    <script>
            function myFunction1() {
                location.href='sessionDestroy.php';
            }
            function myFunction2() {
                location.href='reportEventPage.php';
            }
            function makeMap(longitude, latitude){
                console.log(document.getElementById('harta-modal'));
                document.getElementById('harta-modal')[0].innerHTML = `${longitude} ${latitude}`;
            }
    </script>
</body>
</html>

How to create default value for OneToOne field using symfony

I currently have a user entity that contains multiple values as first_name and last_name for example.

I want to add a OneToOne relation user_informations to my user that will contains a bio field. (Note that I don’t want to add the bio field directly into the user entity )

I have created the entity using the command php bin/console make:entity userInformation

php bin/console make:entity UserInformation

 created: src/Entity/UserInformation.php
 created: src/Repository/UserInformationRepository.php

Then, i have created the OneToOne relation with the User entity


 New property name (press <return> to stop adding fields):
 > user

 Field type (enter ? to see all types) [string]:
 > relation

 What class should this entity be related to?:
 > User

 Relation type? [ManyToOne, OneToMany, ManyToMany, OneToOne]:
 > OneToOne
 Is the UserInformation.user property allowed to be null (nullable)? (yes/no) [yes]:
 > no

And finally, I added the bio field into the user_information


 Add another property? Enter the property name (or press <return> to stop adding fields):
 > bio

 Field type (enter ? to see all types) [string]:
 > 

 Field length [255]:
 > 

 Can this field be null in the database (nullable) (yes/no) [no]:
 > yes

 updated: src/Entity/UserInformation.php

The problem

the problem is that all my user currently have a null value for the user_information.

I would like to add an empty user_information for all my user but I have no idea about how to do this.

I know I could write some script to create a user_information for each user but there might be something else

How do I update column values to equal column values based on another column?

I have a sql table like this,

+-------+-------+-----+
| name  | start | end |
+-------+-------+-----+
| Joe   |    14 |   - |
| Joe   |    13 |   - |
| Steve |    11 |   - |
| Steve |    15 |   - |
| Bruce |    10 |   - |
+-------+-------+-----+

and i want to update the values for column “end” with the values from “start” for each unique column value “name”, so it looks like this.

+-------+-------+-----+
| name  | start | end |
+-------+-------+-----+
| Joe   |    14 |  14 |
| Joe   |    13 |  13 |
| Steve |    11 |  11 |
| Steve |    15 |  15 |
| Bruce |    10 |  10 |
+-------+-------+-----+

my question is: how do i do this in SQL code, and how would it look like with a PHP mysql query?

Enable dl in PHP 8.0

I’ve been trying to enable the PHP 8.0 dl function but I couldn’t succeed, as you see in the screenshot below

phpinfo

but when trying to load an extension

error message

I also know about

refsect1-function.dl changelog

So is there anyway to re-enable this function !

Bulk import of student scores

I have a web app that I had someone do a bit of customization on. It was to create bulk import of scores of students.
As at the time, the students only have exam scores (i.e just one column for scores).

std_id | scores
---------------

  101  |  80

However, the students now have a myriad of test scores and an exam scores.

std_id | ca1 | ca2 |ca3 | ca4 | exam
------------------------------------

  101  | 7   |  8  | 4  | 8   | 45

Well, I figured it should be easy enough to look through his code and see how I could work on it to allow for bulk import of the new tests columns.

However, I got stuck trying to figure how the value for marks is gotten.

Here is the original code:

Controller:

 public function uploadfile()
    {

        $this->form_validation->set_error_delimiters('', '');
        $this->form_validation->set_rules('file', $this->lang->line('image'), 'callback_handle_upload');
        if ($this->form_validation->run() == false) {
            $data = array(
                'file' => form_error('file'),
            );
            $array = array('status' => 0, 'error' => $data);
            echo json_encode($array);
        } else {
            $return_array = array();
//====================
            if (isset($_FILES["file"]) && !empty($_FILES['file']['name'])) {

                $fileName = $_FILES["file"]["tmp_name"];
                if (isset($_FILES["file"]) && !empty($_FILES['file']['name']) && $_FILES["file"]["size"] > 0) {

                    $file = fopen($fileName, "r");
                    $flag = true;
                    while (($column = fgetcsv($file, 10000, ",")) !== false) {
                        if ($flag) {
                            $flag = false;
                            continue;
                        }
                        if (trim($column['0']) != "" && trim($column['1']) != "" && trim($column['2']) != "") {
                            $return_array[] = json_encode(
                                array(
                                    'adm_no'     => $column['0'],
                                    'attendence' => $column['1'],
                                    'marks'      => number_format($column['2'], 2, '.', ''), <!-- Where is this gotten from?-->
                                    'note'       => $this->encoding_lib->toUTF8($column['3']),
                                )
                            );
                        }
                    }
                }

                $array = array('status' => '1', 'error' => '', 'student_marks' => $return_array);
                echo json_encode($array);
            }
            //=============
        }
    }

View

 <tbody>
                            <?php
                            if (empty($resultlist)) {
                                ?>
                                <tr>
                                    <td colspan="7" class="text-danger text-center"><?php echo $this->lang->line('no_record_found'); ?></td>
                                </tr>
                                <?php
                            } else {

                                foreach ($resultlist as $student) {
                                    ?>
                                    <tr class="std_adm_<?php echo $student['admission_no']; ?>">
                              <td><?php echo $student['admission_no']; ?></td>
                              <td style="white-space: nowrap;"><?php echo $student['firstname'] . " " . $student['lastname']; ?></td>
                                <td>
                               <div>
                                 <?php
                                        foreach ($attendence_exam as $attendence_key => $attendence_value) {
                                            $chk = ($student['exam_group_exam_result_attendance'] == $attendence_value) ? "checked='checked'" : "";
                                            ?>
                                            <label class="checkbox-inline"><input type="checkbox" class="attendance_chk" name="exam_group_student_attendance_<?php echo $student['exam_group_class_batch_exam_students_id']; ?>" value="<?php echo $attendence_value; ?>" <?php echo $chk; ?>><?php echo $this->lang->line($attendence_value); ?></label>
                                            <?php
                                        }
                                        ?>

                                    </div>
                                </td>
                                <td> <input type="number" class="marksssss form-control" name="exam_group_student_mark_<?php echo $student['exam_group_class_batch_exam_students_id']; ?>" value="<?php echo $student['exam_group_exam_result_get_marks']; ?>" step="any"></td>
                                <td> <input type="text" class="form-control note" name="exam_group_student_note_<?php echo $student['exam_group_class_batch_exam_students_id']; ?>" value="<?php echo $student['exam_group_exam_result_note']; ?>"></td>

                                </tr>
                                <?php
                            }
                        }
                        ?>
                        </tbody>

Script:

<script type="text/javascript">
    $(document).ready(function () {
        $(document).on('click', "#btnSubmit", function (event) {

            //stop submit the form, we will post it manually.
            event.preventDefault();
            var file_data = $('#my-file-selector').prop('files')[0];
            var form_data = new FormData();
            form_data.append('file', file_data);

            $.ajax({
                url: baseurl + "/admin/examgroup/uploadfile",
                type: 'POST',
                dataType: 'JSON',
                data: form_data,
               contentType: false,
cache: false,
processData:false,
 beforeSend: function () {

                    $('#examfade,#exammodal').css({'display': 'block'});
            },
                success: function (data) {
$('#fileUploadForm')[0].reset();
  if (data.status == "0") {
           var message = "";
          $.each(data.error, function (index, value) {
            message += value;
         });
           errorMsg(message);
       } else {
           var arr = [];
                    $.each(data.student_marks, function (index) {
                        var s = JSON.parse(data.student_marks[index]);
                        arr.push({
                            adm_no: s.adm_no,
                            attendence: s.attendence,
                            marks: s.marks,
                            note: s.note
                        });

                    });
//===============
                    $.each(arr, function (index, value) {
                         var row=$('.marksEntryForm').find('table tbody').find('tr.std_adm_' + value.adm_no);
                       row.find("td input.marksssss").val(value.marks);
                       row.find("td input.note").val(value.note);
                       if(value.attendence == 1){
                         row.find("td input.attendance_chk").prop( "checked", true );
                     }else{
                         row.find("td input.attendance_chk").prop( "checked", false);
                     }
                    });

//=================
       }
                },
            error: function (xhr) { // if error occured
                alert("Error occured.please try again");
                    $('#examfade,#exammodal').css({'display': 'none'});
            },
            complete: function () {
$('#fileUploadForm')[0].reset();
                    $('#examfade,#exammodal').css({'display': 'none'});
            }

            });
        });
    });
</script>

This is what the bulk import file looks like:

   A     |     B     |     C     | D
--------------------------------------
adm_no   |  status   |    marks  | note

Now, I want the file to be like this:

   A     |     B     |    C   |  D   |  E   |  F   |  G  |  H |
-----------------------------------------------------------------
adm_no   |  status   |   ca1  | ca2  |  ca3 | ca4  |exam | note

Select list not refreshing after add data on DB

I read somewhere that I can have only one header(“locagion. foo.php”) per page, my problem is:
I have a form on a left div, with a html that loads with the data from database, I also have another form on a right div that also load the same data, on left I select authors to add a new task, and on right is where I add new authors or delete authors by selecting them from a list, I am doing this because I need to do something similar on the job I just started, but when I add the new author, it loads exactly at the same time on the right div, but to load it on left div the page must be reloaded, and here is the problem, once I create the instruction header(“location: foo.php”) it returns that well known error of “Cannot modify header information – headers already sent by…”Left div – Task author is not loaded when I add a new one, only after refresh – right div delete author is loaded as soon as I include a new one

code at https://github.com/vsrromero/todolist

Sorting rows value based on if statement using SQL

I made a table where I want to list some data. My goal is to list only 1 row if there are multiple rows with the same value. Let’s say I have 2 rows in MySQL table with the string “asd”. I want to see a single row, even if there are multiple rows with the same value.

<table>
                        <thead>
                            <th>#</th>
                            <th>Expeditor</th>
                            <th>Actiuni</th>                                
                        </thead>
                        <?php
                            $i=1;
                            $id2= $_SESSION["id"];
                            $result= mysqli_query($conn, "SELECT * FROM tb_user WHERE id= $id2");
                            $row = $result->fetch_assoc();
                            $userconn = $row['username'];
                            $rows= mysqli_query($conn, "SELECT * FROM mesajeuseri WHERE username='$userconn'");
                            $num=mysqli_num_rows($rows);
                        ?>
                        <?php if($num == 1){ ?>
                        <?php foreach ($rows as $row): ?>
                        <tr>
                            
                            <td><?php echo $i++; ?></td>
                            <td><?php echo $row["expeditor"] ?></td>

                            <td>
                                <a href="contact2.php?destinatar=<?php echo $row["expeditor"]; ?>">Raspunde</a>
                            </td>
                        </tr>
                            
                        <?php endforeach; ?>    
                        <?php } ?>
            </table>

I tried to use $num as a counter, and if he hit 1 this should stop and print the result. This is how I think it should work. I know this is not secure and stuff, wide open to SQL, this is just an offline project for me to see how things work. With this condition if($num == 1) I get 0 results in my table. If I change it to $num > 0 everything works fine.
This is my table:
table
userconn – represent the current user which is connected to the website and he should only see his messages not all of theme. For example if I’m connected with “dariu” I should see one row with the value “Lordikita” not 7 rows with the same value.

CORS issue with HTTP 2.0 [closed]

CORS issue with HTTP 2.0

We have a PHP(Laravel 5.2) web app hosted in Apache(CentOS) that acts as a web service for another web app, Website in Angular and admin panel in React

End Points
https://api.mydomian.com/api_name : Web Server URL
https://admin.mydomain.com : Admin Panel URL
https://mydomianname,com : Website URL

It has been running on HTTP 2.0

We have been experiencing CORS errors since the last few weeks without making any changes that can raise any security issues.
The issue does not always happen, sometimes it works after we refresh Chrome. But sometimes it occurs on other resource files, like css or js.

Following headers are set in the backend code
Access-Control-Allow-Origin’, “*”
Access-Control-Allow-Methods’, ‘GET, POST, PUT, DELETE, OPTIONS’
Access-Control-Allow-Headers’, ‘X-Requested-With, Content-Type, X-Token-Auth, Authorization

When we downgrade HTTP 2.0 to HTTP 1.0 It works fine & and we noticed when we downgrade the browser version it works with HTTP 2.0 as well

Experiencing this issue in all the Browsers(Chrome, Firefox, Safari)

How to stop duplicate rows?

i have a problem in my code where if i do import operation, i always get duplicate rows of imported value. What are the problem in the codes below and how to fix the problem so when i do import operation it won’t get duplicated?

import.php

class SubmissionDetailImport implements ToModel, WithHeadingRow
{
    protected $id;
 
    function __construct($id) {
            $this->id = $id;
    }
 
    public function model(array $row)
    {
 
        $spreadsheet = IOFactory::load(request()->file('file'));
        $i = 0;
        foreach ($spreadsheet->getActiveSheet()->getDrawingCollection() as $drawing) {
            if ($drawing instanceof MemoryDrawing) {
                ob_start();
                call_user_func(
                    $drawing->getRenderingFunction(),
                    $drawing->getImageResource()
                );
                $imageContents = ob_get_contents();
                ob_end_clean();
                switch ($drawing->getMimeType()) {
                    case MemoryDrawing::MIMETYPE_PNG :
                        $extension = 'png';
                        break;
                    case MemoryDrawing::MIMETYPE_GIF:
                        $extension = 'gif';
                        break;
                    case MemoryDrawing::MIMETYPE_JPEG :
                        $extension = 'jpg';
                        break;
                }
            } else {
                $zipReader = fopen($drawing->getPath(), 'r');
                $imageContents = '';
                while (!feof($zipReader)) {
                    $imageContents .= fread($zipReader, 1024);
                }
                fclose($zipReader);
                $extension = $drawing->getExtension();
            }
 
            $myFileName = time() .++$i. '.' . $extension;
            $path = storage_path('/app/public/images/detail/');
            file_put_contents($path . $myFileName, $imageContents);
 
            SubmissionDetail::create([
                'submission_id' => $this->id,
                'nama_barang' => $row['name'],
                'image_path' => '/public/images/detail/' . $myFileName,
                'jumlah' => $row['quantity'],
                'harga_satuan' => $row['price'],
                'harga_total' => $row['total_price'],
                'keterangan' => $row['description'],
            ]);
        }
    }
}

importcontroller.php

public function import(Request $request) {
        Excel::import(new SubmissionDetailImport($request->id), $request->file('file'));
        return redirect()->back()->with("status", ["status" => true, "message" => "Success importing detail"]);
    }

Yii2 CSS to asset folder

I have my site.css in my web/css/

which i declared here

namespace frontendassets;
use yiiwebAssetBundle;
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.min.css'
    ];
}

How do i get AssetBundle to copy it into the assets folder to make it look like this

<link href="/frontend/web/assets/2edj2hj2jk/css/site.css" rel="stylesheet">

instead of this?

<link href="/frontend/web/css/site.css" rel="stylesheet">

or is there another way to achieve this? Basically I want everything in web/css, web/images and web/js to be saved in the assets folder

decimal number with ceil or floor in php

I have a result of decimal number

0.666667

and i wold like to fool it or round it to 0.6,

number_format((float)0.66667, 1, '.', '')
  

but I get 0.7

floor(0.66667)

gives me 0

how can i take this result and floor it to 0.6 or ceil it to 0.7

how can i get data of pressed button of row to popup in same window with controllers data , laravel blade template and jquery?

This is an appointment list code in blade template:-

@foreach($drapp as $app)
                                <!-- Appointment List -->
                                <div class="appointment-list">
                                    <div class="profile-info-widget">
                                        <a href="#" class="booking-doc-img">
                                            <img src="{{ asset('/storage').'/'.$app->patients->profileimage}}" alt="User Image">
                                        </a>
                                        <div class="profile-det-info">
                                            <h3><a href="#"> {{$app->patients->firstname." ".$app->patients->lastname}}</a></h3>
                                            <div class="patient-details">
                                                <h5><i class="far fa-clock"></i> {{date("d M,Y",strtotime($app->bookingdate))}}, {{date("h:i a",strtotime($app->bookingtime))}}</h5>
                                                @if($app->patients->city != null)
                                                <h5><i class="fas fa-map-marker-alt"></i> {{$app->patients->city.",".$app->patients->state.",".$app->patients->country}}</h5>
                                                @else
                                                <h5><i class="fas fa-map-marker-alt"></i> Not Defined</h5>
                                                @endif
                                                <h5><i class="fas fa-envelope"></i> {{$app->patients->email}}</h5>
                                                <h5 class="mb-0"><i class="fas fa-phone"></i> +91 {{$app->patients->phoneno}}</h5>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="appointment-action">
                                        @if($app->status == "2")
                                            <a href="#" class="btn btn-sm bg-info-light" id="{{$app->id}}" data-toggle="modal" data-target="#appt_details">
                                                <i class="far fa-eye"></i> View
                                            </a>
                                            <a href="{{url('/')}}/doctor/dashboard/scheduleconfirm/{{$app->id}}" class="btn btn-sm bg-success-light">
                                                <i class="fas fa-check"></i> Accept
                                            </a>
                                            <a href="{{url('/')}}/doctor/dashboard/schedulecancled/{{$app->id}}" class="btn btn-sm bg-danger-light">
                                                <i class="fas fa-times"></i> Cancel
                                            </a>
                                        @elseif($app->status == "1")
                                            <a href="#" class="btn btn-sm bg-info-light" data-toggle="modal" data-target="#appt_details">
                                                <i class="far fa-eye"></i> View
                                            </a>
                                            <a href="javascript:void(0);" class="btn btn-sm bg-success-light">
                                                <i class="fas fa-check"></i> Confirmed
                                            </a>
                                        @else
                                            <a href="#" class="btn btn-sm bg-info-light" data-toggle="modal" data-target="#appt_details">
                                                <i class="far fa-eye"></i> View
                                            </a>
                                            <a href="javascript:void(0);" class="btn btn-sm bg-danger-light">
                                                <i class="fas fa-times"></i> Canceled
                                            </a>
                                        @endif
                                    </div>
                                </div>
                                <!-- /Appointment List -->
                                @endforeach

After pressing the view button the popup will be opened in a same window like this:-

the image of opened popup

popup window code:-

<!-- Appointment Details Modal -->
        <div class="modal fade custom-modal" id="appt_details">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Appointment Details</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <ul class="info-details">
                            <li>
                                <div class="details-header">
                                    <div class="row">
                                        <div class="col-md-6">
                                            <span class="title">#APT</span>
                                            <span class="text">21 Oct 2019 10:00 AM</span>
                                        </div>
                                        <div class="col-md-6">
                                            <div class="text-right">
                                                <button type="button" class="btn bg-success-light btn-sm" id="topup_status">Completed</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <span class="title">Status:</span>
                                <span class="text">Completed</span>
                            </li>
                            <li>
                                <span class="title">Confirm Date:</span>
                                <span class="text">29 Jun 2019</span>
                            </li>
                            <li>
                                <span class="title">Paid Amount</span>
                                <span class="text">$450</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- /Appointment Details Modal -->

the code of appointment popup is shown above when i will press view button the popup will apppear and i want to bring seleted view buttons row data to the that popup

Pull out elements of an Array that is converted from a XML

im trying to create a php file that can pick out and print values from the code below. This is an XML feed that has been changed to json then to an array. I dont get a choice of how it comes but need to pull out the values from any of the keys but cant seem to get back first array.

I would like to for examples

$key1 = $array['serial'];

This is the array I get given to work with

Array

(
[0] => Array
(
[ns2_ProFeed] => Array
(
[ns2_proFeed] => Array
(
[header] => Array
(
[Id] => 987654321123
[cRef] => 00008797
[prodName] => prod1
[externalRef] => TESTING
)

                        [Identity] => Array
                            (
                                [Serial] => 5654300000214
                                [tel] => +013050000214
                                [ref] => 543365514
                            )

                        [service] => {http://url

                        [responseStatus] => Array
                            (
                                [status] => SUCCESS
                                [timestamp] => 2012-01-09T17:28:02.206+01:00
                            )

                        [parameters] => Array
                            (
                                [parameter] => Array
                                    (
                                        [0] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [value] => Active
                                                        [name] => Status
                                                    )

                                            )

                                        [1] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [value] => 2012-01-09 05:25:52.937
                                                        [name] => activationDate
                                                    )

                                            )

                                    )

                            )

                        [options] => Array
                            (
                                [option] => Array
                                    (
                                        [0] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [startDate] => 2012-01-09T17:27:47.370+01:00
                                                        [value] => on
                                                        [name] => ILC
                                                    )

                                            )

                                        [1] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [startDate] => 2012-01-09T17:27:47.297+01:00
                                                        [value] => on
                                                        [name] => data
                                                    )

                                            )

                                        [2] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [startDate] => 2012-01-09T17:27:47.337+01:00
                                                        [value] => on
                                                        [name] => intmessage
                                                    )

                                            )

                                        [3] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [startDate] => 2012-01-09T17:27:47.323+01:00
                                                        [value] => on
                                                        [name] => multims
                                                    )

                                            )

                                        [4] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [startDate] => 2012-01-09T17:27:47.280+01:00
                                                        [value] => on
                                                        [name] => simplems
                                                    )

                                            )

                                        [5] => Array
                                            (
                                                [@attributes] => Array
                                                    (
                                                        [startDate] => 2012-01-09T17:27:47.353+01:00
                                                        [value] => on
                                                        [name] => roam
                                                    )

                                            )

                                    )

                            )

                    )

            )

    )

)

Docker php8.1 cant connect to MySQL [duplicate]

I’m sorry if my question is not 100% correct, it’s my first one here.

I am currently putting together a docker stack and have a problem with the connection between php(php:8.1-fpm-alpine) and the mysql server (mysql:8.0).

I have built in the image for php as follows:

FROM php:8.1-fpm-alpine

# installing PHP PDO extension to talk to MySQL
RUN docker-php-ext-install mysqli pdo pdo_mysql

WORKDIR /var/www/html/web-root

the MySQL server like this:

FROM mysql:8.0

EXPOSE 3307

I can connect to the mySQL server with this data using the software “Beekeeper-Studio”:

host: 127.0.0.1
port: 3307
user: root
pw:   ""

My test php file is built as follows:

<?php 

require_once "/logs/log.php";


$MYSQL_ADDRESS = "127.0.0.1"; // 127.0.0.1 -> mysql: 172.22.0.5
$MYSQL_DATABASE = "version_db";
$MYSQL_USER = "root";
$MYSQL_PASS = "";
$MYSQL_PORT = "3307";
$MYSQL_DSN = "mysql:host=${MYSQL_ADDRESS};port=${MYSQL_PORT};charset=UTF8;dbname=${MYSQL_DATABASE}";


$logger = new Log();


$logger->log("Update Databases!");


if (!in_array('pdo_mysql', get_loaded_extensions())) {
    $logger->log("pdo_mysql not loaded!");
    exit("pdo_mysql not loaded!");
}

$logger->log("MYSQL_DSN: " . $MYSQL_DSN);

try {
    $pdo = new PDO($MYSQL_DSN, $MYSQL_USER, $MYSQL_PASS, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::MYSQL_ATTR_FOUND_ROWS => TRUE]);
} catch (PDOException $e) {
    $logger->log("No connection to database possible");
    $logger->log($e);
    exit("No connection to database possible");
}

$logger->log("connected to database");

And I get this error message logged:
enter image description here

GraphQL query connect to Dutchie API using PHP

I have a store in Dutchie.com. I want to access it’s products using API key.
This has to do via Dutchie API using GraphQL integrated with PHP.

This is the API Key:

public-eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJBUEktQ0xJRU5UIiwiZXhwIjozMzE4NjM5Mjc0NSwiaWF0IjoxNjI5NDgzOTQ1LCJpc3MiOiJodHRwczovL2R1dGNoY29tIiwianRpIjoiNGMtOTMyOC00MjhkLWEyYTMtOWQzMTc2ZTUwODY0IiwiZW50ZXJwcmlzZV9pZChLWExYTctNDM3OC05NWY4LTNlYzVzBiNSIsInV1aWQiOiI0M2ZlMjdkNy1iZWU2LTQxOTgtYWNhMi03N2Y5Y2I3MjI5MGIifQ.hCQWpcQ5uhKnZOSVQDA5SCMkx5kopC7H3upeU-1jMpg

This is the GraphQL Ping mutation.

mutation Ping {
  ping {
    id,
    time
  }
}

Dutchie End Point: https://plus.dutchie.com/plus/2021-07/graphql

Basically I want to run GraphQL query in my PHP page. I’ll add into my WordPress page later.

I have tried php-graphql-client php library.
Can someone help me to do this using above library or another one really appreciate. I wasted too much time for this as I have only few knowledge of GraphQL.