Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Yeah, then you're going to want to do what Pikachu2000 suggested. For example: $data = array(); $result = mysql_query('...'); while($row = mysql_fetch_assoc($result)) { $data[$row['id']] = $row; } Then you'll be able to access data later on like so: echo $data[5]['some_field']; // outputs the value of 'some_field' column that corresponds to a row with the column id equal to 5
  2. What you're dealing with is portability. There are many techniques that you can use to ensure that you code is portable and works on all systems that you'll be deploying it on. Some things are very simple rules of thumb, and others are more complicated. One example of a simple rule you should always follow is never use short tags (<? ?>). Using the full tags (<?php ?>) ensures that you code will still work on PHP installs that have short tags disabled. As new versions are released they offer new optimizations, features, changes etc.. You can use phpversion to check the version of PHP, or a more specific extension, that is being run. From this you can decide what your code will do; For example, if you decide that you want to make your code PHP 4 compatible and you're using OOP you'll have to write an alternative solution that doesn't use the OOP features that weren't introduced until PHP 5 (e.g. the public/private/protected visibility keywords). While you're writing your code you should make sure that the functions you're using all available in the versions of PHP that you hope to support; the PHP manual does a great job of telling you this. If they're not you need to make sure to provide an alternative solution that will be supported.
  3. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=307535.0
  4. You can try to prove that P = NP and compete with Deolalikar who is trying to prove that P != NP Things aren't looking so good for him, http://www.newscientist.com/article/dn19313-tide-turns-against-milliondollar-maths-proof.html
  5. You're not going to get any help without telling us what's wrong...
  6. $db = new mysql; $db->connect(); $result = $db->query("SELECT * FROM Attributes"); while($row = $db->fetch($result)) { echo $row['Attribute']."<br>"; }
  7. I think you mean: if ( strpos(strtoupper($agent), 'MSIE') !== false) {
  8. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=307477.0
  9. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=307426.0
  10. That doesn't really help. Can you post your entire index page up to the point where you're calling the function? There could also be a problem somewhere else in your functions.php file so post the full source to that please.
  11. You're just asking if you think it would be a good idea to have the option to disable it? If so then yes that would be a good idea.
  12. Make sure the file trying to delete the other file has permission.
  13. Your path is coming out looking like ../files/"somefile" with the quotes in the name. Try this: if (!unlink('../files/'.$fil))
  14. Did you even try what I posted? It should work as long as the path is correct... mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error()); mysql_select_db($database) or die("Can not select the database: ".mysql_error()); if(!isset($_GET['id'] || empty($_GET['id']){ die("Please select your image!"); }else{ $query = mysql_query("SELECT pics FROM tbl_images WHERE id='".$_GET['id']."'"); $row = mysql_fetch_array($query); readfile("pics/" . $row['image']); header('Content-type: image/jpeg'); } If you're uploading images with formats other than jpeg you'll need to adjust the header accordingly.
  15. Sounds like you're looking for a JavaScript plugin. Here's a good one: http://acko.net/dev/farbtastic
  16. There's a few things wrong with that script. First off, when posting code please use [php] or [code] tags; I've edited them in for you this time. Setting $id and then checking if it's set right after is pointless, that will always be true. The advantage of isset is that you can check if a variable is set without it throwing an error message. If you want to directly output the image to the browser then you must output the contents of the image, not the path to the image. You code can be rewritten: mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error()); mysql_select_db($database) or die("Can not select the database: ".mysql_error()); if(!isset($_GET['id'] || empty($_GET['id']){ die("Please select your image!"); }else{ $query = mysql_query("SELECT pics FROM tbl_images WHERE id='".$_GET['id']."'"); $row = mysql_fetch_array($query); readfile($row['image']); header('Content-type: image/jpg'); } I would also suggest that your code more fault safe and secure by 1. escaping the input and 2. Making sure that a row was found before you attempt to use one.
  17. How is that not a solution? $_POST['title'] = mysql_real_escape_string($_POST['title']); // Make sure you do this before the loop ... $update_embed = mysql_real_escape_string($update_embed); $query4 = 'UPDATE movies SET embed = \''.$updated_embed. ',\' where title =\''.$_POST['title'].'\' ';
  18. You should be using mysql_real_escape_string only on the variables you're inserting into the query. In this case that means $updated_embed and $_POST['title'].
  19. $_POST['embed'] must be an array. What does your form look like?
  20. Just because you set the timeouts to fire at the same time doesn't mean the functions will run concurrently. It will still process one after another.
  21. Run the data through mysql_real_escape_string before passing it into the query.
  22. This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=307261.0
×
×
  • 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.