-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Here's one, and here's another.
-
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");
-
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?
-
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.
-
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.
-
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.
-
Do a phpinfo() to make sure the new settings took effect. If View Source doesn't show anything then your code never outputs anything.
-
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.
-
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...
-
.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?
-
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?
-
Depends how you look at it.
-
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)
-
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.
-
How to validate a specific hyperlink from different links using php
requinix replied to compphp's topic in PHP Coding Help
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. -
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.
-
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.
-
Does the wifi not have an ethernet out port? Do you know that you won't get nearly as fast a connection with wifi than with broadband?
-
One to four. Standard ASCII stuff (like you'd find on an en-us keyboard) is one byte and just about every other "common" character is two or three. That's for if you were compiling PHP yourself. Somehow I doubt you are. Just enable the extension if it isn't already.
-
You should use foreign keys whenever they're warranted. There isn't really a situation where you could use one but should not. Here's what my layout would look like, though I tend to overthink things and it may be more complicated than you need: houses: - id - address - rent per month - tenant (optional, FK to tenants, helps with queries) - notes (always useful) tenants: - id - name - phone number - date first moved in - date moved out (nullable) - forwarding address (nullable) - current lease (optional, FK to leases, helps with queries) - notes (always useful) leases: - id - tenant (FK to tenants) - house (FK to houses) - start date - end date - price - amount paid (optional, helps with queries) - pay due date - notes (always useful) payments: - lease (FK to leases) - date - amount - notes (always useful)
-
In my opinion yes, it is worth it. Windows-1252 is probably the best single-byte encoding. It supports standard ASCII, naturally, and quite a few accented characters - even more than ISO 8859-1/Latin1.
-
And their commercials are sleazier than Trojan's and Axe's. Hell, sleazier than commercials for 1-900 services. They still do, just not publicly.
-
You should keep them outside the web tree. public_html/ dir1/ dir2/ dir3/ index.php config/ config1.php config2.php config3.php If the web server is hosting stuff out of public_html then it won't host any of those config files. That's why you would put them in a directory outside public_html.
-
I bet you're looking for it in $_POST, right? That's not where uploaded files go. Look in $_FILES instead.
-
You mean with IIS? The operating system is irrelevant - what matters it the web server software. Use a web.config. But unless you want to learn that, do the right thing: store these precious files in a special folder not inside the website.