Dynamic google line chart not showing up with php and Javascript

I am using google charts to display a line graph on my locally hosted web page. I am using mysqli to take the data from my phpmyadmin database then echoing this into the row spaces in the javascript.

This is the code within my html body:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>

<script>
    google.charts.load('current', {packages: ['corechart', 'line']});
    google.charts.setOnLoadCallback(drawBasic);

    function drawBasic() {

        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Date');
        data.addColumn('number', 'Speed');

        data.addRows([                
            <?php 
            $sql = "SELECT id_rides, speed, date_completed FROM rides_done WHERE (id_users = $_SESSION[id])";
            $result = mysqli_query($link, $sql);
            while($row = mysqli_fetch_assoc($result)) {
                $date = $row['date_completed'];
                $speed = floatval($row['speed']);
                echo "['".$date."', ".$speed."],";
            }
            ?>
        ]);

        var options = {
            hAxis: {
            title: 'Ride date'
            },
            vAxis: {
            title: 'Average speed'
            }
        };

        var chart = new google.visualization.LineChart(document.getElementById('chart_div'));

        chart.draw(data, options);
    }

</script>

The problem is that nothing is being displayed on the web page.

I know that the query works as I tried this on it’s own outside of the javascript and this was output: results of sql query

Before I added the dynamic element of the chart it was working fine with just random lists of data.

I was expecting to see a line graph with ‘Average Speed’ on the y-axis and ‘Ride date’ on the x-axis with 7 datapoints but nothing was displayed.

It seems that js is particular about datatypes here so I’m wondering if it is something to do with either of the following lines – both of which I have been fiddling around with to no avail.

echo "['".$date."', ".$speed."],";

data.addColumn('string', 'Date');
data.addColumn('number', 'Speed');

Thank you very much. All suggestions and ideas are very welcome. As is probably evident I am very new to Javascript so likely to be making some stupid mistakes.

Format date events to dd-mm-yyyy in fullcalendar

I have a database, where there dates who are in format like 21-01-2023 but fullcalendar read dates like 2023-01-20.

I would like to read dates events like 21-01-2023 14:55.

I set lang to fr but just change the language not the the format date.

Any advice or tips would be appreciate.

Thanks.

there is example code of what i want to (see the third events example please)
the sample code :

<html>
  <head>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.css"/>
  </head>

  <body>
    <h2>Translate FullCalendar v2</h2>
    <center>
    <div id="calendar"></div>
    </center>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>

    <script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/lang-all.js"></script>

<script>
$(document).ready(function(){
     $('#calendar').fullCalendar({
          lang: 'fr',
                events: [
        {
          title: 'All Day Event',
          start: '2023-01-01'
        },
        {
          title: 'Long Event',
          start: '2023-01-07',
          end: '2023-01-10'
        },
        {
          title: 'Long Event in my format date i want',
          start: '20-01-2023',
          end: '21-01-2023'
        },
      ]
      });
});
</script>

  </body>
</html>

Astro transforming async generator functions is not supported yet

I want to support old browsers for my website. I am currently trying to use @vitejs/plugin-legacy. But while building I get this error,

[vite:esbuild-transpile] Transform failed with 9 errors:
entry.mjs:551:0: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
entry.mjs:683:2: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
entry.mjs:696:0: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
entry.mjs:1256:2: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
entry.mjs:1295:0: ERROR: Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
...

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
548|  function markHTMLBytes(bytes) {
549|    return new HTMLBytes(bytes);
550|  }
   |    ^
551|  async function* unescapeChunksAsync(iterable) {
   |  ^
552|    for await (const chunk of iterable) {

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
681|      return "AstroComponent";
682|    }
683|    async *[Symbol.asyncIterator]() {
   |    ^
684|      const { htmlParts, expressions } = this;
685|      for (let i = 0; i < htmlParts.length; i++) {

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
693|  function isRenderTemplateResult(obj) {
694|    return typeof obj === "object" && !!obj[renderTemplateResultSym];
695|  }
   |    ^
696|  async function* renderAstroTemplateResult(component) {
   |  ^
697|    for await (const value of component) {

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
1254|      return this.returnValue;
1255|    }
1256|    async *render() {
   |    ^
1257|      if (this.returnValue === void 0) {
1258|        await this.init();

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
1292|    return typeof obj === "object" && !!obj[astroComponentInstanceSym];
1293|  }
1294|  
   |   ^
1295|  async function* renderChild(child) {
   |  ^
1296|    child = await child;

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
1987|    }
1988|    if (!hydration) {
1989|      return async function* () {
   |             ^
1990|        if (slotInstructions) {
1991|          yield* slotInstructions;

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
2029|      island.props["await-children"] = "";
2030|    }
2031|    async function* renderAll() {
   |    ^
2032|      if (slotInstructions) {
2033|        yield* slotInstructions;

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
2086|    const children = item.children;
2087|    return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
2088|  };
   |     ^
2089|  async function* renderExtraHead(result, base) {
   |  ^
2090|    yield base;

Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
2111|    return renderAllHeadContent.bind(null, result);
2112|  }
2113|  const renderHead = createRenderHead;
   |                                       ^
2114|  async function* maybeRenderHead(result) {
   |  ^
2115|    if (result._metadata.hasRenderedHead) {

 error   Transforming async generator functions to the configured target environment ("chrome64", "edge79", "es2020", "firefox67", "safari11.1" + 2 overrides) is not supported yet
  File:
    entry.mjs

Reproduction: https://stackblitz.com/edit/typescript-ry3189

How do I fix this?

Disabling resize window below 250px

Hello i was preparing a website and came accross that on rezing the window below 250px it looses its responsivity especially on firefox. Is there a way, i can disable rezing below 250px;

What i expect is javascript that will alert on rezing below 250px.
what i tried is

$(function () {

    $(window).bind("resize", function () {
        console.log($(this).width())
        if ($(this).width() < 250) {
           alert('resizing below 250px may cause in losing of responsivity');
        }
    })
})

How to use object generated from SQL Server to populate HTML elements?

In my SQL query PHP I have:

<?php  
    $mstr_ID = $_GET['MF_ID'];  
    $sql = "select hospital, patient_id from masterfileaccess where masterfile_id = " . $mstr_ID . "FOR JSON PATH";  
    $patLookup = sqlsrv_query($conn,$sql);  
    $row = sqlsrv_fetch_array($patLookup, SQLSRV_FETCH_ASSOC);  
    echo json_encode($row);  
    sqlsrv_free_stmt($patLookup);  
    sqlsrv_close($conn);  
?>  

In my JavaScript function I have:

function chooseThisPatient(id,name){  
    const mstrID = name.substring(2);  
    const xhttp = new XMLHttpRequest();  
    xhttp.onload = function() {  
    const res = JSON.parse(xhttp.responseText);  
        alert(res)
        // what do I do here to access the JSON file?  
    }  
    let phpfile = "cardiac/phps/cardiacGetPatientData.php?MF_ID=" + mstrID;  
    xhttp.open("GET", phpfile);  
    xhttp.send();  
}  

When I run the select on SQL Management Studio, I get:

[{"hospital":"Good Hospital","patient_id":"12345678"}] 

When I run chooseThisPatient() withOUT the JSON.parse, alert(res) gives me:

{"JSON_F52E2B61-18A1-11d1-B105-008-5F49916B":"[{"hospital":"Good Hospital","patient_id":"12345678"}]"}  

When I run chooseThisPatient() WITH the JSON.parse, alert(res) gives me: Object object

I have tried xhttp.responseXML, res[x] (where x is 0-10) – this gives me single characters ‘[‘,'{‘,”, etc. Have tried res.hospital (undefined), res['hospital'] (undefined), res.key, res.key(), res.key[0], res.keys, Object.keys(res), Object.keys(res[0], all without being able to see what the JSON is holding.

What I would LIKE to happen is to be able to put the object in a loop and update HTML elements, something like:

for( x in res){  
    const key = x.key;  
    const value = x[key];  
    document.getElementById(key).innerHTML = value;  
}  

How to make options DropDown Scrollable in AngularJS Select

I am using select in angularJS and want to have the dropdown from options scrollable as I have a large number of options and it doesn’t look nice.

<select autofocus class="form-control" ng-model="operationName" ng-options="operation for operation in operationNameList" style="width: 440px">

I tried adding a css class but that doesn’t seem to work as well.
.dropdown-menu { max-height: 40px; overflow-y: auto; }

How to access nested elements of json object in node js and mongodb

`const mongoose = require("mongoose");

const productSchema = mongoose.Schema({
  product_name: {
    type: String,
    required: [true, "Must Enter Product Name"],
  },
  product_brand: {
    type: String,
  },
  category: {
    type: String,
    required: [true, "Must Enter Product Catagorey"],
  },
  reviews: [
    {
      name: {
        type: String,
      },
      user: {
        type: mongoose.Schema.Types.ObjectId,
        ref: "User",
      },
      comment: {
        type: String,
        required: true,
      },
      rating: {
        type: Number,
        // required: true,
      },
    },
    { timestamps: true },
  ],

  owner: {
    type: mongoose.Schema.Types.ObjectId,
    ref: "User",
  },
});

module.exports = mongoose.model(“Product”, productSchema);

Here I want to access the values of commet for Appling filters

Here is is output of my products

[ { "_id": "63c4ee520ca7722674d007d5", "product_name": "Headphones", "product_description": "xvy", "product_price": 8000, "product_brand": "Apple", "product_color": "White", "product_stoke": 3, "category": "Headphones", "product_image": "public\images\uploaded\products\167385045002297820433-5f2f-43d1-972a-4b33785393ee.0ad829318c5599f429d2a6e625f8bde3.jpeg", "product_sku": "#1", "owner": "63c4ed720ca7722674d007ab", "reviews": [ { "name": "Daniyal Alam", "user": "63c43d54cf582066929c8c46", "comment": "Good Mobbile Phone", "rating": 4, "_id": "63cbce2cd52bf9ecfdf29323" } ], "__v": 1 }, { "_id": "63c4e3530ca7722674d006b6", "product_name": "Air bud Two.", "product_description": "In the busy world which is fil.", "product_price": 50000, "product_brand": "Apple", "product_color": "White", "product_stoke": 5, "category": "Headphones", "product_image": "public\images\uploaded\products\167384763581197820433-5f2f-43d1-972a-4b33785393ee.0ad829318c5599f429d2a6e625f8bde3.jpeg", "product_sku": "33", "owner": "63c4d8ac0ca7722674d00529", "reviews": [], "__v": 0 }, ]

I want to access my comments i tried the following code but it only returns reviews

`exports.commentProduct = async (req, res, next) => {
  const newproduct = await Product.find({});
  try {
    const reviews = newproduct?.map((p) => {
      if (typeof p.reviews != "undefined") {
        console.log(p.reviews);
      }
    });
    const com = reviews?.map((c) => {
      // console.log(comments);
    });

    // const comments = reviews.comment;
    return res.status(200).json({
      success: true,
      reviews,
    });
  } catch (error) {
    return res.status(500).json({
      success: false,
      message: error.message,
    });
  }
};
`

the Console Prints products having reviews but after appliyng dot notation on reviews i got undefined

`[
  {
    name: 'Daniyal Alam',
    user: new ObjectId("63c43d54cf582066929c8c46"),
    comment: 'BEst One',
    rating: 5,
    _id: new ObjectId("63cbce44d52bf9ecfdf29743")
  }
]
[]
[]
[]
[]
[]
[]
[]
[]
[
  {
    name: 'Daniyal Alam',
    user: new ObjectId("63c43d54cf582066929c8c46"),
    comment: 'pp',
    rating: 4,
    _id: new ObjectId("63c4f76e0ca7722674d040ae")
  }
]
[]
[
  {
    name: 'Daniyal Alam',
    user: new ObjectId("63c43d54cf582066929c8c46"),
    comment: 'Good Mobbile Phone',
    rating: 4,
    _id: new ObjectId("63cbce2cd52bf9ecfdf29323")
  }
]`

why the mongoose.findById is failing when I pass an id in the url which is wrong?

here is the code of mine

router.get('/:id', async (request, response) => {
    try{
        const user_obj = await User.findById(request.params.id);
        if (! user_obj) return response.status(404).send("No course found with the given id.");
        return response.send(user_obj);
    }
    catch(error){
        console.log(error);
    }
    return response.status(400).send("done.");
});

what i am trying to do is to catch the exact reason of failing which is obviously we all know object id is not correct.

i do have tried to wrap it in a try catch block and to get the error message from the error but it says

BSONTypeError: Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer

which is not really descriptive why it is happening.

abort() from a request made by a handler function

I am trying to optimize my react code by fixing any memory leaks. For this i am using createAsyncThunk canceling-while-running.

I am successful in implementing this using useEffect where I dispatch a reducer to request,
when the component mounts and i could automatically trigger abort() signal when the component unmounts using the return of useEffect. Refer the below code:

useEffect(() => {
    const promise = dispatch(getIssuedBooks())
    return promise.abort()
  }, []);

But i have other reducers which get dispatched on onClick events. Refer the code below:

const handleRequest = (id) => {
      dispatch(requestBook(id))
    }
  }

My problem is when component unmounts how do i abort from this request. I tried some things but it did not work out. Please help. Thanks in advance.

Xui one API test form PHP

i want to give online test with xui one api via sms api contact form how can i do this

http://dns/accescode/?api_key=*****&action=create_line&is_trial=1&username=trialeapi&exp_date=1hour&bouquet=???&allowed_outputs=???

Hello

i want to give online test with xui one api via sms api contact form how can i do this


http://dns/accescode/?api_key=*****&action=create_line&is_trial=1&username=trialeapi&exp_date=1hour&bouquet=???&allowed_outputs=???

How do I upload files to pocketbase?

I am using pocketbase and svelte.js.
How can I upload pictures to pocketbase via an html input.

<script lang="ts">
    import { currentUser, pb } from './pocketbase';
    const axios = require('axios').default;

    const fileInput = document.getElementById('fileInput');

    async function uploadFile() {
        axios({
            method: 'post',
            url: 'http://127.0.0.1:8090/api/collections/images/records',
            data: {
                image: fileInput.file,
            }
        });
    }

</script>

<form enctype="multipart/form-data" method="post" on:submit={uploadFile}>
    <input type="file" name="fileInput" id="fileInput">
    <button type="submit">Upload</button>
</form>

Firebase: Error (auth/user-token-expired)

let me first note that I am new to firebase and authentication matters … for several days I am facing a problem with updating email and password functionality using firebase… I want to know if this problem have something with using React and its way of working like re-rendering components ..etc. or is it the use of promises the way i’ve done in the code below.. I really don’t know.

This is the error that I am facing.

Uncaught (in promise) FirebaseError: Firebase: Error (auth/user-token-expired).

Here is the code involved in the situation

firebase.js

const updateUserEmail = (newEmail) => {
        return updateEmail(auth.currentUser, newEmail);
}
const updateUserPassword = (newPassword) => {
        return updatePassword(auth.currentUser, newPassword);
}

update_profile.jsx

async function handleUpdateProfile() {
      setErrorMessage('');
      setIsLoading(true);
      // check for password equality
      if (passwordInputRef.current.value !== confirmPasswordInputRef.current.value) {
        setErrorMessage('Passwords do not match');
        return;
      }
      const promises = [];
      if (emailInputRef.current.value !== currentUser?.email) {

     promises.push(updateUserEmail(emailInputRef.current.value));
     
      }
      
      if (passwordInputRef) {
 promises.push(updateUserPassword(passwordInputRef.current.value);

      }
 
      Promise.all(promises).then(() => {
        navigate('/');
      }).catch((err) => {
        console.log(currentUser);
        console.log(err)
        setErrorMessage('Couldn't Update Your Profile');
      }).finally(() => {
        setIsLoading(false);
      })
    }

I tried auth.currentUser.reload()
like that

auth.currentUser.reload().then(() => {
        updateEmail(auth.currentUser, newEmail);
    })

I tried Re-authenticate the user using the doc guide here
firebaseDocs

but nothing solved the error.