Re: Safely upload a file Programming Web Development by Dani I realize I could have done better when coming up with a safe name. As it stands, a file uploaded that has a file name in non-Latin characters will just end up with a bunch of underscores. I’m not even sure if that suffices as a file name, but for sure there will be collisions as multiple files are attempting to be saved with the same _ name. Re: Flood control using Redis Programming Web Development by Dani Status update: we now use Cloudflare’s free rate limiting functionality. Back when I wrote this, Cloudflare charged for rate limiting. Note we have a Business account. Dynamic Properties in PHP 8.2 Programming Web Development by Dani In my increasingly futile attempt to remain using the now-defunct CodeIgniter 3 framework, I came across something that I figure might be worth sharing in case anyone else is maintaining older PHP codebases and suddenly things start breaking after a PHP upgrade. With PHP 8.2, there’s a new warning that’s catching a lot of people off guard: … Re: Dynamic Properties in PHP 8.2 Programming Web Development by Dani Oh, and an important bit I forgot to mention: PHP's built-in stdClass has the `#[AllowDynamicProperties]` attribute already added. In fact, you can see in the [PHP docs](https://www.php.net/manual/en/class.stdclass.php) that the definition of the stdClass is "a generic empty class with dynamic properties." That means that you can always … Re: Dynamic Properties in PHP 8.2 Programming Web Development by Dani The first I agree would not make much sense to do because one would presume that the User class has its own set of getters and setters for a reason, and just creating random properties on a whim defeats the purpose of organizing and structuring your code by having the class in the first place. Nevertheless, I ran into this exact issue while trying … Re: Dynamic Properties in PHP 8.2 Programming Web Development by jkon I can't get it , why anyone would want to `$user = new User(); $user->nickname = 'Dani';` if nickname is not a public property of User , or even worse `$user = new stdClass(); $user->nickname = 'Dani';` ? Why ? Re: Dynamic Properties in PHP 8.2 Programming Web Development by Dani > This obviously does not make sense to do if you want to create or work with a User object or something of that sort. I realize that in my previous post I incorrectly gave the example of `$user = new stdClass(); $user->nickname = 'Dani';`. My intention was not to say that it was good coding practice to represent a user of the app with an … Safely upload a file Programming Web Development by Dani Here's a quick bit of code to upload a file in PHP. Re: How to show visa info based on country selection in a travel form? Programming Web Development by Biiim I felt like some fun, so I just put together an example for you using CDN's and bootstrap 5. From what you are talking about you probably want to put some of that logic into the Javascript and not need to send a server request for each one, I usually do this kind of thing with javascript objects/arrays (eg `settings['GB']['visa_req'] = false;… Re: How to show visa info based on country selection in a travel form? Programming Web Development by groverharleen Hello, please use developer tool while working on HTML/PHP with AJAX. in the console you can easily track what was the POST/GET request made to PHP file and what is the responses shared by PHP file. try debugging response accordingly or if still you face any trouble, please do share screen shot of Header / Request / Response Tabs. i'll … Re: My php is showing wrong results of time difference Programming Web Development by Dani I am confused when you say the HTML time picker input box can be set to 20:00 for time in and 5:00 for time out, because `<input type="time" ...>` only allows the end-user to specify a time, not a time and date combination. Should it always be assumed that if the time out is earlier than the time in, that it is the next day? … Re: My php is showing wrong results of time difference Programming Web Development by Dani In other words, if you just need days or hours you can do something like `$diff->d` or `$diff->h` (All properties available [here](https://www.php.net/manual/en/class.dateinterval.php), but if you want to calculate a runner's start time and end time and then do something like "You ran the race in 08:33:56!" then you could use the `… Re: How to connect to the Pinterest API using PHP? Programming Web Development by geekinformatic Hey! If you're using the CakePHP framework, you can connect to the Pinterest API with cURL and OAuth integration. Just follow Pinterest’s API docs for endpoints and token handling. Re: How do I remove the last character without breaking the string? Programming Web Development by MAY_261 Use mb_substr() instead of substr(). It handles multibyte characters and emojis correctly. Here is the correct code: $text = "私の名前はダバーです👩‍🚀"; $length = mb_strlen($text, 'UTF-8'); $new_text = mb_substr($text, 0, $length - 1, 'UTF-8'); echo $new_text; https://flatcoding.com/tutorials/php/php-remove-last-… Re: How do I remove the last character without breaking the string? Programming Web Development by Montasser_1 > Use mb_substr() instead of substr(). It handles multibyte characters and emojis correctly. > > Here is the correct code: > > > > $text = "私の名前はダバーです👩‍🚀"; > $length = mb_strlen($text, 'UTF-8'); > $new_text = mb_substr($text, 0, $length - 1, 'UTF-8'); > echo $new_text; > … How do I remove the last character without breaking the string? Programming Web Development by Montasser_1 I try to remove the last character from a string with Japanese text and emojis using this code: <?php $text = "私の名前はダバーです👩‍🚀"; $new_text = substr($text, 0, strlen($text) - 1); echo $new_text; The output breaks the characters and shows garbage. How do I fix this? My php is showing wrong results of time difference Programming Web Development by Mr.M Hi DW, I'm trying to mark attendance register which has the date for which that register is being marked for as well as the date which the register is actually marked on. For Date as well as Marked Date. I also have two time picker textboxs which one is for time in and the other is for time out. Now I've been trying to use even time diff … Re: My php is showing wrong results of time difference Programming Web Development by Mr.M Thanks, to clarify what I meant regarding the dates is that I have a date input that shows a calendar when a user click on it to choose the date for which the register is being marked for. Then I also have 2 time inputs one is for timein and the other is for timeout. Let me try your code and see if it does solve the problem I've been having.… Re: My php is showing wrong results of time difference Programming Web Development by Mr.M I'm getting an error saying the `date_create` class can not be found Re: My php is showing wrong results of time difference Programming Web Development by Dani Oh goodness, I’m sorry! I made a typo. Remove the new keyword. I’ve edited my post above. Re: My php is showing wrong results of time difference Programming Web Development by Mr.M Thank you, you saved me, I've been trying for weeks now. It works now perfectly with your code. Re: My php is showing wrong results of time difference Programming Web Development by Dani > Also just one more question regarding your code, I will have to minus 1 hour from the total hour difference, do I have to use the %h - 1? Just in case you haven't figured this out yet, the answer is no :) In my code above, see where I am showing you what $diff looks like on line 15? You should be able to do something like this: $… Re: My php is showing wrong results of time difference Programming Web Development by Erussuhsh Hi I'm new to android app development can you teach me how to make a app Re: My php is showing wrong results of time difference Programming Web Development by Dani I don’t personally know Android development or mobile development at all. However, others here might. Please start a new question [by clicking here](https://www.daniweb.com/community/contribute/181). Re: Optimizing working with big data Programming Software Development by ThinkWriteGrow > What are some best practices for optimizing memory management when working with large datasets? > > I am tagging this topic both with php (because that is my language of choice, and the one I work with big data with) as well as c++ (because I know DaniWeb has a large low level c++ community that is well suited to being able to delve… Re: How to show visa info based on country selection in a travel form? Programming Web Development by Dani I have moved your post into the web development forum instead of the advertising/marketing forum where it was and tagged it appropriately. Can you please provide the Javascript code as well as PHP code that is buggy so that we can help diagnose this for you. For example, if the JSON response is empty, it is most likely because of a bug in the … How to show visa info based on country selection in a travel form? Programming Web Development by eservices I’m working on a travel planning form that adjusts based on the selected nationality. For example, if someone picks a country like India, the form should display whether they need an electronic visa for places like Sri Lanka, and maybe show a short message or guide link. I’m using JavaScript to detect changes in a <select> dropdown and … Re: Ensuring data consistency and integrity Hardware and Software Cloud-based Apps by Dani We make heavy use of PHP's [Memcached::getDelayedByKey](https://www.php.net/manual/en/memcached.getdelayedbykey.php) which requests multiple items all from a specific server (hashed on the server key, which is the Topic ID #). That ensures that when you pull up a topic, we can retrieve all items for that topic in one request, all from one server. Re: sharepoint policy management software Programming Web Development by Reverend Jim Manitoba Hydro implemented Sharepoint a year or two before I retired. Horrible system if you are expected to manage it without training (as was typical where I worked). I eventually got tired of being told "You're doing it wrong" by the people who DID get the training, while not being told how to do it the right way. I eventually told my … Can I Use AI to Build a Block Management Website for Ilford Clients? Programming Web Development by kearawill Hey developers 👋 I’m working on a new project for a client — a estate agency Ilford, and I’m wondering how much of this could be streamlined or even built with AI tools? The site needs standard features like: Property listings Service request forms (for tenants) Payment gateway Backend for property managers to update info …