Jump to content

requinix

Administrators
  • Posts

    15,266
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by requinix

  1. Your answer is right, it's the best way to build a string like that without having a trailing comma that needs to be removed. I'm just saying that using something like json_encode(), which is for situations exactly like this one, is better.
  2. I have a question for you. If you also believe that it should be done another way, and I'm sure you've seen that OP is trying to learn that better way, why did you give him/her the bad answer?
  3. Construct a multidimensional array that looks like what you want, then json_encode it.
  4. ... The idea you have of creating files for every single thing is bad. Very bad. Don't do it. There is absolutely no reason whatsoever that anyone should ever need to do it. Do you want to know how you should be doing it?
  5. You can't write to the middle of a file without overwriting whatever came after. You'd "have" to read in the whole file, make your change to the string in memory, then write it out.
  6. requinix

    UTF8

    Multibyte Support enabled There's your answer.
  7. requinix

    UTF8

    Is the extension not enabled already? It's one of the most common extensions and thus often is.
  8. I'll say it now: there could be an extension that'll help do this. Such as mod_macro. Yes, there is some flexibility with configuration, but I'm not sure it extends all the way to directives like ServerName and DocumentRoot.
  9. Here's one, and here's another.
  10. From the first file that was executed (generally). Subtle difference. Moral is to always use absolute paths whenever possible, either with the DOCUMENT_ROOT or the __FILE/DIR__ constants. require_once($_SERVER["DOCUMENT_ROOT"] . "/configure.php");
  11. Think. Why would it? If your web and database servers are in different timezones then dates and times will differ between them. Pick one place to do dates. Personally I prefer using PHP for it, but that's just my choice. Now, what you're saying is contradictory. Do you want only the people online within the last five minutes, or do you want all the people and to display which ones are online?
  12. Not if they all have different document roots and log files and such. Not that I've done this myself, but I believe the method to do multiple websites is to create a configuration file from each (based on a template) and have Apache reload its settings. It'd be one of the steps in the "create a subdomain" step, alongside making directories and updating databases and whatnot.
  13. No. You'll have to make something which shows them the files on the server, and acts based on the choice made there rather than on an uploaded file.
  14. I figured. If they were giving you precompiled files then they probably didn't want you seeing the source. Use something like Unix's file command to find out the type of file they gave you. Then compare the information with your system and the PHP setup you have. If they don't match then the client will have to give you the .so compiled for a different architecture.
  15. Do a phpinfo() to make sure the new settings took effect. If View Source doesn't show anything then your code never outputs anything.
  16. Are you sure that it's not showing any data versus PHP crashing and dying? I would bet there's a different problem from the databasework; maybe syntax (are the PHP versions on the old machine and the new machine the same?) maybe settings (how about the php.ini settings?), or maybe something else. As you should to for a development machine, make sure your new web server's php.ini has error_reporting = -1 display_errors = on then restart the web server software (ie, Apache or IIS), run your script(s) again, and look for error messages.
  17. mysql_real_escape_string() is the only thing you need to use when putting something into the database (except stripslashes() beforehand if and only if magic_quotes is enabled). When data comes out you do not need to do anything. When displaying it you do need to use a function like htmlentities(). I suspect your code uses htmlentities(), htmlspecialchars(), and/or html_entity_decode() in places where it should not...
  18. .so files are compiled (like .dll files on Windows) which means they have to be compatible with your system and software. For instance, you can't mix 32-bit and 64-bit. They're generated by anything which can be compiled - predominantly C/C++ but that's not a requirement. Those files then get referenced by other things which support it. PHP code by itself does not; you'd have to write an extension (which is what that link talks about) to be able to use a .so file in your code. I don't know about Java but given its platform-independent nature I would guess not. What is this file your client is giving you about, and is s/he willing and able to give you the original source code?
  19. What do you mean by "can't see"? Can't get to the database machine itself? Can't authenticate? Can't get to the database?
  20. Depends how you look at it.
  21. Then use a view which has an IF in it, doing the same logic as your code does (which it actually wouldn't have to do if you used the view). IF((lastaction + INTERVAL 15 MINUTE)
  22. Easy. Stick a click handler on the map and make the handler place a marker. Easy. Just another form variable. Easy. The JavaScript to create the map also places a marker. Google Maps has a way to look up latitude/longitude into a location. Just look up the country and city yourself. Option A) Google Maps can tell you the "bounding box" for Manhattan; you search for all points within that box. You will get some false positives if a marker is within the box but not actually "in Manhattan". Option B) You find a service that gives you more definitive bounds for places. Good luck. Option C) You prompt people for the location of the image, they tell you what they feel like telling you (though you can verify it using option A), you store that answer somewhere searchable. Option D) You search using all the location data you got from that latitude/longitude. You'd have to store a lot though: borough/city/county/state/country, for starters.
  23. Doesn't account for the length of the "http://" itself, and the third parameter to substr() is the length of the substring. More like $str = "some text http://www.test.com/qs"; $start_pos = strpos($str,"http://"); $end_pos = strpos($str, "/", $start_pos + 7); $substring = substr($str, $start_pos, $end_pos - $start_pos - 1); Could still use some error checking though.
  24. Don't use that method. There's a much simpler way: Unless your "online" field does more than just indicate online versus offline, remove it. Instead store a timestamp of the last action taken; update it when they do something (like load a page). Then your online count is simply the number of users whose timestamp is more than 15 minutes ago.
  25. Don't use WordPress as an example. Please. Their codebase features poor design and worse implementation. Foreign keys (in terms of design) are simply fields in one table that correspond to fields in another table. Constraints aren't strictly necessary so long as the application is coded perfectly; since that can be hard there are foreign keys (in terms of implementation) that enforce the rule that referenced fields actually do exist before you try to use them. Note that they can do more, like automatically update or delete rows. MySQL doesn't automatically relate things for you, if you're thinking along those lines. There isn't a "grab stuff in X table and all the 'related' stuff in Y table" function. You have to tell it exactly what you mean. Instead it gives you some tools for that, such as JOINs and foreign key constraints.
×
×
  • 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.