-
Posts
15,289 -
Joined
-
Last visited
-
Days Won
436
Everything posted by requinix
-
With PHP? Yes, but not in a good way. Javascript is the answer. Why do you want to avoid it?
-
File paths and URLs are not always the same thing. Look at your browser's address bar right now: does it say? https://forums.phpfreaks.com/var/www/forums.phpfreaks.com/index.php?controller=idontknow&action=something&whateverelse&id=313889&name=altering-percieved-resource-path If your $root is also the root of the website then there's a really easy way to get an absolute path: start with a slash. That's it. / in the URL will correspond to the $root. <link rel="stylesheet" type="text/css" href="/css/actors.css"> <link rel="stylesheet" type="text/css" href="/css/gallery.css">
-
A few different ways of solving this, and the ones I like involve continuing with the food[x][y] names but making sure to give every "x" position a value. Because "food[][y]" is very much not going to work. Consider this markup: <input type="hidden" name="row[1]" value="1"> <input type="text" name="fruit[1][name]" value="Apple"> <input type="number" name="fruit[1][qty]" value="1" min="0"> <input type="hidden" name="row[2]" value="2"> <input type="text" name="fruit[2][name]" value="Orange"> <input type="number" name="fruit[2][qty]" value="3" min="0"> <input type="hidden" name="row[kljdshglkjsdfg]" value=""> <input type="text" name="fruit[kljdshglkjsdfg][name]" value="Banana"> <input type="number" name="fruit[kljdshglkjsdfg][qty]" value="6" min="0"> row[x] tells you what the existing ID number is. The "x" could be anything, but the ID number itself is convenient (even if redundant). Then the fruit[x][y] data belongs to that row in the table. If row[x] is empty then it does not exist yet. The "x" can still be anything, even though it doesn't exist, but picking a value anyway means you can group the fruit data by that key. If those additional fields are generated by Javascript then you provide an "x" with any random value. Such as literally a random value. Or a non-random but unique value like the current timestamp, though you would have to get at least millisecond precision to make sure there aren't duplicates if I want multiple rows added in the same second. The only gotcha with the arbitrary "x" is that you have to be careful with numbers because of how PHP manages array keys: if you picked the current timestamp with milliseconds, two rows in quick succession might be x=1234567890.123 and x=1234567890.456, but PHP will take both of those numbers and truncate them to integers, resulting in losing the first row's data because the second overwrote it.
-
You have a problem with file paths and somehow making one file appear to be in another place is the opposite of a solution. Consider that someday you, or maybe someone else, would look at that code and wonder how the hell it seems to be including the correct file when the file path is clearly wrong. 1. If you need to move the file then that sucks. Move the file and get it over with. IDEs can often help with rename operations, otherwise it's real simple to do a quick global search for "page.php" and update the paths you find; unless you have hundreds of files, that should take only a minute or two. 2. If you do have a lot of references to change then that hints at an underlying problem in how you use files for reusable code. Give it a few minutes of thought to see if maybe there is a better way of arranging your code or whatever so that it's accessible in a way that makes more sense. 3. Don't use relative paths. Use an absolute path based on the DOCUMENT_ROOT, as in include $_SERVER["DOCUMENT_ROOT"] . "/pages/page.php";
-
How much troubleshooting have you done on your own? Is the method producing the correct return value/response? Is the AJAX request working as expected? Is the Javascript producing errors?
-
PDO Connect & Session error (pictures of error codes)
requinix replied to LeonLatex's topic in PHP Coding Help
Unfortunately you cut off the screenshot of those error messages just when they were getting to the good parts. Something is including header.php a second time, after the first time when marina.php included it. Fix whatever logic error caused you to decide you had to include it a second time. Then switch to require() instead of include(), -
If you're having problems with some code then you should probably post the code.
-
Fixing values like that in code is not the answer. Where is that "HP OfficeJet Pro:9015e" value coming from in the first place? Why is it not the "HP9015e" value that you actually want?
-
If the date is being printed on the page by your own stuff then you fix that. If you're talking about a date that in the header that the browser adds on its own then you tell the user to change their computer's date and time localization settings to be in the format they want.
- 1 reply
-
- jqprint
- date formate
-
(and 1 more)
Tagged with:
-
Your thread for choosing an editor might not have been the best place to ask for help with some code you've written, don't you think? Now that we're over here, // check if name only contains letters and whitespace if(preg_match('/^\d{21}$/',$TicketNumber)){ 1. That line of code does not check a "name" value, nor does it check if the whatever-value contains letters or whitespace. Letting code comments get out of date with the code they're describing is a great way to confuse yourself and other people. 2. That regular expression only allows for exactly 21 numbers. If you want to allow or require hyphens then you'll have to write something else. So what do you want to do? Require the hyphens? Make them optional? If they're optional, would it be valid for me to enter 1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0-1? What about 12345678901234567890-----------------------------------1? Come up with requirements for this number. Be as precise and explicit as you can be - because the code will reflect that.
-
Is the content of each post dynamic? Are posts for past events supposed to remain viewable?
-
What are these "functions" supposed to do?
-
smtp connection failed error in PHP LIST
requinix replied to keerthi1125's topic in PHP Installation and Configuration
If it can't connect then apparently define('PHPMAILERHOST', 'localhost'); define('PHPMAILERPORT',2500); define('PHPMAILER_SECURE',false); those settings are wrong. Do you really have a mail server running on localhost? And it uses the unusual port 2500? -
You seem really fixated on this "I have to create a stored procedure in my code" thing when you don't have to do that. According to the code you posted, which is a really important point to make so if the code you posted is not what you actually want to do then you need to say something right now (and I'm about 99% sure it is not what you want), DROP PROCEDURE IF EXISTS test1; DELIMITER || CREATE PROCEDURE test1(IN LastID INT(5)) BEGIN SELECT person.RecordID AS PersonID, organization.Name FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 10; SELECT person.RecordID AS PersonID, organization.Name, organization.City, organization.State, organization.Zip FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 25; END || DELIMITER ; I'll say again what I've said before: there is nothing in that query which means you have to create it in your PHP code at the point when you want to call it. There is no information in there that depends on something only the code knows. So do me a favor and try something, okay? Create your "test1" stored procedure manually and remove the stuff about creating it from your code. Now try calling it. You can supply whatever "LastID" parameter you feel like. SQL injection won't be a thing because "LastID' is typed as an integer and SQL injection isn't possible with an integer. Now, you say you want to do something with variable limits. Okay. Have you tried doing that? Because recent MySQL will just let you do that: make the two limit numbers be parameters and specify those variables in the LIMIT clauses. Worst case, your desired stored procedure does not match your posted stored procedure, and the desired stored procedure actually has some aspect that cannot be parameterized. I don't know what it would be. If that was the case then you still (probably) wouldn't create a stored procedure at runtime because that is tied to the answer of a particular question: would your code, the code that hypothetically creates this stored procedure, ever call it multiple times? I don't mean "yes, it would call the procedure every time the code runs". I mean once that procedure was created, would the code that is currently running want to use it multiple times, and would completely separate code anywhere else running shortly after that code also want to use it? I can't imagine why your answer would be anything other than "no", which means you don't need a stored procedure because you can just run those SELECT statements at the time you want them. There's absolutely zero reason to create a stored procedure if it's only going to be used once.
-
Exactly. And in here, DROP PROCEDURE IF EXISTS test1; DELIMITER || CREATE PROCEDURE test1(IN LastID INT(5)) BEGIN SELECT person.RecordID AS PersonID, organization.Name FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 10; SELECT person.RecordID AS PersonID, organization.Name, organization.City, organization.State, organization.Zip FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 25; END || DELIMITER ; there's nothing about it that means it can't be set up ahead of time. You create this stored procedure yourself in the database, preferably under a different name, and then you can use PDO to invoke it. The LastID variable is obviously not known until code wants to call the procedure, but the procedure itself doesn't vary.
-
$row and $row2 both come from while loops. They're only useable within those loops. Your code tries to show reservations for one user, and then booking slots for one reservation. Does that make sense to do? Which user and which reservation are they supposed to show?
-
Any particular reason you want to create stored procedures programmatically? Those are normally things you set up ahead of time, not while the application is running.
-
A 500 happens on the server, not in the browser. Check server log files for a clue what went wrong.
-
Using Let's Encrypt with an Apache proxy to another webserver
requinix replied to NotionCommotion's topic in PHP Coding Help
This external-server-terminates-SSL-and-proxies-internally-without-SSL ("offloading") is a common strategy, especially back in the days when SSL was (or at least people thought it was) computationally expensive. It's not as much now because everything's fast, but the convenience in not having to deploy more certificates across more machines is worthwhile. The only requirement to doing that is securing the network against unwanted servers (ie, MITM attacks), but that really shouldn't be much of a concern. Because if it was a concern, it would really be a concern. Apache shouldn't care... I tend to circumvent problem solving by declaring the problem is moot to begin with. Is the error for every request or intermittent? -
Using Let's Encrypt with an Apache proxy to another webserver
requinix replied to NotionCommotion's topic in PHP Coding Help
Home network? Get rid of HTTPS on the intranet. Have external HTTPS connections pass through the router to the non-containerized server, have that handle all the SSL as a terminator, and then proxy requests to the containerized server's non-SSL on 8080/80. Far simpler. -
Well you're the only one on this site even remotely familiar with the stuff you're working on, so it's going to be hard to find someone who can tell you what you need to do. The problem is specifically this stuff about paying the pilot some $/mi rate, yes? Describe the whole payment thing in as much detail as you can so that hopefully we can catch up near to the knowledge you already have.
-
having ERR_CONNECTION_TIMED_OUT error on my maxcdn bootstrap
requinix replied to sashavalentina's topic in Frameworks
URL is working for me. Maybe your nearby CDN is having connectivity problems? What IP address does maxcdn.bootstrapcdn.com resolve to for you? -
Forget regular expressions. As a human being, how do you look at the contents of that file and decide what to take away from it? Describe the process in detail, step by step. Once you've done that, try expressing the exact same thing in code.
-
Using Let's Encrypt with an Apache proxy to another webserver
requinix replied to NotionCommotion's topic in PHP Coding Help
The only place the Let's Encrypt stuff needs to happen is on the proxying server. Is it containerized too? Because I can't tell what "the docker" is supposed to mean. The servers in the background handling regular requests don't even necessarily need SSL if it's inside your own network (and you trust it's secure against rogue servers or whatever), but otherwise you can use a self-signed cert just for the TLS aspect and make the proxying server ignore the insecurity - or even use a local cert authority, grant certs as needed, and of course install the CA's as a trusted root everywhere. To tell Apache not to proxy a path, normally I would have the virtualhost configuration broken down into <Location>s, but if you don't need that then you can literally tell ProxyPass not to proxy the one path. -
You're not there yet. You can't implement something until you know what it's supposed to be. How those points are dealt with is a business decision. How the airlines recoup money is a business decision. How pilots get paid and at what rate is a business decision. You need answers to these questions - a specification, if you will - before you can move forward.