Jump to content

dannyb785

Members
  • Posts

    544
  • Joined

  • Last visited

Everything posted by dannyb785

  1. I have no clue what Assembler is. I googled it and none of the results seem to be related to what I was asking. Can you expand your answer so it's actually helpful and not a waste of space?
  2. Praise Allah! Finally a response that was helpful. Thank you lemmin, you've restored my hope in this website
  3. Your response of "no" was CLEARLY being sarcastic at my frustration.
  4. Janj, are you saying that on your website, [redacted], that your browser isn't displaying the image? It is displaying correctly for me. Are you using a really old browser maybe that can't display png's?
  5. Have you tried it without the / in front of path? But I don't know your folder setup so that might not be helpful
  6. I'm with lemmin, I read your question and the code over a few times and I'm not sure what you're trying to do. I understood that you wanted to count the number of files in the folder, and then something about the image type(like jpg, bmp, etc?)
  7. Hello, I seem to have had bad luck in getting any helpful answers for my last 2 threads so if you don't want to help, I'd rather you just not reply, but here goes: There are times when I need a list of users to be displayed and then a set of checkboxes next to them, where each checkbox represents something different. As an example, an admin page wants a list of users in a table and in each row, there's a checkbox for "admin"(to choose if that user is an admin), "suspended"(if that user is suspended), and so on. I initially thought that I would just scan each row and those that were checked, it would mark that value in the user table to 1(indicating that it was checked), but then I don't know how to detect a checkbox that was left unchecked. Sorry if my question doesn't make sense, so if it doesn't, I guess an easier way to ask is: how do you detect check boxes that weren't checked?
  8. That doesn't answer any part of my question. I can tell that you enjoy being vague in your posts, but why even reply if you're not going to help?
  9. I also didn't realize this forum was so full of pompous, arrogant coders who feel like my questions aren't worth their time. I didn't think I'd have to give an example but here you go: A user logs in and I store their user id into a session variable. Then, any time they're on a page that requires their own information(like an 'edit my account' page or something), I run a quick query to grab the row in the User table with that user id that was stored in the session variable. It's a value that will never change, no matter what the user does. So I can know for 100% certainty that the value given will be an integer and will be a number that exists in the User table. Is that a sufficient enough example of how I can know for certain?
  10. Jessica, your signature says that instead of giving answers to questions,you give hints. But just saying "it's not efficient" isn't helpful in the slightest.
  11. Hi I can't seem to find an answer anywhere else so I hope someone can give some insight. I'm not looking for actual code, just an example of 2. I've written a few social networks in the past, mostly for fun. But the newsfeed part always tripped me up. I started off by making a database table called "Newsfeed_Post" and each row would have a set of info that explained what the newsfeed post was for(events, pictures, etc), which user did it, etc. But then when I got to the part where I wanted to grab the last 20 posts that were relevant to any particular user, that's where I'm worried about my mysql queries. I understand about JOIN's and whatnot, but if I wanted the option to show the newsfeed updates for users who were a: my friend b: not suspended, c:not hidden(since you can hide a friend's post), etc, that would produce quite a few WHERE conditions, which were very resource-heavy. So all I'm asking about is the concept behind popular newsfeed, we can maybe say facebook for example. I'm not asking how facebook does theirs(obv we don't know) but I'm asking how could facebook(or other social networks) do a newsfeed system that doesn't include a whole bunch of WHERE conditions? Or is it just not possible? Or was my whole idea of having a separate "Newsfeed_Post" table a bad idea? If so, please explain why it's a bad idea. I'm just looking for concepts/idea and possibly the pros/cons for each, if you wish to explain them.
  12. Why won't anyone just say yes or no that the code I provided is efficient or could be made more efficient? Does it use up too many resources to use extract()? Should I avoid using it? I'm not asking for real-world coding. I have my own reasons for being certain that the data in the query won't produce a result. All I'm asking is the quickest(and least resource-heavy) way to grab data from mysql and store it into variables.
  13. I don't think my original question was clear. I wasn't asking if the code was best for validation or anything like that. My question was concerning its efficiency. Let's pretend that you knew for a fact that the query would generate the one row for the id given, and that there were no errors, is this the most efficient way to do that? Or is there a better way? I know that I don't really have to extract(), so I'll just reword the line in question: mysql_fetch_assoc(mysql_query(" ANY QUERY THAT WILL ONLY GENERATE ONE ROW ")); In terms of using up server resources, is there a more efficient way to generate the result than that? Can you kindly give an example of a line of code that would be less "terrible" ?
  14. Hi all, Since I first started coding php, if I was ever grabbing one specific row(usually based on the primary key so it was unique) I've always just done: extract(mysql_fetch_assoc(mysql_query(" SELECT * FROM User WHERE user_id='1' "))); But I recently thought to myself, is that the wrong way to do it? Is there a problem with doing that? Or is there a more efficient way to grab all of the data from one row?
  15. I'm not using CURL, but I guess your suggestion is still similar. The server I'm moving the images to is a client's server so I don't know what his options are set to, but is there a way to prevent a timeout? I was thinking maybe just a cron job every 2 minutes to grab a few images and just let it run all day. Is that feasible?
  16. Hey all, I have to grab a ton of images from a remote server and I have a script that knows the file URL of all the images and it grabs each image path, copies it and saves it into my own directory on my server. But after saving about 20 or 30 images, the script stops and I get the "500 internal server error". Any ideas how to prevent that? Or how to extend the life of the script? I'll give my code in case it helps function create_image($orig_file) { $original = $orig_file; // picture being copied $temp = explode("/", $original); $new_file = $temp[6]."/".$temp[7]; $new = $new_file; // thumb being created $src_img=imagecreatefrompng($original); $old_x=imageSX($src_img); $old_y=imageSY($src_img); $dst_img=ImageCreateTrueColor($old_x,$old_y); imagecopyresampled($dst_img,$src_img,0,0,0,0,$old_x,$old_y,$old_x,$old_y); imagepng($dst_img,$new); imagedestroy($dst_img); imagedestroy($src_img); } $vars = array(3146,3147,3148,3149,3150,3154,3155,3156,3157,3158,3159,3161,3162,3164,3165,3166,3168,3169,3170,3171,3172); $vars2 = array(3141,3142,3143,3144); foreach($vars as $id) { foreach($vars2 as $id2) { create_image("*image-path-here*/{$id}_{$id2}_M.png"); create_image("*image-path-here*/{$id}_{$id2}_LQ.png"); } }
  17. Can anybody guide me in the right direction? Even something like some terms to search in google, I've attempted combinations of automatic, automated, cpanel, dns, domain, add domain, etc and I can't find anything close to what I'm looking for. I've never worked with wordpress, but I believe they have a feature like that where you can opt to change your domain to their nameservers and then your wordpress site can show up under your domain, but how is it done?
  18. But how is it made automatic? When I add a domain to my server, I go to the 'add domain' area in cpanel and then transfer a copy of all the website files(and setup the database) to the new folder that was created for that domain. Can you guide me to how to automate a cpanel action?
  19. When I add a client's domain to my server, first they change the nameservers on their domain, and then(24-48 hours later) I add their domain to my server. With that in mind.... I'm coding a site where someone will buy a domain, change the nameservers, and I need that domain to automatically be recognized on my server, somehow through php, mysql, htaccess, or another method. But I need it to be automatic. How would I do this?
  20. Thank you for your help. I knew they were both 1 byte, but I wasn't sure if integers were maybe faster or more efficient to work with than a CHAR or if it didn't really matter.
  21. I should rephrase my question. Which data type takes up less space? TINYINT or CHAR(1)? Is that really the question? Not really, but I'll answer anyway. A user's level where 1=regular user, 2=admin, etc. I just want to take up as little space as possible in the database.
  22. I've thought it would be CHAR(1) but then I've also read that queries can search easier when the data type is an integer so maybe TINYINT? If the data will only ever be 0-9, what's the best data type to use?
  23. I get what you're saying, but I only made it a function so that if I discovered that the function had a flaw in it that I could easily change it and not have to manually change every time I did that action on every page. And about casting/filtering: I just need to make sure that the specific input is an integer and convert it to an integer if it's not. So if it was "9 lbs" that the result would be '9', and similar
  24. Basically, the function I've been using to filter input to only integers is: function make_int($input) { return (int)$input; } But I was wondering if it was better to use regex like preg_match... is my way sufficient or perhaps is one or the other harder on resources?
  25. wtf man, does it make you feel smart by throwing out all those references that I obviously won't recognize. I'm here asking about an efficient way to run a script consistently and you're talking about crap like a "message broker", something that "implements publish/subscribe", RabbitMQ, ActiveMQ, race conditions, flock program, setting a filesystem lock... seriously? Do you honestly think you're helping with that?
×
×
  • 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.