Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. Hi Rocky48, I have to agree with ch0cu3r & ginerjm. I don't think anyone is being condescending. To clarify things: The mysql_ api is deprecated. mysqli_ is not. PDO and mysqli are two different ways to stay current with mysql use. You do not have to change your code to use PDO to avoid the deprecation. The mysqli api has both an "object oriented" interface, and a procedural (function based) interface. It also has a substantial number of "alias" functions. Unfortunately, the mysqli devs went a bit overboard with all the aliasing and eventually the PHP community came to the conclusion that they should clean things up by removing a bunch of the aliases, and that is what you have hit upon in the "warnings" you are seeing for your current mysqli based code. You could remedy this with the least pain and suffering by simply looking at the page ch0cu3r linked, and simply changing the deprecated name of the function(s) you used to the one(s) it is aliasing. With that said, if you really want to move to PDO that is fine, but please understand that people were simply trying to clarify things for you, and address what clearly were some unfounded assumptions about the warnings you received. Mysqli_ is not going anywhere, and you don't have to abandon it for PDO!
  2. All of the above. In general terms, the most important thing is to make sites. You will learn more by doing than all the other methods combined.
  3. Registration vs. login and password resend are a couple of different issues. I can't explain why you couldn't login. Email sending is somewhere between iffy and non-existant. I'll put it on my list to poke into when I have a moment. If mail is being sent out I'd expect that many systems would see it as spam. I really do appreciate these reports however. It takes a village
  4. Visited parts of Maine in my youth -- beautiful state. Glad to have you here.
  5. Did you check the permissions for files in the upload directory matching the spec that is being unlinked? Is there possibly a file there that has different perms, such that it can't be removed? Are warnings turned on, and are any warnings being generated? There are many things that could be going wrong, but if I understand you correctly, this code works for other users, just not for you? For that reason, you want to check your assumptions by making a test account or several and determining if it is local to your workstation environment or your specific user. What else could be different about your account? What is the nature of $user->userID? Is this a number or a string?
  6. PHP has date/datetime classes. They literally allow for any type of format you want. I'd suggest you start with those because they also provide the ability to do date arithmetic. With that said, there seems to be no rhyme or reason behind your examples. What are these dates and where do they come from? There is no way to show you a loop when we don't know what you're looping through!
  7. How many more posts will you make without using code tags for readability of your code? The first reply from scootstah used them. One would think that would be a hint you might look into.
  8. Thanks for taking the time to let us know. We'll look into this issue and see if we can figure it out.
  9. I think you need to elaborate on your issue. Is it that you are adding/removing files and the list on your page is not being updated? or The contents of the individual files are not being updated?
  10. Unfortunately cron jobs are fairly archaic and opaque. You could create the illusion of a schedule in javascript and present countdown timers, so long as you either codify the cron schedule, or read it and parse it, however given the use of directories like cron.daily/weekly/hourly and the possibility of having many different users owning cron jobs, there is nothing out there that already does this for you that I am aware of. If there are cronjobs installed you can get the raw crontab listing using: crontab -l But then you get something like this: * * * * * /var/www/foo/utility/something.sh params You'd be re-wrting the cron parser before you even began to figure out rendering a display and timers.
  11. How about leaving triggers out of it and just have a proper relational structure? MySQL triggers reduce concurrency and are very slow relatively speaking. MySQL provides a way to find the auto_increment id of a just inserted row as alluded to by scotch in pseudocode -begin transaction -insert parent -get id -insert many-to-many cities table rows for any relevant cities -commit There should be a cities table and not a redundant storage of the city name over and over. I realize this was not your design, nor your design mistakes but when you have a requirement that you change something, it gives you an excuse to start doing things properly and this will improve the system in the process and preserve performance over time.
  12. I don't see an issue with the code. Is there anything in your apache or php logs? With that said, the code: imagepng($img, 'signature.png'); is going to attempt to write the file in the current working directory where that script is running. Your permissions may not be allowing a file to be written there. Try providing the full path to a directory and filename you are sure has write access for the user apache is running as. I'm not much help there because I don't use windows/xamp etc. You should also try and turn off the warning level while debugging this. Try adding: error_reporting(E_ERROR | E_PARSE);
  13. There is an old compsci saying: "Garbage in garbage out". In order to determine what data you have to work with, you need to to dump out the data structure in some human understandable way so that you can check your assumptions. There are several tools for this in php: var_dump and print_r for example. I also think that given a small amount of effort, you could probably learn to understand JSON format, which is fairly easy to understand if you invest maybe 20 minutes studying it online and looking at some examples. Here is the raw JSON output from your example: { "results" : [ { "address_components" : [ { "long_name" : "95117", "short_name" : "95117", "types" : [ "postal_code" ] }, { "long_name" : "San Jose", "short_name" : "San Jose", "types" : [ "locality", "political" ] }, { "long_name" : "Santa Clara County", "short_name" : "Santa Clara County", "types" : [ "administrative_area_level_2", "political" ] }, { "long_name" : "California", "short_name" : "CA", "types" : [ "administrative_area_level_1", "political" ] }, { "long_name" : "United States", "short_name" : "US", "types" : [ "country", "political" ] } ], "formatted_address" : "San Jose, CA 95117, USA", "geometry" : { "bounds" : { "northeast" : { "lat" : 37.3299101, "lng" : -121.9499179 }, "southwest" : { "lat" : 37.2943199, "lng" : -121.9817339 } }, "location" : { "lat" : 37.3120731, "lng" : -121.9643745 }, "location_type" : "APPROXIMATE", "viewport" : { "northeast" : { "lat" : 37.3299101, "lng" : -121.9499179 }, "southwest" : { "lat" : 37.2943199, "lng" : -121.9817339 } } }, "place_id" : "ChIJ4YcqPMHKj4AR_oe_L8U_ojs", "types" : [ "postal_code" ] } ], "status" : "OK" } In the code you provided, which simply converts the JSON to a php array, once you understand JSON a bit you can figure out what the array structure is going to look like. It appears that determine the city data isn't as simple as finding a fixed key, because the structure contains an array named 'address_components' with a number of generic sub objects. You have to actually look for the 'locality' key in the list of types for that embedded object: { "long_name" : "San Jose", "short_name" : "San Jose", "types" : [ "locality", "political" ] }, So for example, I can see that something like this would seem to allow you to determine the city component: $city = array(); foreach ($data['results'][0]['address_components'] as $addrObj) { foreach($addrObj['types'] as $type) { if ('locality' == $type) { $city['short_name'] = $addrObj['short_name']; $city['long_name'] = $addObj['long_name']; } } } Of course, I'd highly recommend using var_dump($data) to debug these assumptions.
  14. Use the datetime object, and this is pretty simple. $date1 = new DateTime(); $date2 = date_create("2013-12-12"); $diff = date_diff($date1,$date2, true); echo $diff->format("%R%a days");
  15. Probably there is a problem in the loading of included .conf files for php, so that there is no longer a correct addhandler statement tying .php extension files to the php module. Check through the apache .conf files and include directories.
  16. You provided no code and minimal information. What help do you expect?
  17. This is basically the idea behind the popular idea of class relationships via dependency injection/inversion of control/loose coupling. Nice article by the architect of the symfony framework explaining the idea in more detail here: http://fabien.potencier.org/what-is-dependency-injection.html It's great to start with private variables, but frequently you want to take a step back from that and use protected variables, unless you are certain you will not be using inheritance.
  18. That is only something you would do if there is a public facing aspect to the system, where other users would be able to see information about the user in question, or interact with them in some way. Facebook and Twitter are both social networks that are driven by that design. Most systems don't do that unless it's specifically for the reason of providing a public facing page for others. When you login to Facebook, your url's don't all become Facebook.com/yourname/....
  19. We discussed this a long time ago, and the consensus was that we wanted to keep everything positive. "Disagree" would carry with it negative connotations, and the argument is/was that if you disagree with some advice you are always free to post an alternative. A quick "thumbs down" button is also prone for abuse.
  20. I've also found the strip format button to be useful on occasion.
  21. FWIW, this was because the time on the host machine was off. Phpfreaks is running in a virtual server, so any attempts to fix the time locally were doomed. We had to get the host server date/time fixed, and Eric setup NTP so hopefully this problem will not re-occur in the future.
  22. How about: $string = $_REQUEST['sched-date']." ".$_REQUEST['sched-start']; $date = DateTime::createFromFormat('Y-m-d H:i', $string); echo "String: $string\n"; echo "ISO Format: " . $date->format('c');
  23. Perhaps what they were actually looking for is your implementation of the search.
×
×
  • 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.