bluerhinos/phpMQTT

mqtt mysql

pw44 opened this issue · 3 comments

pw44 commented

trying to have mysql performing a query based on the mqtt topic.

$mqtt = new Bluerhinos\phpMQTT($server, $port, $client_id);
if(!$mqtt->connect(true, NULL, $username, $password)) {
exit(1);
}

mysql_connect( $mysql_host, $mysql_user, $mysql_pass ) or die( ' Erro na conexão ' );

$mqtt->debug = true;

$topics['bluerhinos/phpMQTT/examples/publishtest'] = array('qos' => 0, 'function' => 'procMsg');
$mqtt->subscribe($topics, 0);

while($mqtt->proc()) {

}

$mqtt->close();

function procMsg($topic, $msg){
echo 'Msg Recieved: ' . date('r') . "\n";
echo "Topic: {$topic}\n\n";
echo "\t$msg\n\n";

is not working... error:

PHP Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /home/paulo/TOOLS/MQTT-PHP/subscribe-mysql.php:27
Stack trace:
#0 {main}
thrown in /home/paulo/TOOLS/MQTT-PHP/subscribe-mysql.php on line 27

any clue?

Your problem is unrelated to this MQTT library!
The function you used "mysql_connect()" was deprecated since PHP5. It has been removed from PHP7.
Please look the up the manual pages and use the alternative suggestion.

pw44 commented
pw44 commented

my fault.