Post imp values to MySql database via php

Hi ,

I am trying to post a value into my MySql database via a php script, using this as the squirrel code:

local _td = OutputPort(“TD”, “string”);
imp.configure(“Transfer one value to mysql”, [], [_td]);

I get a good connection to my php script, as the node “Http Request” shows 200.
Also, when I check with the node “Show Input”, the text “MySendText” appears correctly.

However, when I then try to send the data from via php to the MySql database,
the php does not seem to pass it on. However, the php script creates an empty database entry each time I run the imp code.

This is the php code I am using:

<?php $con=mysqli_connect("","...","...","..."); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="INSERT INTO imp_txt (Textfield) VALUES ('$_POST[TD]')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error()); } echo "1 record added"; mysqli_close($con); ?>

I am aware that the error may be on the php side. However, I successfully manage to call the same php script from an html file, which adds a value to my database ok.

Any ideas please?

Should you be using the HTTP REQUEST vimp in your planner?

See that example of sending (POST) data to a website.

Or is there another way to POST to a remote website that I haven’t learned yet?

My hero!

Now it works.
I replaced

$sql=“INSERT INTO imp_txt (Textfield)


$sql=“INSERT INTO imp_txt (Textfield)

I hadn’t realised that value is a part of a standard expression in PHP.

LOL … I didn’t even notice the ‘value’ part. Glad you saw that in the example.

I’m awaiting the improvements on various agents. I assume that the imp (squirrel) will be able to post data to remote http websites without using the planner? Am I correct that in the future, the ‘planner’ will no longer even be used?

Yes, agents can send data to remote APIs without planner use at all; you can still use the planner though. We have other things coming to replace that later!

@Joachim I am trying to set up a similar project. Would you be willing to share the code for the project on the server side?

$sql="INSERT INTO imp_txt (Textfield) VALUES ('$_POST[value]')";

I hadn’t realised that value is a part of a standard expression in PHP.

Just for the record: value is not part of a standard expression in PHP, but the name of the HTTP POST parameter used by the HTTP Request node to transmit your data. See the documentation: