Jump to content
  • Who's Online   0 Members, 0 Anonymous, 2,214 Guests (See full list)

    • There are no registered users currently online

All Activity

This stream auto-updates

  1. Today
  2. Ok.. I am a total plonker! I looked a bit harder and the declarations are in fact made conditionally. I've moved them outside of the if() block. That'll solve the issue. My fault, my bad, apologies for wasting peoples time.
  3. this isn't a php version problem. the problem may have always existed, but you just likely have error_reporting/display_errors set to values now that's reporting and displaying this error. note: a nonexistent variable is loosely a false value, so any == or != comparison or if($var) of if(!$var) will logically work. your code could be unsetting it, or you have a character set problem, where either the definition or usage isn't exactly what it appears to be. i would delete and retype one or both lines or copy just those lines into their own file file and run them. edit: here's another possibility - the php code where the definition is at, isn't actually php code, due to the use of a short open tag. if you cannot determine the cause of the problem, you will need to post enough of the code that reproduces the problem.
  4. Fair comments but no, it’s an unconditional declaration and in the same scope. #baffled
  5. A couple of possibilities spring to mind. Are the definition and the usage of the variable inside the same scope; for example - is it used inside a function but defined outside that function? Is the definition inside a conditional block of code (eg if() )so that it has not been executed because the condition was false?
  6. Hi folks, first time here although I've been coding in PHP for more years than I can remember. I'm in the process of moving some legacy code from v7.4 upto 8.2, which has the following declaration: $pri_sec_replaced = FALSE; However, when executed I receive the following warning: PHP Warning: Undefined variable $pri_sec_replaced in ... Am I missing something fundamental here? As far as I'm concerned the boolean has been declared and set. Thanks in advance.
  7. Yesterday
  8. Last week
  9. What's the underlying OS, and what MUA (SMTP program) is running? /var/log/maillog /etc/maillog - Sendmail, etc. /var/log/exim4/mainlog, /var/log/exim4/paniclog - Exim No idea if you're using QMail; but logfiles are usually very insightful in these cases.
  10. Sounds reasonable.
  11. It's either an issue with the existing code, or an issue with your server environment. Because the script is generating a 500 error, this is something that needs to be debugged. Optimistically, this probably a sub 4 hour job, but I have no idea what that means for freelancer or other sites of that type. There's also the issue of preparation of an environment for testing the code, and version control. Assuming none of those things are in place, is the developer going to YOLO on your production server? In order to even figure it out, you probably want a developer with strong sysadmin skills who can diagnose what is going on with your hosting environment. So I'd build your estimate with a range from 4-8 hours.
  12. We would need to see some code, as well as a link to the documentation. One obvious thing to try would be to open the connection using "r+" instead of "w+".
  13. I'm working on a new project to control my hottub. I'm designing using a RasPi 3+ and an 8 chan relay board. I have a php function that does "$fd = fopen (/dev/ttyUSB0, w+) and fprint (fd, "0x%s", an octal string); and relay 1 turns on, turns off - as does 2 thru 8. on off on off on... life is good. My problem: Mfg info says 0xFF will return the status of all 8 relays as in "00100110". I have tried all sorts of combinations of fprint 0xFF which seems to go OK. Then fgets, fscanf, fread and the code just hangs. Has anyone gotten this to work? Can someone offer some help? Thanks in advance. (I'll owe u a beer)
  14. Also, what would be an estimated budget for completing this project? Freelancer is recommending the following options: Micro ($30 - $250) and Entry ($250 - $750).
  15. Thank you for the detailed information regarding this issue. So, is this simply a matter of hiring a programmer and having them update the code on the form to PHP v8.3 and imagemagick, or is there something further that needs to be done? Are there any recommendations for where to find a programmer? I've had success with Freelancer.com in the past, but that was awhile ago and was only for smaller fixes. Any further assistance or recommendations would be greatly appreciated.
  16. Beyond mac's insights and salient comments, the code snippet you provided tells us nothing, as it is not the code you are using. The only way to gain insight into this is having detailed logging to review when the mailer freezes. I'd also suggest scanning the release notes in regards to the phpMailer releases, to check if there are any Breaking changes you might have missed, or things that are now handled differently between the two versions. There are 2 likely possibilities based on your comments: There are some emails that are causing issues when delivered. The way the code is written (and the environment involved) uses up available resources (network connections, database handles, or other available memory). Many companies use phpMailer so I am doubtful that there is an issue with it that would be trivially obvious, but regardless of that, you need detailed debugging which will be best facilitated by the injection of an object that implements PSR3 as described in the phpMailer source code here. If you don't already have that, here's a bit more on setting that up: After the instantiation of the PHPMailer object, that would involve a call like this: $mail->Debugoutput = new myPsr3Logger; A lot of projects use the well regarded monolog library which allows for logging to be integrated into many different logging systems, but in your case, just insuring it is writing to a log file on your system would be sufficient. As for some trivia, the author of monolog is the same guy who created PHP's dependency management tool Composer. The documentation states that the only log level that will be used is the 'Debug' level.
  17. It is the scripts in the subdirectory named boatlettering. There are 2 I see being called: The image src runs boatNamePreviewImage-new.php load_image2.php gets called when changes to the parameters are made. Obviously things on the server changed and this is probably because your code uses an ancient and long end of life version: php5.6. On top of that, it relies on the imagemagick library, so any issues with the version of imagemagik that supported that old version of php will also cause it to no longer function. I don't see this as being a quick fix, and there is very little people here could do for you, even with the source code, as your existing code is antiquated, and needs to be updated to run under supported versions of php and the imagemagick library, as well as running on a supported operating system, which it most likely did not previously, or now that it has been updated, will no longer support the old code.
  18. What you will see if you open that PHP file in a text editor such as Notepad.
  19. What is the "source code"?
  20. We can't help unless you share the source code of the script. All I could say at this point is the script outputs a 0 byte image.
  21. I have a boat name designer that uses ImageMagick to generate the image. It has been working fine for years and then suddenly stopped working this morning. When I clicked on the link, instead of the designer I got a "500 server error". I contacted the Host provider and they were able to get the designer back online but the image preview did not work. Here is our communication from oldest to newest: ================================================= The website has a form that should generate an image, but it fails to do so, everything else works except for that particular component. The customer wanted to revert to a backup, but it did not work. Opened the ticket to take a deeper look. ================================================= After investigating the issue, we were not able to find the root cause of the Image preview issue. At first, there was an issue with the suPHP module as it was not installed on the shared host. I had to edit a line of code in the `.htaccess` file so the 500 error you called for went away. Adding a `#` to every line of the block so it was disabled: ``` # #suPHP_ConfigPath /home/boatlett/public_html/boatlettering/ # # #order allow,deny #deny from all # ``` Before that, I also installed the module to prevent any code modifications. This created issues on the server overall, so I had to revert to the previous setting. The logs are not giving us any explicit cause of the issue. So the best option will be to contact a developer so they have a better solution to the issue with the form, as it looks like it should run with PHP 5.6, according to this line: ``` AddType application/x-httpd-ea-php56 .php .php5 .phtml ``` ================================================= Unfortunately there are no errors being displayed, so we would have nothing to work off of in reviewing the 'BoatLetteringPreviewForm.php' script. No errors are shown when checking the F12 developer console, and no errors are being logged in the site's home directory. In such a case, you would need to contact the script's developer to determine why the script is not functioning properly. If the script requires some specific PHP version or extension, we could set the site to use it, though we would not be able to determine the script's requirements simply by looking at it. ================================================= At this point I suggested they reinstall the ImageMagick module as I recalled this issue happened a few times in the past and was fixed rather quickly by doing that. Here is their reply: ================================================= I checked the module and tried to reinstall, but I do not think it will take any effect. I did found old similar tickets for the same problem and noticed we also suggested a developer to look into the same issue further. (But reinstalling fixed the issue so no need to contact a developer) You can try to change the PHP version and see how it goes, but a developer would be indeed more suited to check the issues here. ================================================= It seems to me they don't want to reinstall ImageMagick because they don't think it will do any good. Should I push them on the matter? If nothing more than to eliminate it as a cause? I was hoping someone could take a look at the page: https://www.boatlettering.net/boatlettering/BoatLetteringPreviewForm.php and give me an idea of what's going on and why the image generation portion would suddenly stop working without making any changes to it? Sincerely,
  22. That was the question originally posed as I interpreted it. This is why the OP posted interest in the ESP32, which is a line of 32 bit Microcontrollers. They are typically used for IOT projects, and I don't think are a good match for this. A Raspberry pi, Orange Pi, or even a GMTek Mini PC are all a lot more viable given the OP's professed direction in this project, involving an OS capable of running an HTTP server and app server.
  23. AI tools are usually pretty good for getting started with a simple task like this. I googled the relay board you mentioned and found a PDF that lists the data required to turn the relays on or off. I feed that into ChatGPT and asked it to describe the protocol to get an understanding of it. I then asked it to generate a web form using PHP that can be used to turn the relays on or off. <?php // relay_control.php // === Function to build command === function relayCommand(int $relay, bool $state): string { $header = 0xA0; $relayByte = $relay & 0xFF; $stateByte = $state ? 0x01 : 0x00; $checksum = ($header + $relayByte + $stateByte) & 0xFF; return pack('C4', $header, $relayByte, $stateByte, $checksum); } // === Handle form submission === $message = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $relay = intval($_POST['relay'] ?? 1); $state = ($_POST['action'] === 'on'); $cmd = relayCommand($relay, $state); $hexCmd = strtoupper(bin2hex($cmd)); // Example: write to USB device (uncomment when you know the device path) // $fp = fopen('/dev/ttyUSB0', 'wb'); // if ($fp) { // fwrite($fp, $cmd); // fclose($fp); // } $message = "Relay $relay " . ($state ? 'ON' : 'OFF') . " → Command: $hexCmd"; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Relay Control</title> <style> body { font-family: Arial, sans-serif; padding: 20px; } form { margin: 20px 0; } select, button { font-size: 16px; padding: 5px 10px; margin: 5px; } .msg { margin-top: 15px; font-weight: bold; } </style> </head> <body> <h1>LCUS-8 Relay Control</h1> <form method="post"> <label for="relay">Relay number:</label> <select name="relay" id="relay"> <?php for ($i = 1; $i <= 8; $i++): ?> <option value="<?= $i ?>"><?= $i ?></option> <?php endfor; ?> </select> <button type="submit" name="action" value="on">Turn ON</button> <button type="submit" name="action" value="off">Turn OFF</button> </form> <?php if ($message): ?> <div class="msg"><?= htmlspecialchars($message) ?></div> <?php endif; ?> </body> </html> Sounds like a project that you could do with a raspberry pi computer + the relay board. Might be able to go even simpler if you didn't need to host the control interface on the device itself and instead just communicated with it over the network or a serial port.
  24. how are you invoking this? is the code looping over data, and if so what is the code with the looping? approximately how long was the execution time for each of the segments of sent emails? you are using exceptions for errors. when using exceptions, none of the discrete error checking logic will ever get executed upon an error and should be removed. when using exceptions for errors, unless you are doing something special with the error information, you should not catch and handle exceptions in your code. instead let php catch and handle any exception, where php will use its error related settings (error_reporting, display_errors, and log_errors) to control what happens with the actual error information, via an uncaught exception error. php's error_reporting should always be set to E_ALL. if you are invoking this via a browser, you should set display_errors to ON, so that any php detected errors (which will include any uncaught exceptions) will be displayed. if you are invoking this via a cron job/scheduled task, you should set log_errors to ON, so that any php detected errors will be logged.
  25. I just updated PHPMailer from version 5.1 to 6.10.0. I was successfully sending small batches of emails today, so I thought everything was great. Tonight I went to run a job that was going to send a couple thousand emails out and it stopped about a third of the way through. It just stopped sending out emails after about 369 emails. I started it again from the point where it quit and it only made it through the next 500ish. After starting from that spot it made it through the list. There are no errors messages, no error logs, no debugging logs. I never had anything like this happen when running v5.1. Nothing else changed in my code, data files, etc. So I am wondering if there is some limiting factor with the newer PHPMailer? Does it take more memory? I'm looking for ideas on how to debug this. Any relevant differences between PHPMailer 5.1 and 6.10.0? Suggestions how I should debug it? Other than the first 4 lines of code below, nothing has changed. I find it hard to believe it is a code issue since this has been running for many years without issue. Ideas where I should start? require_once 'include_files/PHPMailer/PHPMailer_v6.10.0/PHPMailer/Exception.php'; require_once 'include_files/PHPMailer/PHPMailer_v6.10.0/PHPMailer/PHPMailer.php'; require_once 'include_files/PHPMailer/PHPMailer_v6.10.0/PHPMailer/SMTP.php'; $mailer = new PHPMailer\PHPMailer\PHPMailer(true); $mailer -> IsSMTP(); $mailer -> Host = 'smtp.mandrillapp.com'; $mailer -> SMTPAuth = true; $mailer -> Username = 'myusername'; $mailer -> Password = 'mypassword'; $mailer -> SMTPSecure = 'tls'; $mailer -> Port = 587; $mailer -> IsHTML(true); $mailer -> AddReplyTo('My Email'); $mailer -> FromName = "My Name"; $mailer -> From = 'My Email'; $mailer -> AddAddress('Your Email'); $mailer -> Subject = 'My Subject'; $mailer -> Body = 'My Message'; if ($mailer -> Send()) { } else { print "Mailer Error: " . $mailer->ErrorInfo; }
  26. Earlier
  27. Did I miss where a question was asked? What was the source .py being copied here, in case that's necessary information? Input arguments are rather awkward, like gizmola said something like $_POST or even $_GET will probably be more appropriate. Obviously the exact nature of the $on/$off stuff is irrelevant to operating the board so it can be rewritten into any style. For the board, seems odd that you're actually supposed to include a "0x" in the buffer? Otherwise since this is a device, a mere file_put_contents is likely sufficient - w vs. r+ shouldn't matter.
  28. The script does no parameter count checking, which isn't a great idea. First thing you would want to do is check $argc == 3. I'm assuming you know that $argv[0] is the script name, so typically you would check the count and display a "usage {$argv[0]} relay# 0|1 [off|on]\n", or something similar if it's not the right count. With that said you stated you wanted to do this with an html page, so probably it would be better to just have a "self posting" form script where you use html to display the controls, and set the 2 parameters based on whatever UI decisions you make. In that case, you would want to get the 2 parameters via the $_POST[] superglobal array, perhaps with html form elements named $_POST['relay'] and $_POST['state'] which you can set to be 0 or 1. You certainly in either case want to do some bounds checking (cast to int or use intval) and insure that the relay is in the range of 0-7. It would also be good if there was a way to determine the pre-existing state of the system. With that said, given the circumscribed set of functions, and purpose of this, I would suggest that you consider the alternative of a board based controller, perhaps with an lcd keypad. With a "mini-pc" you have all the issues of how your web app is going to be displayed, although if your device has wifi, you could design the html/css to be responsive, and control it using a pc or phone. Sounds like a fun and interesting project.
  29. I'm starting a new project to replace the $700 hot tub controller board with a "Roll your own". Haven't decided on the CPU - ESP32-? or a less than $100 micro pc. As needed the relay board ( LCUS-8 USB Relay Module 8 Channel DC 5V ) will drive T9AS1D12 30A relays. Web page for display and control. Anyhow looking for how to control the relay board using PHP - Google wasn't any help. I found a 70+ line python script ( I dislike py ) so I used it as a base for a 19 line PHP script. #!/usr/bin/php <?php $on = array ("", "\xa0\x01\x01\xa2", "\xa0\x02\x01\xa3", "\xa0\x03\x01\xa4", "\xa0\x04\x01\xa5", "\xa0\x05\x01\xa6", "\xa0\x06\x01\xa7", "\xa0\x07\x01\xa8", "\xa0\x08\x01\xa9"); $off = array ("", "\xa0\x01\x00\xa1", "\xa0\x02\x00\xa2", "\xa0\x03\x00\xa3", "\xa0\x04\x00\xa4", "\xa0\x05\x00\xa5", "\xa0\x06\x00\xa6", "\xa0\x07\x00\xa7", "\xa0\x08\x00\xa8"); $relay = $argv[1]; $oo = $argv[2]; $fd = fopen ("/dev/ttyUSB0", "r+"); switch ($oo) { case 0: fprintf ($fd, "0x%s", $off[$relay]); break; case 1: fprintf ($fd, "0x%s", $on[$relay]); break; } fclose ($fd);
  1. Load more activity
×
×
  • 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.