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

I’m sure he will like that it’s procedural :)

borobhaisab commented: You a 100% right there! Checking it oput now. +4
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Is simplexml_load_string() an Xml File Parser just like simple_html_dom() and domdocument() are html parsers ? Out of the latter two, which one you prefer and why that one over the other ?

Kinda, yeah. Instead of creating a DOMDocument it creates a SimpleXML element. I don't personally have experience traversing SimpleXML elements so I can't comment on which I prefer for XML files.

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

I tried to reply but can’t always see the “reply to this topic” link, like now.

It's possible that it is hidden at smaller browser resolutions. (e.g. if your web browser window is small).

You should always be able to find it at the very bottom of the page though.

Screen_Shot_2023-03-20_at_12.44.43_PM.png

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

Yes, you have to first go to the discussion you want to respond to, and then you can reply to that topic.

If you click on the hamburger menu (the three icons to the left of the logo) it will bring up the navigation menu. In the "Your Content Finder" section you can click on "Topics & Posts". Within that section are links to:

Olive34 commented: I tried to reply but can’t always see the “reply to this topic” link, like now. +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

So that function just returns true or false when called, it doesn't actually move anything.

Unfortunately I haven't looked at VB code in 25 years, so I can't be of much further assistance to you, although I'm confused by what you mean when you say you can't identify the coordinates. because it looks like PictureBox1.Top and PictureBox1.Left is identifying its coordinates, no?

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

Where did you attempt to put the code that didn’t work? I’m not seeing it in your full code. Also, the code you are saying isn’t working is just a conditional that checks the size/placements of picturebox1 and pixturebox2 with respect to each other. It doesn’t actually move either of them.

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

Now looking at the screenshot you included in your previous post, the original line says to 'echo' and you replaced it with a line that says to just set it to the variable $line but don't do anything with it (don't echo it). So you would expect that it wouldn't show anything.

Also, I guess I'm confused, what's wrong with the original line that you have?

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

And, with that code, what gets added to 1st_count.txt? Does linkcounter.php successfully grab the value of namehref that was passed into the URL?

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

When you have the URL that includes any_variable_name=$namehref are you also using $GET['any_variable_name'] to retrieve the filename on linkcounter.php?

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

OK, so then looking at the URL "$click?$namehref" it looks like that translates to a URL such as https://nerjabible.com/output/linkcounter.php?<some directory name>

Query strings need to be a key-value pair, meaning something like keyword=<some value here>. Therefore, the URL should be properly written as https://nerjabible.com/output/linkcounter.php?namehref=<some directory name>. In your PHP code, you would want it to look like this:

$line = "<a href=\"$click?namehref=$namehref\"><font color='red'>$name</font> </a>"; 

Then, in the linkcounter.php file, you can do something such as:

$namehref = $_GET['namehref'];

and that will fetch the parameter from the URL string.

Alternatively, you can do something such as:

$line = "<a href=\"$click?any_variable_name=$namehref\"><font color='red'>$name</font> </a>"; 

and then, in linkcounter.php, you would have:

$variable_retrieved_from_url = $_GET['any_variable_name'];

I hope that this makes sense!! Feel free to ask if you have any follow-up questions to get it working.

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

Can you please clarify exactly what the values of the variables $name, $namehref, and $click are?

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

Secure it in what way? For the typical household, a password-protected router is just fine.

nancykhoo58 commented: Thanks! I got it. +0
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I second that you need to normalize your tables. The same problem you're running into here is what is making your MySQL query not work in this other thread of yours.

Good luck!!

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

I'm sorry but I'm confused by your question. If I look at your PHP code, I see that you are pulling in from the form daftar_kursus, which is the submit button ... Then, I see you are using implode to make the variable $IDKursus a PHP array of all of the checked boxes separated by commas. You then have PHP code t update the table pensyarah. What I don't understand is what isn't working the way you're expecting?

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

That should work, yes.

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

The date has to be formatted in W3C Datetime format.

That means it needs to be YY-MM-DD and you currently have YY-DD-MM.

Also, the times are formatted incorrectly as well. Try using ISO 8601 date @ https://www.php.net/manual/en/datetime.format.php

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

It’s not considered new content if there isn’t a substantial change to the content of the page. Google has reiterated this recently as well, specifically going after blogs that have articles such as “Top X of 2022” and then update it to be “Top X of 2023” and make a couple small changes. That was the example Google mentioned, anyways, but I suspect the algorithm would extend to what you’re doing as well.

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

Google catches onto those tricks very, very quickly. It’s a sure way for Google to start not trusting your sitemap. And it also makes your content easily detectable as automated. I highly suggest not doing it, but of course you’re free to do a test run and see what works for you.

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

A dynamic sitemap is optimal if you have more than a handful of URLs. Depending on how often it changes, you can set cache-control HTTP headers, or even cache it in your file system on your end as well.

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

I would definitely build your own dynamic sitemap if the list of pages on your site change frequently (e.g. a blog or user generated content). I'm glad you were able to get it working.

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

I was just thinking … can you show me the PHP code you’re using to generate the MySQL query?

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

I'm really sorry, I cannot for the life of me figure out why that's happening. I must not be noticing something obvious.

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

And this doesn't work? ...

RewriteEngine on
RewriteRule ^([A-Za-z0-9]+)/(.+)$     $1/index.php?name=$2 [L]
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Since changing the folder name, what does your .htaccess look like?

What did the .htaccess look like when it semi-worked? (e.g. it worked as long as there was no hyphen in the name?)

Stefce commented: Yes that is correct it worked without symbols +6
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

And you used the exact code I have above? You don't accidentally have ?name=$2 instead of ?name=$1, right?

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member
if ($y = $link->prepare('SELECT id, password FROM usuarios WHERE username = ?'))
{
    $y->bind_param('s', $_POST['username']);
    $y->execute();
    $y->store_result();

    if ($y->num_rows > 0)
    {
        show_error('Username exists, please choose another!');
    }
    else if ($y = $link->prepare('SELECT id, password FROM usuarios WHERE email = ?'))
    {
        $y->bind_param('s', $_POST['email']);
        $y->execute();
        $y->store_result();

        if ($y->num_rows > 0)
        {
            show_error('Email exists, please choose another!');
        }
        else if (strlen($_POST['password']) > 25 || strlen($_POST['password']) < 6)
        {
            show_error('Password must be between 6 and 25 characters long!');
        }
    }
}

function show_error($error_msg)
{
    echo $error_msg;
    exit;
}
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I would do

if (...)
{

}
else if (...)
{

}
else if (...)
{

}
else
{

}

It's not good practice to short circuit the page by calling exit; in the middle of an if-else block.

You might also wish to look into try/catch blocks for errors.

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

If you look at the rewrite rule I created, it follows the format of A/B where A is a word consisting of lowercase letters, numbers, or a dash, and B is a word consisting just of lowercase letters or numbers.

If you want model-profile/<anything goes> to work, you can do something like this:

RewriteRule ^model-profile/(.+)$     model-profile/index.php?name=$1 [L]
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

Oh goodness, I see the problem with my recent code. The line:

RewriteRule ^([a-z0-9]+)/([a-z0-9]+)$     $1/index.php?name=$2 [L]

says that the URL should be in the form [alphanumeric word]/[alphanumeric word]. But the folder name has a dash in it (model-profile). So it should really be:

RewriteRule ^([a-z0-9-]+)/([a-z0-9]+)$     $1/index.php?name=$2 [L]

Try that.

Does that work?

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

I'm really sorry. I didn't get much sleep and admit I'm a little loopy, but i really don't see what is wrong with:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-z0-9]+)/([a-z0-9]+)$     $1/index.php?name=$2 [L]

That should work, as should the rule I provided before. (This one is a little more flexible)

Update: I just noticed you mentioned you're using Litespeed, not Apache. I have no experience at all with Litespeed, but a little Google research shows that Litespeed does support .htaccess, but you need to enable it by specifying the location of the .hataccess file in your litespeed config. I wish I could help more but I have literally no experience with litespeed. It apparently also works differently depending on if you are using openlitespeed or litespeed enterprise.

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

Are you using Apache with the above htaccess file or are you using Nginx? Is there anything else in your htaccess? What is the specific URL you are typing into your web browser?

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

Yes, it's possible, but how to do it depends on if you are using Nginx or Apache.

If it's Apache, you will need to add a mod_rewrite rule to an .htaccess file and upload it to the domain root. The contents of the .htaccess file would look something like this:

RewriteEngine On
RewriteRule ^model-profile/(.*)$ https://domain.com/model-profile/index.php?name=$1 [L]

As for how to do it in nginx, you would need to modify your nginx config file with either the rewrite directive or try_files directive. (You can use try_files to redirect everything to index.php and then have code in index.php figure out what to do based on the format of the URL).

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

You can mark it as solved by toggling the little green switch next to the reply button. I’ll go ahead and do that for you.

Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member
  1. Are you entirely sure that there are ten columns in the model profile table, listed in order of the columns specified, and with the appropriate filed types (e.g. the columns storing pictures should be blobs, etc.)?

  2. Instead of using htmlentities surrounded by manual single quotes, use $conn->real_escape_string($string) as so:

     $sql = "INSERT INTO modelprofile VALUES (
        '',
        " . $conn->real_escape_string($name) . ",
        " . $conn->real_escape_string($url) . ",
        " . $conn->real_escape_string($profilepic) . ",
        " . $conn->real_escape_string($pic1) . ",
        " . $conn->real_escape_string($pic2) . ",
        " . $conn->real_escape_string($pic3) . ",
        " . $conn->real_escape_string($pic4) . ",
        " . $conn->real_escape_string($pic5) . ",
        " . $conn->real_escape_string($tags) . "
    )";
  3. If the MySQL query isn't running, and it's not triggering an error, and also not spitting out "model added", it's possible the entire if block if(isset($_POST["submitGirl"])) is not being triggered. Try running an else around that if statement to see if $_POST['submitGirl'] doesn't exist.

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

There can be an infinite number of levels of sitemap index files pointing to sitemap index files pointing to sitemap files.

Luckily, the BJ_Crawler class you described over in your other thread already uses recursion to currently handle an unlimited depth, so you don't need to handle this on your end. It's already being taken care of for you.

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

This is not what Google Drive was designed for and it is not recommended. Instead, you should be hosting images through a CDN.

I recommend Cloudflare, as it’s what DaniWeb uses, and they have a free option. It can take some initial configuring to get your server onto Cloudflare, but once it is, you can configure it to cache your images on its servers around the world.

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

I’m glad you got it working, although it wasn’t necessarily the way you were wanting.

You can use URI rerouting so that your pages don’t have a .php extension. DaniWeb is written in PHP and none of our files have a php extension.

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

Have you figured out your bug?

download.png

Without a doubt, this image very clearly shows that those three files are not available at those locations. They are showing 404 errors. Although I do now notice those are .map files ... I've never seen .map files for JS before?

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

Provided that menu.html is not being blocked from being seen by bots in your robots.txt file, Googlebot is able to understand and parse javascript, and is able to understand what the complete page is meant to look like.

However, it is not ideal, from an SEO perspective. Web browsers having to fetch menu.html and then parse the Javascript also makes pages load slower, which is bad for the end-user and also for Google.

The better way to accomplish a shared menu is to use a server-side programming language (PHP, for example).

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

And are the bootstrap and popper JS files also in the correct locations the HTML is looking for them at?

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

Your screenshot shows a file called jquery-3.6.1min.js inside the folder core/js/jquery.

However, your javascript says:

<script src="core/js/jquery/jquery-2.2.4.min.js"></script>

The file jquery-2.2.4.min.js, that your HTML code is looking for, is not there.

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

The javacript console errors say that the jQuery .js file is not at the location you are pointing to. Either you moved the file accidentally, or there’s a typo in the path.

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

I would upgrade to a newer version of jQuery. The version you're using is pretty old.

The jQuery code to load menu.html inside #menu is correct, and the only reason it wouldn't be working is because:

  • menu.html and index.html are located in different folders
  • jQuery is not loading correctly
  • Something in plugins.js or active.js is preventing jQuery from working properly
  • Something else is going wrong in code you aren't including in your example here; For example, if other javascript on the page is syntactically broken, no javascript on the page will work

If you use Google Chrome, as I do, try opening the Developer Tools and see if any javascript console errors show up. You can do this by right clicking on the web page, and then choosing Inspect. Then, when the developer tools open, click the Console tab across the top, and see if it flags any errors. Other web browsers also provide similar functionality although I'm not sure offhand what it's called in Edge, Safari, or Firefox.

The best way for us to help you at this point is probably to just provide a link to the live version of this page, so we can diagnose for ourselves what the issue may be.

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

Here's a little bit about DaniWeb.

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

Another example:

$page = 10; // We set $page to 10
echo 'backward ' .$backward = $page--; // We set $backward to the value of $page, which is 10, and *then* set $page to 9
echo 'forward ' .$forward = $page++; // We set $forward to the value of $page, which is now 9, and *then* set $page back to 10
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

You are setting the value of $page to $backward, and then decrementing $page.

That's why you will notice that after executing:

echo 'backward ' . $backward = $page--;

The value of $backward is 10, and the value of $page is 9.

If what you are trying to do is decrement $page, and then set the newly decremented value to the $backward variable, you will want to do ++$page and --$page.

// Set the value of $page to $backward, and then increment $page
$backward = $page++;

// Increment $page, and then set the new value to $backward
$backward = ++$page;
Dani 4,645 The Queen of DaniWeb Administrator Featured Poster Premium Member

I'll mark this question as solved. Glad you got it working.

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

The purpose of urlencode and rawurlencode is to translate weird characters that have no place being in URLs into a form that is URL-friendly, so that freeform strings can be properly transported within a valid-formatted URL without the URL breaking.

For example, https://www.daniweb.com/wdjd$&@“;!,.html is not a valid URL.

When you use user input (that can literally be absolutely anything) to dynamically build your URL, there’s a chance of the end user entering wacky data that makes no sense in the context of a properly formatted URL. So that’s why we encode the bits and segments of the URL that have the possibility to be “weird”, to ensure that our URL looks and functions like a valid URL. These urlencode functions “translate” weird characters and symbols that have no business being in a URL into encoded versions that represent the characters but in a way that is allowed in URL strings.

$_SERVER[PHP_SELF] is the URL of the current page, according to php. If PHP is telling us it’s the URL representing the page we are on, it goes without question that it’s a valid URL. There’s no need to encode any invalid characters because we won’t find any invalid characters in a valid URL.

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

I remember you said if I use http_build_query() then no need to use urlencode() or raw_urlencode() as http_build_query() will auto do them.

Yes, when I look at the official PHP documentation for http_build_query() I can see that it says that the description of this function is that it "Generates a URL-encoded query string from the associative (or indexed) array provided." Therefore, there is no need to run urlencode() since it does it for me.

rawurlencode() is a whole different matter. Remember, http_build_query() only operates on query strings. rawurlencode() is used on the URL path. You still need to use rawurlencode() if the URL path you want to use is not already URL encoded. In your case, the URL path is set to $_SERVER['PHP_SELF'] which is already properly URL encoded, so there's no need to use it.

You will still want to use intval() to make sure that the 'pg' passed in is an integer. What if someone visits the URL ?pg=blah when you are expecting pg to be an integer?

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

Yes, you should. The first one correctly converts & to &amp;.

Both of these are equally valid:

// Version 1 converts & to &amp; with htmlspecialchars()
$serps_url = $_SERVER['PHP_SELF'].'?'.http_build_query($array);
echo '<a href="' .htmlspecialchars($serps_url) .'">' ."<b>$i</b>" .'</a>';

// Version 2 converts & to &amp; with http_build_query()
$serps_url = $_SERVER['PHP_SELF'].'?'.http_build_query($array, '', '&amp;');
echo '<a href="' . $serps_url .'">' ."<b>$i</b>" .'</a>';

and this is not valid HTML:

// This produces HTML that includes & where it should be &amp;
$serps_url = $_SERVER['PHP_SELF'].'?'.http_build_query($array);
echo '<a href="' .$serps_url .'">' ."<b>$i</b>" .'</a>';