-
Posts
15,067 -
Joined
-
Last visited
-
Days Won
414
Posts posted by requinix
-
-
How many php.ini files do you have? Did you edit the right one? Use phpinfo or php -i to see which file it's using.
-
private static $templateMail = BASEURL . 'assets/mail/template.html';
This is probably wrong: the template should be a file, not a URL. You need a different constant (or none at all) instead of BASEURL.
-
1 hour ago, eaglehopes said:
I tried installed them package by package but, could not start Apache2.
Did you edit any of the configuration yourself? It pretty much works out of the box... and given that XAMPP said the port was already in use means that it was, in fact, running.
1 hour ago, eaglehopes said:Since English is not my mother/native language, it is my mistake.
It's a common thing that even English speakers will do. It annoys me, personally. I was unnecessarily harsh on you for it.
1 hour ago, eaglehopes said:If I prevent access to that file by .htaccess file, can I drop that red flag?
I mean more that you (probably) shouldn't be creating this file at all. What is it? Most of the time, someone will do this sort of thing because the file acts as a database instead of, you know, using an actual database (which is the "M" in XAMPP).
-
1. You're using XAMPP on Linux? 😆 Just install Apache, PHP, and whatever else you need through your package manager. Normally.
2. It's code. Singular. "Codes" are things you enter into videogames.
3. Don't reference w3schools. Sometimes they tell you the right thing to do, sometimes they tell you the wrong thing to do, and if you're learning then you won't be able to tell the difference between them.Where did you put main.js? /opt/lampp/htdocs/js/main.js? Then the first form you had is correct. If not then (a) why not? and (b) the second form was correct (except "js/main.js" - no ./ - is cleaner and means the same thing), however you might discover problems with this approach...
And changing that won't affect any of your PHP code. The thing with file_put_contents is a completely separate issue. That error is telling you that /opt/lampp/htdocs/pages does not exist.
It's also a red flag that you're using code to create this filesList.txt file, but I'm going to ignore it.Also, please tell me you're not running this as root. Use your user account - give it ownership of /opt/lampp/htdocs and everything inside it.
- 1
-
1 minute ago, Adamhumbug said:
My reason for doing this is we need to be able to print it on paper and it needs a cover page as well as headers and footers.
A cover page is just a DIV with a page break after.
Headers and footers are harder: HTML and CSS don't really do those. There are hacks for specific browsers that can mostly do it, but really if you need these sorts of things then you should be generating PDFs.
Depending what library you use, there may be some special markup you can use to specify a page header and footer. -
DIVs representing pages is a weird way of doing this. Normally you don't and you just create a regular page...
You can use CSS to affect printing, though, such as break-before and break-after.
- 1
-
Some searching suggests the Twitch player has to do it itself, but in case that's not accurate, I would try using the FullScreen API triggered by when the screen orientation changes.
- 1
-
1. In order for Javascript to find the #input-id element, it needs to exist in the browser's DOM - that's the internal model that the browser uses to manage the page.
2. When you put things into the <head>, they happen immediately as the browser is loading the HTML markup it's receiving from the server.
3. Your datepicker input is somewhere down on the page.Putting those together means that DOM stuff in the <head>, such as using getElementById, is not going to work in 99% of cases. You're simply trying to do things too early and they're not available yet.
The right way of doing this is to wait until the DOM is ready. Exactly how depends on what/whether you're using Javascript libraries, as most tend to give you an easy way to hook into that without worrying about the details; the classic example is jQuery's $(function) syntax.
But for a simple, non-library method, it's generally sufficient to put your DOM <script> stuff at the bottom of the page. Browsers build up the DOM as they go, so putting your scripting at the bottom of the page generally means that the rest of it is ready to use.
<html> <head> <!-- these resources will be loaded immediately when the browser reads the page --> <link href="css/hotel-datepicker.css" rel="stylesheet"> <script src="js/fecha.js"></script> <script src="js/hotel-datepicker.min.js"></script> </head> <body> <script> // #input-id does not exist yet... </script> ... <input type="text" id="input-id" name="datepicker"> ... <script> // now it does var hdpkr = new HotelDatepicker(document.getElementById("input-id"), options); </script> </body> </html>
-
This page lists their supported platforms. It doesn't go back far enough to list MySQL versions that existed around the time of Windows XP. Unsurprisingly.
If you look at the Important Platform Support Updates, you'll see they killed XP support around 2014. Pull up the platforms page on archive.org around that timeframe, or a little later, and I bet you'll have an answer.
-
2 minutes ago, requinix said:
the scanner may have noticed the "eval" at the bottom, which allows executing arbitrary code
If the scanner cannot be told to ignore this warning, there is a minor modification you can make to the code that I suspect will "resolve" it...
-
There's no way we can tell you whether this file meets "legal regulations" and, since we don't know anything about you, all we can do to judge whether the file is safe is to venture guesses.
It appears to be a valid file, even if it does some risky things - the scanner may have noticed the "eval" at the bottom, which allows executing arbitrary code - and follows some outdated and discouraged practices, and it does not appear to be malicious.
You should confirm that the file hasn't been modified recently: something like this should not have received any recent modifications, and likely would be dated to the same time frame as many other files on the site.
-
54 minutes ago, Adamhumbug said:
String needs to be in quotes?
String needs to be in quotes.
You've got one set on the outside for PHP, another set on the inside for the HTML attribute, and now you need a third set for the Javascript string.
You have three options:
// raw double quotes, but escaped because of the PHP quotes $out .="<tr class='align-middle custom-lc' onclick='triggerClientContextMenu($cId, \"$coName\")'>" // double quotes as HTML entities, which won't conflict with PHP's quotes $out .="<tr class='align-middle custom-lc' onclick='triggerClientContextMenu($cId, "$coName")'>" // single quotes as HTML entities, which won't conflict with the HTML's quotes $out .="<tr class='align-middle custom-lc' onclick='triggerClientContextMenu($cId, '$coName')'>"
These three options may leave you open to problems if $coName contains apostrophes and you haven't protected yourself against that.
A fourth option is to run $coName through json_encode and then htmlspecialchars with the ENT_QUOTES flag (and them in that order), after which you can put it directly into the "code" without manually adding quotes.But the fifth option is better: take a whole different approach to this by not using 1990s' web techniques like inline Javascript handlers...
-
Does this
triggerClientContextMenu(1, Company Name)
look like valid Javascript code?
-
If you need a count then array_unique won't help you. There is one that can help, though, in this list.
To output something before each "word", what have you tried so far?
-
10 minutes ago, Pikachu2000 said:
Ok, thank you. The reason I was thinking of a separate images table is that only about a third of the questions will have any image at all, and some may have one type, the other type or possibly even both types. I didn't want to leave a bunch of empty fields in the question table, but if that doesn't matter I'm fine with it. My thinking was along the same lines with a table for correct answers, but again if it doesn't matter, it doesn't matter.
I've heard opinions that if a piece of data (read: column) will often be null then it should be moved into its own table. I don't agree.
10 minutes ago, Pikachu2000 said:EDIT: It's also possible any one question could have an unknown number of either/both image types.
Ah, then that means a one-to-many relationship and you're forced into creating that third table.
-
Generally, the first step for something like this is to figure out what sorts of "entities" you have. Don't think about it in terms of database tables: you're modelling the real world right now, not what you put into the software.
These things tend to stand out on their own, like you could look up the data for each one individually. "A question" and "an answer" are the two most obvious things; you could think of "an image used in a question" as one as well, but I don't.Then you figure out relationships between your various entities and the pieces of data - "has one of", "has many of", that stuff. If you could have more than one of a thing then it almost always needs to be a separate entity (if it wasn't already).
So here, I think
-
Questions
- ID
- Type
- Text
- Image path
- Whether the image is inline or opens separately
-
Answers
- ID
- Question FK
- Text
- Maybe a priority/sort order for arranging the answers
- Whether it's the/a correct answer
The questions and the answers are obviously their own logical entities. I don't think the images are, like I said, unless you wanted to reuse images for multiple questions. You could still do it if you really wanted to, of course.
The relationships are "each question has one-or-more answers" and "each answer belongs to one question" (I assume). That means answers must be their own entities, but that was already established. The fact that it's one-to-many means you don't need an association table and can just use regular FKs; if you were to decide that "each answer could belong to multiple questions" then you have a many-to-many and be forced into creating that third table. Likewise, I wouldn't say you need a separate table to associate a question's correct answers: the relationships there are "each question has one-or-more correct answers" and "each correct answer belongs to one question" (unless not, but this one's even less likely), which is identical to their general relationship and so fits into that system naturally without needing anything more than an "is a correct answer" flag.
-
Questions
-
Seems to be working correctly. You do realize that you have nothing in that header except for a tiny image applied as the background, right?
-
There isn't an error because you didn't write any code to do that. If you want to show an error (and also redisplay the form) then give PHP appropriate code for it.
It'll be a little awkward, though, considering your form is shown before you try to process it. Any errors you try to show will display below the form, which isn't where people would normally expect to see them.
It's actually quite backwards from how things are normally done. You should rearrange your code a little so that (1) if the form was submitted you process it, and then (2) you can show the form (if you want) with appropriate error messages (if you want). -
Presumably both of them do so to match the original mysql, whose fetch_array returned the combined form. And I'm going to guess it did out of some sense of "maximum usefulness, minimum effort": call the thing that returns an array and you can use it however you want. $_REQUEST will have come out of that same sort of mentality too, back when PHP was treated more like a templating system than a programming language.
-
You don't have to if you don't want to, but it is the package management tool for PHP. And it's not like you have to install any actual software - Composer is, itself, also PHP code that you can simply run.
- 1
-
Those are just PHP libraries. PHP code. They'll work just as well as your own code does.
- 1
-
1. CAPTCHA
2. CAPTCHA
3. Use a mailing library like PhpMailer or SwiftMailer instead of doing it yourself with mail() - not least because they will construct proper emails that are less likely to hit your spam filters
4. CAPTCHA- 1
-
Parentheses are for grouping. You use them when you want to deal with things as a group instead of each one individually.
"Alice is driving to work, and Bob is driving to work, and Cindy is driving to work": the three of them are each taking their own cars to work and contributing to local traffic problems.
"(Alice and Bob and Cindy) are driving to work": the three of them are carpooling like responsible human beings.Having parentheses for the sake of having parentheses is wasteful but not inherently wrong. But when you throw other things into a regex, like + or *, and to apply them to the parenthesized group, then you change what the regex does.
"(Alice and Bob and Cindy)+ are driving to work": there are some number of people, every one of them named Alice or Bob or Cindy, and they are all driving to work together in one comically-oversized minivan.
"(Alice and Bob and Cindy)* are driving to work": maybe there are three people driving to work, or maybe there are more than three people, or maybe there aren't any people at all because it's the weekend and they don't work on the weekend. -
2 hours ago, phppup said:
My final solution is
$pattern = "/^([A-Z][a-zA-Z '&-]{1,48})*[A-Za-z]$/";
Is this the same as your solution?
No.
When testing software, your goal should be to break it. To make it do something you don't want, or to not do something you do want. Simply testing some examples of what you want and what you don't isn't enough.
Since I have other things to do today,
$pattern = "/^[A-Z][a-zA-Z '&-]{1,48}[A-Za-z]$/";
Try both your solution and my solution against the string
AbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyzAbcdefghijklmnopqrstuvwxyz
Passing Variables From Function to Function
in Javascript Help
Posted
You've skipped past one very particular problem: you want an existing menu item's text to reflect something that can change. Using a variable for the addItem's label doesn't mean that you can change the variable's value later and the label will update. You would have to add and remove these items every time the custom-lc is clicked.
So the truth is actually that no, the code you've posted doesn't work. Not that you're using it wrong but that it can't do what you want. And I don't see anything in the library you're using that lets you edit menu labels.
I'm not sure how you came across that library, but when I search for "jQuery context menu" the very first result is this one, which looks like a much better option given that it's been updated during this year and, you know, it has actual documentation.