Jump to content

kicken

Gurus
  • Posts

    4,704
  • Joined

  • Last visited

  • Days Won

    179

Everything posted by kicken

  1. Because your save function defaults to IMAGETYPE_JPEG if you don't pass anything else (which you're not). You need to either change your function to default to the value of $this->image_type, or pass in that value when you call the function.
  2. The way your script is structured, it is not going to stop if your if (strtotime($user_data->lock_date) > $current_gmt_time) condition is true. It will set the output variable but then keep going and continue to process all the subsequent if statements. Assuming your putting in an invalid password rather than the correct one you'll end up triggering that section of code that locks the user out and displays that long message. If you put in the valid password you'd get logged in, even though the user is supposed to be locked out.
  3. The timezone setting in PHP affects how php interprets string dates (eg, strtotime()) and formatting, (eg date()) but has no bearing on the actual numeric timestamp that is returned. That number is always the same for any given time at any location, because it is, by definition, in GMT (# of seconds since 1/1/1970 @ 00:00:00 GMT).
  4. I was looking through the RFC's the other day and spotted the loop+else one. I'm a fan of that one and would like to see it get implemented. I'd like to see it extended a bit too. as it is, it would allow something like: while ($row=$db->fetch()){ echo '...row data...'; } else { echo 'No rows found.'; } The extension I think should go along with it would allow something like: while ($row=$db->fetch()){ echo '...row data...'; } finally { echo '...summary info...'; } else { echo 'No rows found.'; } I'm not sure I'm necessarily happy with the names else and finally as the keywords (can be confusing, multiple ways to interpret it) but I've not thought up anything better.
  5. That's why I've never owned an apple anything for the most part. They are considerably more expensive and do not offer any more useful features compared to a windows or linux PC/Laptop. Back when I was in college I don't recall seeing much for Apple laptops but not many people had a laptop in general either. I've noticed in general though apple laptops seem to be much more popular now, based on what I see at local starbucks'/cafe's and what not. Almost anyone that has a laptop and is not using it for "business" has an Apple. Some business people have had them to but as one might expect they seem to be more in the designer/photography business.
  6. Yea, I was kind of excited when I first read about being able to do that, but the I realized it wasn't really useful because you need the isset/empty checks to prevent the e_notice errors. It'd be nice if they made a special case or something for those so that it would work. $action = isset($_GET['action'])?:'default'; would be nice if it worked.
  7. There's nothing wrong with using absolute paths, just do not hard code them. Either define a variable or a constant and use that as a prefix to relative paths. I personally find them to be easier to use/debug as you are always sure what folder/file your referencing. The HTTP specification says that the argument to a Location: header needs to be a full URI, not a relative path. Most browsers will work with a relative URI however. I've never encountered one that didn't. So it kind of comes down to if you want to follow the spec, or if you want to just make it work. I've created a custom function called DoRedir() that will accept a relative reference, calculate the absolute URI, and then issue the header with the absolute uri. That way I can just use a relative uri throughout the code for easy of use/readability but still keep to the specification.
  8. Most people don't sit there any watch their phone waiting for it to jump back/forward They just see the time when they leave, then check the time when they get there. I remember having to know about timezones as a kid from trying to watch cartoons on TV. They would always advertise shows as being at for example "8/7 central" which was 8 eastern, 7 central. we lived in mountain so it would be 6 our time. I don't watch much TV anymore so I dunno if they still do that. I can't remember hearing them advertise like that anytime recently when I have watched TV. I'm always a bit amazed when people don't seem to know about timezones too. Seems like it should be basic knowlege to me.
  9. I use null for function defaults if there's not something more appropriate as I feel it is more semantically correct. Null represents and unknown value and if someone does not pass an argument to a function then it's value is unknown as it was never specified. In the function body I'll test for that unknown state and handle it appropriately. Sometimes that means trying to calculate/guess the correct value, sometimes it means skipping a particular block of code, sometimes it means other things.
  10. 1) Please use [code][/code] tags when you post your code. 2) You can't mix mysql_* functions and the mysqli object. Not only that, your referencing variables that do not exist. It's as if your just missing a whole portion of the script. You're also making things more complicated than they really need to be. To check a login all you need to do is run a query such as: SELECT UserId FROM users WHERE Username=? AND Password=? If the username and password are correct, it will match and return a row. If it is not correct, you will not get a row. $form_password = md5(md5($password)); $conn = new mysqli('host','username','password', 'database') or die ('Couldnt connect to database'); $stmt = $conn->prepare("SELECT username FROM users WHERE username=? AND password=?"); $stmt->bind_param('ss', $form_username, $form_password); $stmt->execute(); //This is how you get a result. You bind a variable for each column you are returning $stmt->bind_result($dbusername); if ($stmt->fetch()){ //Success! $_SESSION['username']=$dbusername; if($username == "ash") { include("ash.php"); } else if($username == "Bobby") { include("Bobby.php"); } } else { echo ("Incorrect username or password. <br /><a href='webpage'>Click here to try again</a>"); }
  11. Try using imagecopymerge instead of imagecopy. It should have the effect your after. As for why it works on one server but not the other, I don't know. One of them is compiled with the bundled GD library while the other appears to use the system library. There must be some small difference between the two that is causing the different output
  12. You would have to build a query using some CASE statements to assign the right values to the right rows. It is not usually worth the hassle. Avoiding queries in a loop is something aimed more at SELECT and INSERT queries as it is generally easily avoidable and results in a much faster execution time.
  13. You would have to convert the script to use MySQLi or PDO to be able to use prepared statements (which I'd recommend). When using the classic mysql extension you just need to ensure you run your variables through mysql_real_escape_string before using them in a query: $query = mysql_query("SELECT * FROM users WHERE username='".mysql_real_escape_string($username)."' "); If it's available to you (check phpinfo()'s output) I'd recommend using PDO to access your database. Google a few tutorials on it, it is pretty simple to use.
  14. I would probably leave it together but it doesn't mater too much either way really. The only suggestion I give really is to not use chdir() since it might have a negative effect on other areas of your scripts. For instance if you had a script that say manipulated some images that are in the same dir as the script: <?php $im = imagecreatefromjpeg("somefile.jpg"); log_action("opened first file"); $im2 = imagecreatefromjpeg("someotherfile.jpg"); log_action("Opened second file"); The second imagecreatefromjpeg would fail because your log function changed the working directory to where your logs are rather than where the script is.
  15. <?php function log_action($action, $message="") { $dt = time(); $datetime = strftime("%m-%d-%Y %I:%M:%S", $dt); $date = strftime("%m-%d-%Y", $dt); $dirname = strftime("%m-%Y", $dt); $logfile = SITE_ROOT.DS.'logs'.DS.$dirname.DS."logfile_".$date.".txt"; $data = strftime("%m-%d-%Y %I:%M:%S", $dt)." | Login: {$message} logged in.\r\n"; chdir(SITE_ROOT.DS.'logs'); if(!is_dir($dirname)) { mkdir(SITE_ROOT.DS.'logs'.DS.$dirname); if(file_put_contents($logfile, $data, FILE_APPEND)) { } else { echo "logfile could not be accessed"; } } return $message; } So after a little re-formatting so it is readable, do you see what the problem is now? Your only logging something if the file doesn't exist. Once you've created it, your function does nothing.
  16. The end function accepts an array reference because it modifies the array's internal pointer as part of it's work. By passing it the result of explode your not passing a reference value like it expects. To remove the error you need to use a variable as the argument to end: $page = explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF']); $page = substr(end($page), 0, -4);
  17. I'm not really sure how one would explain it any better than the wiki page, they do a pretty good job of explaining how it works, with plenty of examples. Basically, as you (should) know, all data at the core is just a string of 1 and 0 bits. So a number like 16 is represented as 00010000. The number 1 is represented as 00000001. What & does is examine each of those bits and generates a third bit pattern (new data) based on the other two. For each bit position, it examines the value at that point in the two input numbers. If they are both 1, the output pattern has a 1, otherwise it has a 0. So given 16 & 1: 00010000 & 00000001 ---------------- 00000000 The reason this works for identifying if a number is even or odd is because in binary form, all even numbers have a 0 in the right-most bit, and all odd numbers have a 1 there. By applying &1 to a number you are able to test if that bit is set to 1 or 0, thus identifying if it is odd or even.
  18. I'm assuming you mean converting all your numeric constants from 9876 (decimal) to 0x2694 (hex) or 023224 (octal) notation. If that's what you mean then no, your script will not run any faster as it all gets compiled down to the same stuff anyway. All you'd do with a change like that is make your script harder to read/debug. /agree'ed @op you need to learn to ask a better question rather than just be an ass to people.
  19. It's nice to have if you need to do a cleanup, but don't necessarily want to catch exceptions (let them be handled higher up or something). Sure you can work around it by just catching and re-throwing but it's less than ideal imo. try { //something making $tmpfile on disk } finally { unlink($tmpfile); } is nicer / less bug prone than try { //something ///.... unlink($tmpfile); } catch (Exception $e){ unlink($tmpfile); throw $e; } I've had on a few instances small bugs due to a change in cleanup code that got made in one spot but not the other. Being about to keep it in just one area would prevent that.
  20. I run an AMD FX6100 on my desktop and have Folding@home going so it is at 100% load 24/7. The CPU runs around 52C or so, not too bad really. I wouldn't be worried about it til probably closer to 65C. I've never really bothered to check my laptops but I know my old toshiba would get hot enough that you you couldn't set it on your lap or you'd probably burn yourself. It worked fine though, never had issues with stability. My newer asus hardly gets hot at all, even under load.
  21. Yea, I've run across a few forms that put them below in a list like that, it is fairly annoying imo and I would not like that. Devshed's method is not too bad but if there are a lot of agree's it can get to taking up a bit of space. I think something small and simple would be best. Something along the lines of X people agree with this post. Hovering/Clicking it could optionally open something with details about who agreed with it.
  22. Have you checked the Power Supply to make sure it's working properly? If it's not providing enough power or unstable power it might be causing issues, any may just ruin any new equipment you might get later on.
  23. Use [m=curl]cURL[/m] to send your HTTP requests. Do that within a loop to send multiple requests. In pseudo-code: foreach ($requestToBeMade as $args){ runRequestWithCurl($args) }
  24. This topic has been moved to Editor Help (Dreamweaver, Zend, etc). http://forums.phpfreaks.com/index.php?topic=363174.0
  25. Based on the error I am going to guess that the value has to be a constant integer and not a variable. That's not the only problem you have though. You can't parameterize a table name like that. Your procedure will try and alter quite literally the table called `tableName` and not whatever you pass in as that parameter. Why are you trying to create this procedure anyway? It's only a single line of SQL to do what you want to do, the procedure does not really save you anything. I'd also question why your wanting to change the auto-increment value in the first place.
×
×
  • 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.