-
Posts
15,231 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
No changes? Since apparently the city is required, where do you want it to show up in the new URL?
-
PHP sometimes does unusual and unexpected things with memory. Try using memory_get_peak_usage() instead.
-
Sigh. Won't work. ^ THIS Won't work.
-
Look at the error $_FILES['editcar_fileupload']['error'] to see if a file was actually uploaded (or if there was some other error). Error codes
-
Str/preg_Replacing An Array With The Same Words?
requinix replied to jimbbob's topic in PHP Coding Help
Is it always a comma-separate list like that? explode() out the original string on commas and replace each part if it's in the array of words to replace. $string = "Word 1"; $words = array("Word 1", "Word 2"); $replace = "Word 1,Word 2"; $array = explode(",", $string); foreach($array as $k => $word) { if (in_array($word, $words)) { $array[$k] = $replace; } } $new_string = implode(",", $array); Don't know how it compares to a preg_replace() solution. -
Adding Next And Previous Function To An Edit Form
requinix replied to RLAArtistry's topic in PHP Coding Help
Don't assume that the ID numbers are sequential. If you want me to go into the full rant about doing so I will, but basically: ID numbers are arbitrary numbers with the sole purpose of being unique, and when you assign this "previous is ID-1" and "next is ID+1" meanings you change the concept into something it is not. I would do two more queries to grab the previous and next records: SELECT id FROM products WHERE some condition indicating the record is before the current one ORDER BY some field DESC LIMIT 1 SELECT id FROM products WHERE some condition indicating the record is after the current one ORDER BY some field ASC LIMIT 1 If you go by a date, such as a creation or modification date, then it would be like SELECT id FROM products WHERE modification_date < modification_date from this record ORDER BY modification_date DESC LIMIT 1 SELECT id FROM products WHERE modification_date > modification_date from this record ORDER BY modification_date ASC LIMIT 1 Plus you get to know if there is, in fact, a previous and/or next record at the same time.- 6 replies
-
- php next code
- previous code
-
(and 2 more)
Tagged with:
-
Which Php Version(S) Are Compatible With Mysql5.1.65?
requinix replied to yshua's topic in MySQL Help
Given what the post says, yes: I'm very surprised that an ISP provides that level of tech support. -
Help from where? I don't see anything from you having to do with this. Only the code at the very bottom forces it to be a command-line script. Remove it and write something else in its place so that you can do whatever you want. Meanwhile the code in the class outputs stuff directly so for the time being you might want to use a PRE or stick to a text-only page. Otherwise what's your code?
-
How To Wrap A Json Array Inside A Json Object?
requinix replied to anevins's topic in Javascript Help
The JSON you have doesn't match the JSON you're supposed to send so there's a problem with that too. What's your code? -
There's a very big, glaring syntax error in that code. Assuming that's a typo, remove the space from the beginning of the string.
-
It's called URL rewriting. Give Google a shot: there's a lot of information out there and now that you know what it's called it'll be much easier to find it.
-
It's possible you might get a 503 but that's because you were able to contact a machine that sits in front of the actual API server, such as a load balancer or proxy. Keep an eye on the service. If/when it goes down, try to use it and see what happens.
-
Script Works In Php 3.x But Not In Php 5.x
requinix replied to JamesFinch's topic in PHP Coding Help
Pfft-- Are you surprised it doesn't work? PHP 3 is one month away from being 12 years old. It's even older than Windows XP and that's been around forever. At 6.26 KB it shouldn't take long to rewrite it for 5.3. Long-form globals like $HTTP_POST_VARS are now just $_POST, function signatures have changed quite a bit (mostly by adding options, but some have been changed), and there's support for classes and objects. And that only gets you up to 5.2: after that a bunch of things became deprecated (magic_quotes, register_globals, assorted functions and extensions). Check the changelogs to find out more - the above is just some of the more important changes in a nutshell. -
1 and 3 are virtually identical, as are 2 and 4. As a developer I don't want to have to force key/value pairs into some custom URL structure. I want to write code like $data = array( "key" => "value", "key2" => "value2" ); $url = "http colon slash slash www.example.com/service/method?" . http_build_query($data); (or cURL if I have to POST stuff). In other words, conform to existing standards and use existing functions and methodologies. URL rewriting is primarily for users so they can see a pretty and memorable address in their browser and in the links they click. That does not apply to an API.
-
Do you actually need p1 to communicate with p2? Literally? Or is it more like you need p1 to broadcast a message and p2 cares about receiving those specific messages?
- 4 replies
-
- memcached
- onlinegame
-
(and 3 more)
Tagged with:
-
How To Scrape A Page That Uses Prompt Login
requinix replied to ultimatum's topic in PHP Coding Help
CURLOPT_USERPWD Frames are dealt with by the browser - cURL will only give you the HTML that defines the frame, not the contents of the page referenced. In general you do this kind of work by logging in (and making sure cURL is saving the cookies someplace you can reuse in subsequent calls) and hitting the exact URLs you need. -
Can you upgrade? 5.3 has been out for a long time and has a long list of really cool things you can use.
-
I don't mind a list of use statements: it reminds me about classes I'm using that are in another namespace. Besides, most of the time (1) I'm using classes in the same namespace so the list is fairly small and (2) if I need multiple classes outside the namespace there's a good chance I need to refactor a little for the sake of encapsulation and coupling and whatnot.
-
There's no point in using namespaces if there's only one or two in the entire project. Just do without it and consider them in the global namespace (which is exactly the end result). Most of the time, if you're organizing classes into multiple folders (eg, lots of underscores as separators) then you can use namespaces. Or you don't and just stick with long class names; PHP's implementation of namespaces can be a bit awkward at times* so it's not uncommon to see PHP 5.3+ code that isn't using namespaces. * Can't import/use entire namespaces, class names resolve differently than functions and constants, the ridiculous notion that a backslash is the right separator character...
-
I'd think pretty much anything that supports audio/video, streaming, and playlists. I don't watch much video but MPlayer et al. and VLC probably work.
-
I've dabbled with this kind of thing in PHP and I'll tell you: it's not easy. The best method I know is IPC (inter-process communication) such as with streams (essentially sockets but they're easier to deal with in PHP than sets of sockets). Shared memory is only worthwhile if one process ever writes to it and all the other processes read. Not to mention how the whole Unix forking model is such a hassle compared to Windows' threading model. Want a second thread? Fork the whole damn process and clean up memory you don't need to use. If you're really serious about this then don't use PHP for it. Or at least not all of it. It just doesn't support multithreading that well.
- 4 replies
-
- memcached
- onlinegame
-
(and 3 more)
Tagged with: