Jump to content

Unable to load a class


ebolisa

Recommended Posts

Hi,

I've a simple code which uses a class from here. When I execute it, I get this error

Quote

Fatal error: Uncaught Error: Class 'phpMQTT' not found in C:\Apache24\htdocs\mqtt\test.php:10 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\mqtt\test.php on line 10

and I cannot understand why my code doesn't see the class. Both files, the class.php and test.php, are in the same folder.

Any help is appreciated.

TIA
 

<?php
require("phpMQTT.php");

$server = "192.168.0.250";     // change if necessary
$port = 1883;                     // change if necessary
$username = "";                   // set your username
$password = "";                   // set your password
$client_id = "phpMQTT-publisher"; // make sure this is unique for connecting to sever - you could use uniqid()

$mqtt = new phpMQTT($server, $port, $client_id);

if ($mqtt->connect(true, NULL, $username, $password)) {
    echo 'hereeeee';
    $mqtt->publish("room/lamp", "on" . date("r"), 0);
    $mqtt->close();
} else {
    echo "Time out!\n";
}
?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.