I need to add variable called $new_status, but its not being recognised on php, any suggestions.

$sendData = '{ "messages" : [ { "content" : "Your order is $new_status.", } ] }';

$new_status seems fine in my test. But your $sendData statement? I can't tell what your intent was there.

Here's what I tested with an online PHP tool.

<!DOCTYPE html>
<html>
<body>

<?php
$new_status = "01010101";

$sendData = '{ "messages" : [ { "content" : "Your order is $new_status.", } ] }';

echo "<h2>" . $new_status . "</h2>";
echo  $sendData . "<br>";
?>

</body>
</html>
commented: inside content when I put '$new_status, I can see it gets recognised, but I get error Unexpected T Variable +0

I see I was unclear. I was addressing your statement about $new_status by creating a minimum viable example. What it revealed to me was your one supplied line of code may not be doing what you expected. The 15 lines of code does work and $new_status was used and I see the output from the echo statements.

Take a trip to w3chools to use their online PHP tool to try it out.

Also, I can't guess what your single line of code's intent was. That's up to you.

one thing is where is the new status coming from? is it coming from the URL?

if so, you can have something like:

<!DOCTYPE html>
<html>
<body>

<?php

<?php
    if(isset($_GET['status'])){
    $new_status = $_GET['status'];
    if($status=="your variable"){
        echo $sendData = '{ "messages" : [ { "content" : "Your order is $new_status.", } ] }';
    }
    }
?>



echo "<h2>" . $new_status . "</h2>";
echo  $sendData . "<br>";
?>

</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.