Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Oh goodness, I’m sorry! I made a typo. Remove the new keyword. I’ve edited my post above.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

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? Otherwise, if the time out is later than the time in, should it always be assumed that it is the same day?

Perhaps what you mean to say is that you are using <input type="datetime-local"> which makes a lot more sense, because then the end-user specifies both a date and time together.

Let's assume that the datetime-local control is used and both a start and an end are submitted via an HTTP POST form.

We can now do something such as this:

// Get start and end date/time combos from HTTP form
$start = $_POST['start'];
$end = $_POST['end'];

// Create DateTime objects in PHP for us to work with
$start_object = date_create($start);
$end_object = date_create($end);

// Get the difference represented as a PHP object
$diff = date_diff($start, $end);

// $diff is now a PHP object of how many years, months, days, hours, seconds

// See for ourselves what $diff looks like
var_dump($diff);

// Specify a string that says how to format the time interval
$format = '%d days, %h hours, %i minutes';

// Format the difference in a way we want
echo 'The time difference …
Erussuhsh commented: Hi can you help me Dani +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I have seen too much code written by self-taught programmers who, through ignorance, eschewed good design.

While that's very, very true, that's [unfortunately] not typically what people come to DaniWeb asking for help with. Many people unfortunately don't care about doing things right, but just well enough to work. As long as it gets the job done, I suppose.

NuGG: So sorry about hijacking your thread with this whole discussion about the demise of DaniWeb! I am glad, however, that you were able to get your problem figured out, and I'll mark this question as solved. Thanks for sharing your update.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

But programming basics are still something people need help with, and the basics have not changed appreciably over my career.

They sure have changed appreciably during my career! But maybe that's because my career is in web development, and the web, and the technologies that power the web, have changed a lot over the past 25 years. Heck, 25 years ago we were talking HTML and perl cgi scripts! Usenet groups and AOL and Compuserve before that.

Salem commented: Memory lane flashback! I suddenly remembered my CiS ID +16
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

(where people abandoned us for sites like Stack Overflow)

But there are still a few dinosaurs around who can answer some programming questions.

Not to knock ya, but I think another part of the problem is that all that's left are dinosaurs who aren't necessarily skilled at the most trendiest things these days. There's only so much people can reminisce in a forum about punchcards.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Then there’s me, whose expertise is mostly limited to technical SEO and PHP these days, I’m afraid. Ugh, the brain fog is real.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Been coming on daniweb for 20 years, was always such a great place for help and advice. Last time I visited was 4-5 years ago and I noticed then it was getting quieter. Somewhat sorry to see the state of things now, these "most recent" threads are all so old! Where is everyone? I shall try stop by here more often and contribute!

You are very much appreciated. Thank you for your devotion to our community over all the years! Unfortunately, I started dealing with some health issues that left me bedbound in 2020 and 2021. By 2023, I had been diagnosed with a form of terminal cancer among other things. It’s been really hard, but I’m doing my best to keep the website up. In other news, the reason for the increase in SEO content is because that’s my personal passion, and DaniWeb’s reputation in the SEO space (I’ve been speaking at SEO conferences for 20 years) has transcended its reputation in the programming space (where people abandoned us for sites like Stack Overflow).

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Use Cloudflare (free plan is available) and plugins such as WP Rocket or WP Engine.

Romaric Onel commented: Thank you very much.In fact, my site is super fast (92% on mobile and 99% on desktop performance according to Google Page Speed). +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I highly doubt anyone here would be able to sell or license to you access to their Apple developer enterprise account (mostly because it would violate their own agreement with Apple), but out of curiosity, why do you need it? The program is designed for specific use cases in which large organizations need to distribute their proprietary app privately to their employees?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Eek! I’m so sorry. We upgraded our editor last week and I suppose it’s possible a bug was introduced in my code?

Can you please start a new thread in the Meta DaniWeb forum explaining exactly what you were clicking on, etc. just before it crashes, along with your browser and operating system. I don’t really want to conflate this thread with debugging DaniWeb.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Good question. We have multiple web servers that are load balanced, and only 2 database servers in a master/slave setup. I know there are ways to shard the database so you could essentially put different records of a table on different servers, but I personally have no experience with that. I am pretty sure you can shard by row or by column.

We also have a Memcached pool (for caching) where we specify the server we want to use by passing in a server key into all gets and sets. We make sure that all cached items that need to be fetched on a particular page are fetched at once, and always from a single server. That seems to work well for us.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

As Harry points out, my first guess would be to check robots.txt and ensure you aren't blocking any pages from SEMRush. Also make sure you aren't using a CDN or proxy like Cloudflare that is blocking it from their side.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Sorry, I'm confused. Do you want to decode the JSON in PHP or in Javascript?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I can only speak for the limited experience I have in coding DaniWeb. What we do differs mainly between if the HTTP request that's requesting the PHP page uses GET or POST. In the case of a POST request, we're most likely signing up, creating a post, editing a user profile, etc. In the case of a GET request, we're most likely just reading content and not modifying the database.

GET Requests:

  • Open a persistent MySQL connection at the beginning of the PHP script
  • Execute n number of MySQL queries (typically 0-3) throughout the PHP script

POST Requests:

  • Open a non-persistent MySQL connection at the beginning of the PHP script
  • Start a transaction
  • Execute n number of MySQL queries (typically 3-5) throughout the PHP script
  • End the transaction
  • Close the MySQL connection

On average, a rough guess is that each script takes about 120 ms to execute for an end-user. HTTP latency then brings that number closer to 200 ms (of course, depending on where in the world you are, this is often much higher) from HTTP request to response.

We then do run PHP scripts in cron jobs to do things like send emails and perform some heavy calculations. We do this much the same way as our GET requests, in that we open a persistent MySQL connection. The cron job often executes a couple really complex MySQL queries that might take as much as a second or more to execute. There's also a lot …

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

So I went ahead and made sure to connect.close() everywhere that I opened a connection

How many times do you have a single script opening and closing a connection to MySQL? Is this a web script?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Are you connecting to MySQL with persistent connections? What happens if you don't use persistent connections?

Also, I'm confused what you mean about it complaining about too many connections simply by you changing how many records a single connection works with?

cored0mp commented: responded below, thanks +2
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What I mean is, can you please provide the URL on spaces.w3schools.com, so that I can see if maybe it's a CORS issue that is causing the problem. (That's my best guess as to what the problem is, but if I can check out the URL, I can investigate further.)

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Can you please share a public link to a URL where you are testing/using it so that I can investigate further?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What happens when you just go to the URL https://api.snoopi.io/check?apikey=MY API KEY ? Does the API correctly provide your location in JSON format?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I wish I could help but I do MySQL and PHP. I definitely agree with you that it makes sense to get data into the database and then process it and query it as much as you can from in there. However, it’s been my experience that, just because you can do it from within MySQL, doesn’t mean you should. MySQL is not always the best tool for the job, the same way Python or PHP are not always the best tools for the job. Sometimes it’s more efficient to do things, especially manipulating records, from outside the database.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

rproffit, are you referring to this or this? Or this? (All 3 of which I was only able to find after typing in your exact Google query. "Vaibhav Jaiswal" came up with nothing.)

We are not psychics. We can't guess what search query you would use nor which search result you would click on. If you're going to make a recommendation to read something, can you please post a link to what that is?

rproffitt commented: I wonder if this is OP's own article? +0
VAIBHAV_20 commented: why do you think soo? that it's his or not +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Why is it your job to determine it?

The only thing that is against our community rules is to not specifically ask for help to do something illegal. He posed in his own question that he wants to learn ethical hacking, which is not illegal. Why should his very first post in this community be met with having to go out of his way to prove why he's not lying?

rproffitt commented: vaibhav jaiswal ethical hacking found it for me. +17
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

As I always do when we get a big influx of spam, I evaluated what's getting through our spam bot and made some adjustments. It now catches an additional 22% of spam posts compared to 5 weeks ago.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I'm so sorry about that!!

Last night I was working on some stuff until rather late, and my husband stopped me and told me to come to bed. I did a cursory check that everything was looking good, checked in my work, and went to bed. Apparently I broke something and didn't realize it until morning. It's now been fixed. So sorry about that!!

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I guess that’s changed since I submitted my site what I feel like is at least a decade ago.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

You are correctly implementing 301 redirects in an .htaccess file. Ensure that the redirects point to the exact same URL as you have in the canonical.

Additionally, ensure that all internal links throughout your site point to that same URL as well.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Is that what you want your preferred URLs to look like?

Read a Book commented: Yes, thats correct way of displaying and reading in my language +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Make sure that every page has the correct link rel=canonical html tag set to tell Google what the one and only URL to the page is.

Ensure there are no internal links anywhere in your site that use this wrong version of the URL.

Remember, Google is finding this wrong URL somewhere! It’s not making it up :)

Ideally, implement 301 redirects from the wrong version of the page to the correct version.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I don't have personal experience with multilingual websites or non-English websites to be able to advise you on what's best. However, I would advise you that while it's appropriate to use multiple fonts, you want to ensure the entire website has a consistent look and feel, navigational structure, and design language. Otherwise it will be very confusing to the end user and not a good experience, and Google realizes that.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Google won’t get confused as long as you implement 301 redirects from non-www to www. The benefit of keeping both search console accounts is you can keep track and see that Google is stopping/slowing down crawling the old one and no longer indexing it.

If Google search console is still showing you indexed pages for the non-www property, then you know you have a technical SEO problem you’ll need to solve.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Hello,

Google Search Console is showing that vidceo is not the main content of the page, because I don't see any video on this page? I don't see how not having the carousel loop by default will change that?

Or are you referring to the other products at the bottom of the page that are rotating through as well?

Either way, I'm not seeing video anywhere on the page?

Can you provide a URL with an example of a product that has video, so I can see why you think Google is not prioritizing it?

As far as your carousel is concerned, I see a link to the javascript file https://www.kupisi.mk/js/dz.carousel.js at the bottom of the page. When I look at this MoonCartCarousel, I see that it is just the theme making calls to a jQuery class called Swiper and telling Swiper to set autoplay with various delays of 1500-2000 milliseconds. So then I looked at swiperjs.com and I can see here in the API docs that simply removing the autoplay: { } parameter will completely disable autoplay. You can make some other tweaks as well.

dz.carousel.js currently looks like this (I passed it through a JS beautifier to format the code):

var MoonCartCarousel = function() {
    var handleMainSwiper = function() {
        if (jQuery('.main-swiper').length > 0) {
            var swiper = new Swiper(".main-swiper-thumb", {
                loop: true,
                spaceBetween: 10,
                freeMode: true,
                watchSlidesProgress: true,
                autoplay: {
                    delay: 1500,
                },
            });
            var swiper2 = new Swiper(".main-swiper", {
                loop: true,
                effect: "fade", …
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

As someone who has been in the SEO industry for over two decades, it doesn't really matter if you use www or non-www. All that is important is that, whichever you choose, you stick to it. That means that all links on the web (social media, etc.) point to the same version of your domain. All internal links on your website point to the same version of your domain (if they are not relative links). All that matters is that you're consistent.

If you have canonical links set up in your HTML, make sure they reference the new www version of your domain. You will also want to make sure you have redirects set up to redirect every non-www URL to its www counterpart with HTTP 301 Permanent Redirect. Make sure you're not using 302 temporary redirects, as that sends a different signal to Google.

Since you've switched, you will also want to create a Google Search Console property with the https://www. version of your domain. I'm not sure if you're already using Search Console (you should be!) but, if you already are, you'll need to create a new property.

I believe Google Analytics also requires a different property to be set up and differentiates between www and non-www.

As far as whether it was a good choice, that's up to you. Google doesn't care.

Also, Cloudflare support is never ideal. I have no clue why they would recommend you switch to the www version if you're getting …

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Isn't that expected behavior?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I also think the problem is that with mod_rewrite on, READ_LEX begins with / and with mod_rewrite off, READ_LEX ends with /.

Is the value of BASE_URL set to http://localhost/mysite or http://localhost/mysite/ ?

You might be ending up with a URL that looks like http://localhost/mysitereadlex/slug instead of http://localhost/mysite/readlex/slug

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

In <head> I have this php:

I see you have on line 3 if($mod_rewrite == 'Off') {. Where do you set the value of $mod_rewrite? How do you tell if it's Off or On?

Which I then recall in this link and htaccess works fine:

Again, where do you set the values for BASE_URL?

The same link without Constant PHP:

What do you mean by 'Constant PHP`?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I apologize that I still am misunderstanding you.

I'm confused what you mean by "example from database", because it seems your question is about htaccess and PHP. I'm confused what is being retrieved from the database

In your second example, what are the values of BASE_URL and READ_LEX?

Additionally, your .htaccess file said readlex.php but in your example in your previous post, you have read-lex.php.

You should be able to use the following .htaccess file I have below to convert:

http://localhost/readlex.php?slug=Provvedimento-di-sospensione-Trib-Cagliari

into:

http://localhost/readlex/provvedimento-di-sospensione-trib-cagliari

RewriteEngine On    
RewriteRule ^readlex/(.+)$ readlex.php?slug=$1 [NC,L]
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I suppose I’m not properly understanding your question. Do you mean when you go to the URL in your browser localhost/mysite/readlex.php?slug=Le-mura-di-Lucca it doesn’t load, but when you go to the rewritten URL it works fine?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Hello there! I can try my best to help you as I'm pretty good with this kind of thing. However, I'm a bit confused what you're referring to. I'm on your website's homepage, and I don't know what swipe effect you're referring to? I'm on a macOS laptop using Chrome.

rproffitt commented: I see a carousel effect. Might be in CSS but I haven't dug into their site. +17
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

It has to do with the scope of a javascript variable. It means that the variable is hoisted (aka “lifted up”) to the top of the code block it’s in.

This has nothing to do with web hosting, and is only relevant if you are a javascript developer.

jayashree10 commented: Thank you for answering. 😇🌈i understood +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I’m so glad you got it figured out! Sorry we weren’t able to help you.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I’m not personally too savvy about this, but does SSH require you to send a private key?

Forgive that portion of my question, as I personally upload via SSH, which I believe cURL is able to handle as well. So for a moment I thought you were doing the same.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member
  • Check that you’re using a valid username and password and that those credentials have proper access to the path you’re attempting to connect to
  • I’m not personally too savvy about this, but does SSH require you to send a private key?

Are you able to connect via regular command line?

Also, I did a Google search to try to get you an answer. Is this you by any chance? https://stackoverflow.com/questions/77404068/libcurl-c-curle-failed-init-failure-establishing-ssh-session-43-failed-get

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

What happens when you do:

SELECT CONVERT(UNHEX(HEX('string')) USING utf8mb4);

You can see from https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_binary-as-hex that it shows that as of MySQL 8.0.19, it displays binary data as hexadecimal when mysql is in interactive mode. You can disable it with the --skip-binary-as-hex flag when connecting via the command line.

I don't believe this is an issue if connecting via a web app and using an appropriate character set.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Sorry! I went on a bit of a tangent about BASE64 because I skimmed over your initial question and saw you were doing things such as UNHEX(HEX()).

Let me answer your question now: I think it has to do with the encoding you're using for your database. When I do SELECT UNHEX(HEX('string')); I get string back. I'm using MySQL 8 with a server charset of UTF-8 Unicode (utf8mb4).

What happens if, when connecting to MySQL from the command line, you add the flag --skip-binary-as-hex?

cored0mp commented: This showed promise, but did not fix the error. Instead I had to use the CONVERT() function +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

The reason I ask is because something we use here at DaniWeb is:

// Convert from Base 10 to Base 36
function encrypt_id($id = 0)
{    
    return base_convert($id, 10, 36);
}

// Convert from Base 36 to Base 10
function decrypt_id($id = 0)
{    
    return intval(base_convert($id, 36, 10));
}

This is PHP, but you get the point. I suspect python has a similar function.

And then the MySQL equivalent of those would be:

CONV(id, 10, 36) // From Base 10 to Base 36
CONV(id, 36, 10) // From Base 36 to Base 10

Base 10 system allows for the characters 0,1,2,3...9 (Hence 10 different characters used to represent the number)
Base 36 system allows for 0-9 as well as A-Z (Hence 36 different characters)
Base 62 system allows for 0-9, A-Z, and a-z, but php's native base_convert() function doesn't support it

We do this for integer ID #s because the encoded versions are both portable and fewer bytes, which serves us well in a couple of different areas. For example, instead of the number 987654321 we can send GC0UY9.

You should be able to use the same/similar algorithm for ASCII strings.

Base 64, which is essentially Base 62 plus + and / characters, is used a lot to encode/decode strings, such as to transport binary data over email. Therefore, there's a MySQL FROM_BASE64() and MySQL TO_BASE64() as well as, in PHP, there's base64_encode() and base64_decode(). A quick Google search showed that Python has similar functions e.g.:

import base64
string = …
cored0mp commented: Thanks! This helped. Ended up solving it with CONVERT (FROM_BASE64('TXkgY2F0IGxpa2VzIHRvIGNoYXNlIGVsZXBoYW50cyE=') USING utf8mb4) +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Is there a better way to python-encode data that's consistently reversible using mysql for processing?

I suppose the first question I would ask is why does the data need to be encoded in MySQL? What is the objective for it to be encoded? I suspect it's not security, since you're wanting something easily portable and encoded/decoded cross-platform, and encoded rather than encrypted. I also suspect it's not to conserve space, since, with the algorithm you're using, your encoded string is longer than your decoded version.

What is the problem you are trying to solve instead of just keeping everything in plain text?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I'm a fan of the Percona flavor of MySQL. DaniWeb used to do a lot of work with Percona back when they were a small startup and I had the cell number of the owner. Nowadays they're too big for us ;)

cored0mp commented: Thanks Dani! +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I believe you need to connect to the appropriate database first, before issuing the create table command. From my understanding, it is not possible to specify a database name from within the create table command.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Wow! Thats realy awesome idea. Ill try it!

Did it work?