|
I would either: A) Use a database abstraction layer with prepared/parametrized queries so you don't have to do the escaping manually or B) Break the string concatenation on to another line and assigned it to a variable with some line breaks/formatting around the . operator.
|
# ¿ Mar 31, 2008 06:56 |
|
|
# ¿ May 7, 2024 13:21 |
|
Treytor posted:I suck at PHP, I admit. All I really know how to do is modify code already given to me, and somewhat follow what is going on. Anyway, let me cut to the chase. http://us2.php.net/stream_context_create http://us.php.net/manual/en/wrappers.http.php (See example 1)
|
# ¿ Apr 1, 2008 03:42 |
|
Little Brittle posted:I can't figure out how to get wrappers working, so I'll just use CURL. Thanks for the tip. You need the // to search all nodes for the REF tag otherwise the query is /ASX/ENTRY/REF/@HREF In most engines the tag/attribute name matching can be case sensitive, so check first. waffle iron fucked around with this message at 04:34 on Jul 5, 2008 |
# ¿ Jul 5, 2008 04:32 |
|
Stephen posted:How would I check in PHP if a string exists as a variable? isset will only tell me if a variable exists, and does not accept a string as a parameter.
|
# ¿ Jul 14, 2008 21:58 |
|
functional posted:You may be confused because I took the time to write a nice problem description. (Nobody does homework in PHP. And I am not a student.)
|
# ¿ Aug 11, 2008 20:12 |
|
weekoldsushi posted:
http://php.net/basename
|
# ¿ Aug 14, 2008 18:00 |
|
thedaian posted:I've been talking with Gibbon on AIM for a while, and I'm pretty sure we've solved the problem. Though, Gibbon, I urge you to learn how to program with another language. PHP is a pretty terrible beginners language, and there's a million issues of security and other things that could happen. Plus, even though PHP has pretty good documentation, a lot of tutorials are either badly written, or ignore a lot of the security problems that can exist.
|
# ¿ Aug 18, 2008 03:41 |
|
That is a pretty horrible way of filtering because it will match on anything that contains f, u, c, and k in that order, whether it be a word or a paragraph. Edit: Actually it isn't but the you have people putting in underscores or spaces and the whole filtering falls apart again. waffle iron fucked around with this message at 05:11 on Sep 3, 2008 |
# ¿ Sep 3, 2008 05:09 |
|
Stephen posted:I wanted to do this, however I'm afraid of creating an infinite loop in the event that one of the files is broken or invalid.
|
# ¿ Oct 31, 2008 19:31 |
|
Please don't store images in a database. You're better off writing them to a disk and storing the path and filename in the database.
|
# ¿ Nov 13, 2008 19:00 |
|
Roctor posted:I'm making a replacement for an ad management system at work and the old system stored all the ad images in the database. Legacy code exists to ruin lives. At least it's not as bad as storing PHP in a database and then eval'ing.
|
# ¿ Nov 13, 2008 20:15 |
|
From what I remember, the OO stuff in PHP4 is a little slower than straight up procedural programming, but then again objects in PHP4 suck. In early versions of PHP5 there was more overhead for objects, but they were 1st class OO. At this point PHP5 has matured quite a bit and hardware is fast enough so it really should make a difference on performance. At the same time, I wouldn't overarchitect things by writing your own framework where everything that can be a class is a class. For a lot of stuff, letting the database deal with big work can and is faster.
|
# ¿ Jan 17, 2009 15:32 |
|
MrMoo posted:If you are using PHP for performance on execution rather than development something is already rather wrong.
|
# ¿ Jan 18, 2009 09:28 |
|
I've always been a fan of privilege separation; using different database user accounts with limited permissions to write. Although practically it's easy to go overboard create excess database connections. Certainly having a user that can only read and write, but not alter/drop tables is a good idea. It doesn't protect you from deleting every row though, so use prepared statements.
|
# ¿ Jan 21, 2009 01:13 |
|
When the PHP file it is interpreted and then becomes OPCODEs that are excuted in the Zend Engine. The code should generate the same OPCODEs regardless of formatting.
|
# ¿ Jan 29, 2009 06:08 |
|
the littlest prince posted:I'm a total php noob, and I want to do some simple site-scraping to make a page for my own personal use. What I want to do is run a search on a couple of craigslist sites (e.g. new york, los angeles, and denver) and then display the results all on one page. See http://www.php.net/manual/en/filesystem.configuration.php#ini.user-agent
|
# ¿ Jan 31, 2009 17:16 |
|
And when it comes down to it, do the null checks yourself or write a helper function that does all that for you. It's not especially hard to get the behavior you're looking for. The implicit conversions are defined in the documentation for PHP, so it's not like you have to figure this out on your own. Edit: Next you'll be complaining about the lack of unsigned ints in Javascript and PHP. waffle iron fucked around with this message at 06:04 on Feb 2, 2009 |
# ¿ Feb 2, 2009 06:02 |
|
If you're going to serve up random images or other poo poo like that, never ever output it in a PHP file unless they're really loving tiny. Because you're not sending Cache headers the browser redownloads it every time. You're better off writing to a folder if the image is dynamic and then sending a 302 or 307 HTTP status with a Location header. I repeat: using PHP to send binary data is extra retarded. That goes double for serving images out of a database with PHP. waffle iron fucked around with this message at 02:26 on Jul 21, 2009 |
# ¿ Jul 21, 2009 02:21 |
|
DarkLotus posted:Yeah, storing images in a db is retarded. The moral of the story is static content or content that changes less than once a day should be served off a static web server or cached to disk and served from a static web server.
|
# ¿ Jul 21, 2009 02:58 |
|
supster posted:This is way too wide of a generalization. There are a lot of legitimate reasons for doing it. Additionally, just because you're serving the file through PHP doesn't mean you can't set cache-control or expires headers - in fact it gives you more control to make better use of them.
|
# ¿ Jul 21, 2009 12:12 |
|
awdio posted:Why can't I get this simple script to work? All I want to do is take an image from a URL and store it to a folder on my server. The folder has the correct permissions and I've tried a manual image uploader to that same folder and it works. http://php.net/fwrite
|
# ¿ Aug 15, 2009 00:15 |
|
Lumpy posted:You use them for very different things in general, so it's not really an "instead" thing.
|
# ¿ Sep 3, 2009 00:32 |
|
fletcher posted:This may be a dumb question, but what is to stop me from putting a fake login on some site that claims to be an "OpenID login" and just stealing a bunch of OpenID credentials?
|
# ¿ Sep 19, 2009 01:27 |
|
thedaian posted:You can do it. You probably have the syntax wrong (it's also not the best method, but it would work). No need for eval() I see you and raise you: php:<? function red() { echo 'RED!'; } function green() { echo 'GREEN!'; } $red = 'green'; $color='red'; $$color();?>
|
# ¿ Oct 19, 2009 23:24 |
|
When you do a GET on any file, a sane web server will open the file and hold onto that file descriptor and fread()s the gently caress out of it. Saving over a file on a sane OS will unlink that filename and then save a new file with that filename. There is probably no way you'd ever get an incorrect/incomplete file unless the people providing this service are brain dead.
|
# ¿ Jan 7, 2010 02:42 |
|
|
# ¿ May 7, 2024 13:21 |
|
A location header after sending a file is out of specification. For the issue of sending the file, I would recommend using X-Sendfile instead of using PHP to read it out. On large files PHP could hit the memory limits and die in the middle execution. http://codeutopia.net/blog/2009/03/06/sending-files-better-apache-mod_xsendfile-and-php/
|
# ¿ Mar 21, 2010 16:28 |