Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. You can use any IDE for any framework, or just a text editor if you prefer. Personally, I use Eclipse with the PHP Developer Tools plugin.
  2. What if they have Javascript disabled? Then it will always be "off".
  3. So do something like $check = isset($_POST['checkbox']) ? 1 : 0; If the checkbox is checked it will be "1", if not it will be "0".
  4. Why? A checkbox is a boolean - it's either on or it's off. Logically, then, if it is not "checked" it is safe to assume it is "unchecked".
  5. A little more robust pattern: $outputStr = preg_replace('#<br[\s\/]*>#i', "\n", $inputStr); I'm not sure I agree with that assessment, because you would only see the BR tags if he posted the source. In any case, if he wanted BR instead of a newline he can just run nl2br after your function. That way, BRs are preserved but all other HTML is removed.
  6. Pick a framework and go from there. Pretty much all of them are MVC, and well written. For framework newbies I usually recommend CodeIgniter because it has excellent documentation and it's easy to get started with.
  7. You can add a where clause for the first table, and then the JOINed table should only pull results based on what the first table's mpid matches. SELECT t1.title, t2.* FROM table1 AS t1 JOIN table2 AS t2 ON t2.mpid = t1.mpid WHERE t1.mpid = '$mpid'
  8. Something like SELECT t1.title, t2.* FROM table1 AS t1 JOIN table2 AS t2 ON t2.mpid = t1.mpid
  9. I didn't spend too much time on this but you are definitely vulnerable to CSRF attacks and I'm pretty sure SQL injection as well.
  10. I think the best you could do without .htaccess is http://example.com/index.php/product/name/xyz/q/service
  11. Using strip_tags with the second parameter opens up XSS attacks. So if you need to keep certain HTML elements use something else, like HTML Purifier.
  12. The error is because output was sent before a header call, which is logically wrong. Using output buffering means that any output is not output until the end or until you tell it to be output, thereby not outputting anything before headers, thereby masking incorrect code.
  13. May not be the best solution, but this is what I came up with off the top of my head and before my coffee. $where = ''; $age = $_POST['age']; $date = $_POST['date']; $sex = $_POST['sex']; $postalcode = $_POST['postalcode']; if ($age != '') { $where .= " AND age='$age'"; } if ($date != '') { $where .= " OR date='$date'"; } if ($sex != '') { $where .= " AND sex='$sex'"; } if ($postalcode != '') { $where .= " AND postalcode='$postalcode'"; } $where = preg_replace('/^AND|OR/i', '', trim($where));
  14. It's because you are simply appending all of the values to the same variable. You'll have to use an array and loop over it later. $members = array(); while ($row = mysql_fetch_array($get_members)) { $members[] = $row; } foreach($members as $member): ?> <tr> <td><?php echo $member['id'];?></td> <td><?php echo $member['username'];?></td> <td><?php echo $member['email'];?></td> <td><?php echo $member['account_type'];?></td> </tr> <?php endforeach;
  15. You can disagree all you want, that doesn't make it any more correct. It's the same thing as slapping @ on everything. Sure it makes the error go away, but the code is still wrong.
  16. What's worse is he was able to answer the question in only 9 lines of code (one of which is blank), whereas you needed 20. I jest of course - no ill intent meant. But his was more or less pseudo code, and he collapsed the conditionals.
  17. That PECL package does exactly the same thing as any other bbcode library. I already gave you exactly what you asked for. All you have to do is copy and paste it.
  18. Damnit, I just typed 20 lines and you beat me to it kicken.
  19. It's just Javascript. View source and go nuts.
  20. Well there's this. I've never used it so I don't know how well it works. EDIT: I was about to flip complete shit trying to figure out how to properly post code on SO until I figured out you can just hit "ctrl+k" to automatically format it. Other sites (like reddit) unfortunately do not share that, so posting code still sucks.
  21. 1. You need to use backticks, not apostrophes. 2. The keyword is "EXISTS" not "EXIST". DROP TABLE IF EXISTS `airline_survey`
  22. Your tire pressure and oil are related in the sense that they are both considered routine maintenance. The user's email has nothing to do with the password hash. Aside from that, you can't just update the hash without knowing their password.
  23. The cookie has no value, it simply exists. Basically if it exists, don't add a view, if it doesn't exist create it and add a view. How would you differentiate between each post/image they're viewing? Right, I guess I was just thinking of the website itself and not individual pages. There's a lot of different ways to do it, but most of them result in unnecessary database reads/writes. For something simple like viewing a page and adding a view every 24 hours, it's pretty easy. You can just keep an array in a cookie or something with a last_visited timestamp. For something like a forum where it becomes "unread" after other activities, it's a little more complicated.
  24. Because they are completely unrelated and it has no possible benefit.
  25. Along with that, I think you might also be interested in URI routing like I mentioned earlier. Usually it is used for MVC platforms but you can adapt it to anything really. Like I said earlier, CodeIgniter's method is really simple. If you download CodeIgniter go to the system/core/Router.php file and check that out. In particular, the _parse_routes() method. This is where the magic happens, and it's really the only code you need to replicate the process. With CodeIgniter, your route would look like: $route['(:any)'] = 'article/view/$1'; This would basically match anything after your domain and send it to the controller "article" and method "view".
×
×
  • 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.