Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by requinix

  1. Then you changed something else in that class, because it wasn't doing this before. Fix the syntax error and try again.
  2. Unfortunately I don't really have tips or tricks to pass along. I can mention phptherightway.com as a good resource, but it isn't totally comprehensive. For now, make sure you avoid articles and tutorials from some random person's blog and instead try to hit up the more reputable sites that perhaps you've already heard of before. catch (PDOException $e) { /* If there is a PDO exception, throw a standard exception */ throw new Exception('Database query error'); } Don't do that either. You're taking a perfectly good exception and then discarding everything it has to offer and replacing it with a mere "Database query error". Remove the whole try/catch and see what happens.
  3. Have you considered trying to use mysqli_error() to find out what went wrong?
  4. $user->password = base64_encode($_POST['password']); $user->password = base64_encode(isset($_GET['password']) ? $_GET['password'] : die()); No. No base64_encode. Don't do that. $_GET['password'] That is incredibly bad. Do not put the password in the URL. That's... I don't know why this code even exists. Make the problem go away by changing the form to use method=post. I really, really shouldn't have to say that.
  5. I see three blue colors: navy blue with writing, light blue with writing, and the dark blue/gray with images. I can't figure what you're describing according to that. I'm guessing that you want to have text + image / image + text alternating on desktop and then just text + image on mobile. Is that it? Rearrange everything in the markup so that it is correct: text first, image second. Desktop is where you should be making it read backwards. Do that by using looking into whatever options your CSS framework gives you regarding repositioning inside its grid system; if there isn't anything then use order.
  6. Are you sure you need to do this from PHP? There should be a client-side API that embeds some Twitter information if you give it a username.
  7. You have a directory called ".htpasswds" that already exists? Then there is some mechanism already in place to do what I'm talking about. Do you see anything about password protecting directories in CPanel?
  8. Yes, it's true that we do like quick answers, but only to quick questions: very often the background information is not just useful but even significant and can affect what advice should be given. Your criteria are that you have an authentication system that is applied for individual directories where one username and password (each) is sufficient, and that you are using Apache. Right? https://cwiki.apache.org/confluence/display/HTTPD/PasswordBasicAuth You can set up a single file containing all the information for all the directories, each one with a different "username", then instead of Require-ing any valid user, you require the specific "username" for that directory.
  9. So the answer to the question I asked is "no, I do not want a different username/password for each person". Let's try another one and see if we can reach the answer with fewer posts this time: Are you using Apache?
  10. It will be either a string or an array. If you want to protect against that, a simple is_string() will suffice.
  11. Thanks for making an account here and notifying us that you had a question and asked it somewhere else. We'll be watching that carefully.
  12. If it's a string then it won't be ===false. Because it's a string. Same for ===null. Maybe what you're looking for is isset($_POST["whatever"]) && trim($_POST["whatever"]) != ""
  13. You have two forms, one to let you open the file and another to let you save contents to the file. The first form has the filename, the second form has the file contents. The question for you is: why would the second form also have the filename? You didn't put a filename in there. It's just the textarea. Your browser isn't going to take the filename from the first form and include it in the second form's data. So put both into one form. Filename and file contents. Put the two buttons into the form too. Since it's just the one form now, you'll need a different method to determine what your code should do. Solve that by giving a name to your button, and you might as well use the same name for both since the user can only click one of them, then checking (a) if $_POST has that button and (b) what value it has. Side note: <button> buttons are better than <input> buttons. <button type="submit" name="action" value="open">Open</button> But before you do any of this, open up your php.ini (should be where you installed PHP), find the error_reporting and display_errors settings (the real settings, not the ones that are part of the documentation inside the file), and set them to error_reporting = -1 display_errors = on Then restart your web server and try running your code as it is right now. You should see a number of error messages. Do the changes I said above and run it all, then if you still see errors you need to go in and start fixing them.
  14. Yes, a different username and password for the different directories, but do you also need a different username and password for each person? If so, how many people and do you need a full user system where they can log in and change passwords and whatever, or can you simply assign them passwords and that's the end of it?
  15. What do you mean by "save the changes"? What is supposed to be saved? Where?
  16. I don't. You have no business trying something like installing software on a server. But I can't stop you. So if you're going to anyway, don't do anything except what the installation guides tell you to do. Don't touch files, don't go snooping around for stuff you won't understand, just forget it all exists and follow the steps to install. You probably messed something up. Delete all the files and start over again.
  17. Moved to MySQL. You address this problem by refactoring your application so that the problem doesn't exist in the first place. Storing the platforms as individual columns is not a good idea. For one, it puts you in the situation you're in now. For two, it makes it harder to support whatever platform will be popular next year. You can generalize each platform as having a URL to the user's page. Probably don't need much more than that. Create a table that lists all the platforms you support, with an ID (like every table should have) and a nice name. Want to support a new platform? Add a row. Then create a new table that contains a row for each combination of user and platform URL; if the user has a Facebook and a YouTube page then there will be two rows in this table. Add to that this concept of a number of followers. That's two new columns in the second table: one for the minimum and one for the maximum numbers. Or whatever. Then querying is easy.
  18. If you process credit cards then you can find out whether the charge was successful immediately. No problem. Some other payment methods are instant like that. For payment methods that are not instant then you need to tap into some mechanism where they notify your site of a change. For example, PayPal has IPN which pings your site when activity happens with a transaction. You thank the user for the payment and then wait for the IPN message that confirms the payment happened - it typically happens within seconds - before you give the user access.
  19. But here's the question: what is that expression going to evaluate to? 2 or 4? The problem is the last line. It uses $i++ and $i in one statement, and that's a no-no. Did you see when I mentioned sequence points earlier? Look into it.
  20. Obviously it isn't real code someone would write. Not all of it. But that last line, that's something one could reasonably write in some circumstance.
  21. Yes, that describes how one pre-increment operation works on a variable. That page does not explain how one or more pre- or post-increment operators on the same variable work when in the same expression. The concept is called a sequence point. Look into it: most everything you'll find will talk about C/C++, but it applies to PHP as well.
  22. Not necessarily. PHP makes no promise that the $i on the right happens before or after the ++$i on the left.
  • 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.