Leaderboard
Popular Content
Showing content with the highest reputation since 10/21/2024 in all areas
-
It might work a little more cleanly in PHPStorm, but when I tried it in VS Code, I found it much more complicated to try to select text or read through code when the editor was injecting those things into the view. Maybe if they weren't inline, though I can't imagine how not, they might be nicer for me... But I'm also a proponent of the idea that you should be able to tell what the parameter is, be that through a variable name or an obvious literal value (or a constant...), and if you can't tell then you should do something about that. // this is obvious on what the parameters are password_verify($password, $hashedPassword) // this is not password_verify($value, $row[1])2 points
-
The closing </option> tag on the $ThisYear output is missing the closing >, so the following markup is broken. check the 'view source' of the output in your browser.1 point
-
So you want something like this: foreach ($tokenArr as $val) { //... current code // bottom of foreach loop if ($errMess !== '') { break; } }1 point
-
(foreach isn't a function) It'd be easier to show if you posted the rest of the code instead of just a couple lines, but basically, replace the while loop with a foreach loop, and then add into it a little logic for $errMess. If that still doesn't make sense, post what you came up with (as well as the original code) so we can see what happened and not have to guess about it.1 point
-
If you're asking, does that mean you tried what I said and couldn't find an answer and decided to not mention that? Or does it mean you saw my answer and decided you didn't like it and wanted something else instead?1 point
-
You need to give is some information as to what the actual issue is. Otherwise nobody can or will help you. Another good tip is to encase your code into the <> tag so it shows like this: <?php // database.php require_once __DIR__ . '/config.php'; // Ensure this path correctly points to config.php /** * Establish a new database connection. * * @return mysqli The MySQLi database connection object. * @throws Exception if the connection fails. */ function db_connect() { // Use MySQLi to connect to the database $connection = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Check if the connection was successful if ($connection->connect_error) { error_log("Database connection failed: " . $connection->connect_error); die("Database connection failed. Please check the error log for details."); } // Set the character set to UTF-8 for proper handling of characters if (!$connection->set_charset("utf8mb4")) { error_log("Error setting character set utf8mb4: " . $connection->error); } return $connection; } /** * Close an existing database connection. * * @param mysqli|null $connection The connection object to close. * @return void */ function db_disconnect($connection) { if ($connection instanceof mysqli) { $connection->close(); } } // Establish a connection and store it in the variable $db for use later $db = db_connect(); // You can now use $db for your database queries It makes it easier to read. Also, no need for this: if ($connection instanceof mysqli) { $connection->close(); } PHP automatically closes connections. Okay, your turn1 point
-
When storing dates in database always use yyyy-mm-dd format, and store in a DATE type column (or date time type if you need the time too. See https://forums.phpfreaks.com/topic/325220-date-help/?do=findComment&comment=16388851 point
-
Outside the webroot - whether that's called www/ or http/. The whole point is that you don't want the casual browser to be able to access the files directly, only php can access them. So from within the webroot you'll use something along the lines of include_once('../includes/myPhpFile.php'); The contents of myPhpFile are now accessible from the calling script.1 point
-
I'm not well versed in using cURL, but based on what you provided previously your call to the URL you are using is returning the response: 301 error "Permanently Moved" But, you expect to be getting the JSON encoded output for the $allowed_domains array you are creating. I would assume you have tested the url in a browser and verified you are seeing the JSON content? If not, start there. If the content is correct when access via a browser then my best guess is that the web server maybe has some logic to detect programmatic access to pages and is blocking it. I'm pretty sure I've seen something like that before. But your issue has noting to do with the error you first reported. You need to figure out why your cURL request is not retrieving the JSON content you think it should be returning. Although, this is a good opportunity to add additional error handling to your code to cover a scenario where the cURL request doesn't fail, but does not return contents you expect.1 point
-
the curl code is making a http(s) request to the URL, just like a browser would. because it is to a .php page, the php code is being executed on the target server and what you get back is whatever that page outputs. you do not get the raw php code. because you are trying to transfer data, i recommend that you use JSON and use echo json_encode($domains_content); in the domains.php code, then after you successfully receive that JSON string from the curl call, you can use json_decode() on it to get the array of data.1 point
-
1 point
-
I like to think of a framework as literally that - a frame you use to build your project on. So instead of having to write your database connection, display, and interconnecting code for each project you can concentrate on the actual functional logic for that specific project. Use the framework-provided database connection to get the data, write the templates to display the data (but don't worry about actually rendering the templates), and auto load the extra files you'll need to process the data the user sends to you, adjust and amend it as necessary, and send that data to the template that will render it. Basically, frameworks at their heart do the boring and repetitive stuff for you. Beyond that I think there's been a slight misunderstanding when you're talking about "controls". Most modern frameworks (Laravel, CodeIgniter, and CakePHP most notably) are based on the MVC design pattern wherein there are Models, Views, and Controllers. Controllers basically ingest the data the user submits, retrieves any additional data your system needs from the Models (and/or saves data via the Models), works on that data as necessary, and then sends that resulting data to be rendered in the View. So think of it like Models interact directly with the database, Views interact directly with the browser, and Controllers dictate the actual function of your system by interacting with the Models and Views.1 point
-
Misunderstood. Frameworks are a bunch of code that other people wrote to do stuff. Using them saves you the time of having to write your own bunch of code to do stuff. They do so much stuff that the intention is you take what they provide as a foundation and then add what you want. There's also libraries, which are a bunch of code that other people wrote to do stuff that saves you the time of having to write your own code to do stuff, but they're much smaller in scope than frameworks. They're basically about solving small individual problems, so using libraries means you don't have to solve those same problems yourself and you can focus on more important issues. There is overlap between frameworks and libraries. The distinction is in how they get used: are you taking a bunch of stuff and adding more, or are you using stuff to create other separate stuff? VS Code and Dreamweaver (if anyone still uses that) are "integrated development environments", but everybody just calls them IDEs. IDEs are glorified text editors, in that they let you type stuff into a text file just like any simple text editor does, but IDEs also have tons of features dedicated to dealing with code and so are much nicer to use than text editors. Like they can be aware of language syntax nuances and tell you when you wrote something wrong, while text editors might be able to do a little bit of that but would care more about checking your spelling. I don't like "template" as a metaphor. A template is about taking something and supplying a few bits here and there and you're done. You go to some blog creator website (coughwordpress) and they'll give you a template for a site: you set a name, colors, images, whatever, but all you're doing is customizing the same basic thing that everybody else is using. This forum is basically a template because we installed Invision Power Board and customized it a bunch. A framework is about you having a starting point for actually building something - not just customizing. You write code to do things, you implement features, you make decisions about how things work, and so on. Making a complicated website involves many different things, and frameworks have a lot of that designed for you so you don't have to make it all yourself. Where are you seeing "controls"? That typically means things like text boxes and buttons and links, like right now I'm typing into a "textarea" control that has a bunch of formatting button controls at the top and a "submit" button control below it. But people don't normally use the word "control" much these days. I think maybe you shouldn't worry much about what a control is. It's such a generic term that it doesn't really say much. "Text box" and "button" and "link" are specific types of controls, and talking about those is much easier (but also kinda off-topic from what we're talking about now).1 point
This leaderboard is set to New York/GMT-05:00