Jump to content

trq

Staff Alumni
  • Posts

    30,999
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by trq

  1. You can get the contents of a web page using file_get_contents then parse it for the title using preg_match.
  2. You shouldn't be relying on the primary key to determine the display order of your data, create another column and sort by that. Either that, or simply select and dsiplay your data using 'ORDER BY id DESC'.
  3. You are sending the data via POST yet looking for it within the $_GET array.
  4. $str1 = "sam"; $str2 = "paul"; foreach ($name as $key => $value) { if ($value == $str1) { $name[$key] = $str2; } } You could also use array_map.
  5. If $last starts off less then $first your loop will never iterate. Look at your logic.
  6. Considering that string is serialized data. <?php $numbers = '{"val_a":7,"val_b":5,"val_c":4,"val_d":6,"val_e":5}'; $array = unserialize($numbers); echo array_sum($array); ?>
  7. Your question isn't php related. You use an Apache module called mod_rewrite to rewrite urls from the form www.example.com/page.php/id/123 back to www.example.com/page.php?id=123, php then receives this data in its usual manner. We have a mod_rewrite board here.
  8. http://developers.facebook.com/docs/
  9. You never actually write anything to the file. All you do is open and close it. See fwrite.
  10. A simple.. UPDATE users SET `password` = MD5(`password`); Will do.
  11. You are sending the request via GET, yet looking within the $_POST array for your data.
  12. 1) Ive not really found too many but have read several books including 'PHP 5 Objects, Patterns and Practice'. I use OOP for pretty much every project these days. 2) I'm not exactly sure what your getting at but it would seem to me a User object might be best tied to php sessions. 3) You should only expose enough of a classes API to make it useful. The inner working should not be known / accessible to the outside. 4) None. If that is all you are doing. Generally however classes are designed to work make functions with a common set of data. Functions alone do not relate to each other in the same way.
  13. There are numerous problems with the script. Firstly, simply filtering data out of a users input without telling them is a bad idea. What is you end up changing there password? They would no longer be able to use it to login. Secondly, all inputted data need to go through mysql_real_escape_string to make it safe for using within a database query. Thirdly, your executing two SELECT queries against the same table, this could easily be done with one query. Finally, your INSERT statement has a wildcard in it. This is incorrect syntax.
  14. You haven't defined $username anywhere. <?php session_start(); $_SESSION['username'] = $_POST['username'];
  15. Because $_REQUEST['option'] isn't defined at the time. Your entire switch should be in between a check for its existence. if (isset($_REQUEST['option'])) { switch ($_REQUEST['option']) { // rest of code } }
  16. There is no guarantee that a user will be able to make a request via http using get_file_contents() as it relies completely on there servers allow_url_fopen settings.
  17. I would say you have magic quotes enabled. You can check this using get_magic_quotes_gpc then remove them using stripslashes. eg; if (get_magic_quotes_gpc()) { $content = stripslashes($_POST['content']); } else { $content = $_POST['content']; }
  18. We are not here to write code for people. Post your attempt and a description of your problem.
  19. I'm not sure it can be breaking that many rules as languages that are better suited to OOP then php (eg Ruby and Python) allow similar approaches within there design. PHP however doesn't, and I'm really not that sure the approach you are taking with php is particularly well thought out, designed, or what that feature was provided to actually do.
  20. $normal = 'http://www.mysite.com/gallery/normal_img1.jpg'; $thumb = str_replace('normal', 'thumb', $normal);
×
×
  • 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.