Jump to content

Andou

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by Andou

  1. What's a page (in this context)? Is it a webpage or something else? Is it one page or several? If it's one page, it should be easy enough to whip up a one-off. If it's several, how are you planning on storing the links to the pages? Database, array, or something else? How do you want to find the lowest price? Do you want to save a copy of the entire HTML and sort through it until you find the price? Or do you want to find the right element and pinpoint it from there? Both options work. How are you "adding the product"? Are you inserting the details into a database or saving the HTML to copy it over?
  2. Oops! I definitely have a lot more to learn. Great comparison, though.
  3. Considering around 77.5% of websites are using PHP (down 1%, but still way more than half), I don't believe them. I compare it to the concept of inertia - things that are spinning don't want to stop spinning.
  4. What I do is add <?php ini_set('display_errors', '1'); ini_set('display_startup_errors', '1'); error_reporting(E_ALL); to the top of the file. This lets me see everything. It's the same thing as what requinix suggests, just doing it using code instead.
  5. As far as it could be an error, try adding ini_set('display_errors', '1'); and error_reporting(E_ALL); at the top of your file. Also, regex101.com is a great website for debugging why the regex isn't working. It also has good documentation.
  6. I'll add that var_dump helps a lot when dealing with arrays. I always use <?php echo '<pre>' . var_dump($array); . '</pre>; so I can see what's going on with it.
  7. Glad to hear it! Sometimes, Google-Fu and putting stuff in quotes is the best way to solve problems. (By the way, if it's solved, there's a button you can click somewhere on the thread to mark it as solved.)
  8. A couple of things. First, put error_reporting(E_ALL); and ini_set('display_errors' 1); at the top of the file so we can see the errors. Second, I googled it and apparently calling "json_last_error()" after json_encode() may fix the issue if it gives you the error code. Try it, and if it still doesn't work, I'll see what else can be done.
  9. I don't know if the OP will respond, but just in case: have you done a mysql dump or gotten the issue sorted out yet?
  10. If I were you, I would have it so you upload a text file, like so (almost like pseudocode): BEGIN PAGE BEGIN TITLE = "My Web Page" END TITLE BEGIN BODY COMMENT "Your content goes here" END COMMENT END BODY END PAGE And then write a parser to detect "BEGIN" and "END" and replace that with the relevant html tag (i.e. "BEGIN TITLE" = <title>, "END TITLE" = </title>). This is what most template engines do, so I wouldn't necessarily do it myself or reinvent the wheel. (You would also be writing your own template language a la the parser, so I wouldn't do this unless I had to. Take it as a proof-of-concept.) * * * So, assuming you'd do it your way, am I correct in assuming this is how it works: You have a site. You upload a text file to the site. Your PHP code scans the text file and outputs HTML from it. But requinix is correct, we really do need a little more information. Is there any reason you can't use PHP itself to build the site? * * * edit: As it turns out, I put your query in google and StackOverflow has a solution.
  11. Dunno how helpful this is, but if I were you I would put all the relevant PHP code before the HTML so I didn't keep breaking in and out of it. I suppose the reason why the form is showing on the next page is that it's in the HTML, but someone with more experience may have a better solution.
  12. I'm pretty sure OP is asking what's wrong. A couple of things I noticed: You have no question (so far, anyway). I'm not a mind reader. I'd be happy to help, but I need to know what you're asking. Are you asking for help to fix an error? Or something else? I see that from the variable name alone, this is (probably) a school project. However, this leads me onto point #3, which is... Just because it is a school project does not mean you should forsake security. I see that your $sql variable holds a query vulnerable to SQL injection. If you like, read up on prepared statements or PDO. "passowrd" should probably be "password". You have no opening <?php tag. Quoting from @ginerjm's excellent advice, you should always put "error_reporting(E_ALL);" and "ini_set('display_errors', '1');" on top of the file so you can see what goes wrong. That's all off the top of my head, if I think anything else is wrong I'll come back to it. * * * edit: Oh, and yes, even though this is just a school project, keeping passwords and security information in the source code itself is a security hole. Assume, for instance, the site gets hacked. Now they have access to the DB itself.
  13. Andou

    New member

    Welcome to PHPFreaks! Nice to meet another fellow newcomer.
  14. Answering this a couple of days late in the hopes it helps someone - if you run into a situation like this, either stick "alert-success" in the div class itself or use a <style> tag, if it's only for that one section alone. Also, in the future if you run into issues and need our help, it helps if you put error_reporting(E_ALL); ini_set('display_errors', '1'); right after the opening <?php tag, so we can see what's going on. Glad to see you found a solution.
  15. Pretty sure ginerjm got to it before I did, but just in case, make sure you have <?php error_reporting(E_ALL); ini_set('display_errors', '1'); at the top of module/botblocker.php.
  16. Yes, put it in the same file. Do you have an opening <?php tag at the beginning of the file?
  17. I can't really add on to requinix and gizmola's excellent answers. Do note that you don't have to use phpmailer - its documentation also has examples from SwiftMailer and the Mail component from Laminas. Since I don't have a server with me right now, I found some examples from phpmailer's github repository. Even if you're not entirely sure what to do, I recommend going through the examples (at least) to see what needs to be done.
  18. Andou

    Greetings!

    https://symfony.com/doc/current/doctrine.html "Symfony provides all the tools you need to use databases in your applications thanks to Doctrine, the best set of PHP libraries to work with databases. These tools support relational databases like MySQL and PostgreSQL and also NoSQL databases like MongoDB." I think it's just a case of learning and figuring it out.
  19. Andou

    Greetings!

    Symfony has a free book (which you can also buy if you really want). That's how I tried to learn it, anyway. There's also SymfonyCasts (which are video tutorials), really nice but you do have to pay for (most of) them.
  20. I agree as much as the next person and yeah, I would have taken it the same way, but Nolan isn't worth fighting over. Let's focus on the people who actually do want to help you, me included. How's the website going, by the way? Did you take the frontend-backend separation path?
  21. Are you getting an error? If so, what error do you get when you run the code? What appears as the error on the page? And while you're add it, add error_reporting(E_ALL); ini_set('display_errors', '1'); to the top of the file so you can see the errors that appear. (Assuming you fix the errors, you can comment out those two lines by putting a "//" before them.) edit: It's fine to use ChatGPT for getting snippets of code (I wouldn't do it, but it's not like it's illegal or anything) but even though you say you aren't a programmer, you should at least try to look at the code and determine what it does.
  22. I'd say you should at least give it a shot. I'd probably do it the OOP way if I needed an API, too. Of course, it probably depends on complexity. If I needed an API to only do one or two things, I'll just use POP (because it's dead simple) and then clean up my code. On the other hand, if I needed an API to do a lot of things, I'd probably take the time to plan it out in an OOP fashion and get started based on that.
  23. gizmola said it better than I could, but how you should do it is by googling "PHP The Right Way" and scroll down until you see PDO. Or just check the manual. You can, in fact, learn PDO with a budget of £0 (or $0, as the case may be). I myself am trying to learn it right now.
  24. Also, while it doesn't affect readability (as far as I can read it, anyway), in the future you should probably use the Code button in the editor to show the code. It makes it easier to scroll down and see what's going on.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.