ebolisa Posted March 16, 2020 Share Posted March 16, 2020 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/310305-unable-to-load-a-class/ Share on other sites More sharing options...
requinix Posted March 16, 2020 Share Posted March 16, 2020 Look at line 3 of phpMQTT.php. Quote Link to comment https://forums.phpfreaks.com/topic/310305-unable-to-load-a-class/#findComment-1575510 Share on other sites More sharing options...
ebolisa Posted March 16, 2020 Author Share Posted March 16, 2020 Hum, If I comment line 3, it fixes the issue. Quote Link to comment https://forums.phpfreaks.com/topic/310305-unable-to-load-a-class/#findComment-1575511 Share on other sites More sharing options...
requinix Posted March 16, 2020 Share Posted March 16, 2020 Don't comment it. Leave it be. Do you know what it is? Do you know what it means? Quote Link to comment https://forums.phpfreaks.com/topic/310305-unable-to-load-a-class/#findComment-1575512 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.