-
Posts
22 -
Joined
-
Last visited
Everything posted by Andou
-
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?
-
Oops! I definitely have a lot more to learn. Great comparison, though.
-
Fixing Issues with PHP, AJAX, and MySQL Data Insertion
Andou replied to Olumide's topic in PHP Coding Help
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. -
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.
-
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.
-
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.
-
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.)
-
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.
-
How to transfer data from one database to another.
Andou replied to KangaBytes's topic in MySQL Help
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? -
Whats error are you getting?
-
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.
-
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.
-
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.
-
Welcome to PHPFreaks! Nice to meet another fellow newcomer.
-
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.
-
PHP Notice: Undefined index: data in.. repeated log errors
Andou replied to myphp's topic in PHP Coding Help
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. -
PHP Notice: Undefined index: data in.. repeated log errors
Andou replied to myphp's topic in PHP Coding Help
Yes, put it in the same file. Do you have an opening <?php tag at the beginning of the file? -
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.
-
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.
-
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.
-
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?
-
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.
-
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.
-
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.