Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. @mjdamato If you're trying to create bitwise OR operations, why are you using .= operator? Won't that end up with type having values like: 14 12 24 124 etc? @cooldude You have inputs on your form that look like this: <input type="checkbox" name="{$ID}_active" /> <input type="checkbox" name="{$ID}_coaching" /> etc.. Which leads to a post array that looks like this: Array( [5_active] => 'on', [5_coaching] => 'on', etc. ) I find it is much easier to create my inputs in this format: <input type="checkbox" name="info[{$ID}][active]" /> <input type="checkbox" name="info[{$ID}][coaching]" /> etc.. Which leads to a post array that looks like this: Array( [info] => Array( [5] = Array( [active] => 'on', [coaching] => 'on' ), [7] = Array( [active] => 'on' ) ) ) What I'm getting at is whenever I build forms, I try and coerce the inputs into a format that makes form processing take the least amount of effort and thought on my part. The first step in doing so is organizing the way the data is given to me. I'll post back in a bit with my attempt at modifying your code as it is right now.
  2. Regexps are best used when you're matching a specific pattern, which means you don't know the characters in advance. In this case, you know the exact starting and ending points of the string, so I'd recommend a combination of strpos and substr to accomplish what you need. <?php $srch1 = '<textarea name="textarea" rows="5">'; $srch2 = '</textarea>'; $pos1 = strpos($the_string, $srch1); if($pos1 !== FALSE){ $pos1 += strlen($srch1); $pos2 = strpos($the_string, $srch2, $pos1); if($pos2 !== FALSE){ $substr = substr($the_string, $pos1, $pos2 - $pos1); echo $substr; } } ?> That may be slightly faster than invoking the regexp engine. Also, I've had trouble in the past using regexps on very large strings so for things that could be potentially large I try to avoid them. I didn't test that code, some of the offsets may be off by 1 so add '+ 1' as necessary.
  3. You repeated the word script in your script tag, remove the duplicate.
  4. Hah! Funny story about the chair! I had a really crappy chair before this and my fiance wanted to get me a nice gift, so she gets me that chair right. But she wanted me to pick out one that I liked because she knew how particular I am about them since I spend a lot of time in the computer chair. So we drive around to a few places and I test out dozen or so chairs at each one, finally we buy that one, as you're right, its really comfy. I get home, set it up, and start doing stuff. For regular usage it was great. But for games it was terrible. The arms constantly got in the way and they're not adjustable so it was either sit awkwardly or get sore elbows. So eventually we decided she can use the chair and we bought me a more simple one with no arms and basic cushioning. So then my desk was falling apart so I bought a new one, which is really just a cheap table. Well it's taller than the old one so the chair is a perfect fit now. But she won't give it back to me! 8[
  5. Maximum is 2560 x 1600, but I run 1920 x 1200 so that I can still read text. Mostly I bought it because its always been my dream to play games on a big flat screen. I bought this awhile ago for $2k, I'm not sure how much they've come down since then. But at the time I don't think there was any other brand but Apple that made them in this size. Newegg lists a couple of 30" monitors in the $1200-$1300 range. I think the quality on this one is amazing, but if I did it over again I might go with a different brand to save some money. When I initially hooked it up I had a nVidia 7800 Ultra which was a pretty decent graphics card, but it wasn't powerful enough to give me any resolution higher than 1200 x 800. I ended up having to shell out another $350 for a new video card as well that had true dual DVI support. So before you buy any really big monitor, do some googling and make sure your video card can support the resolution, unless you're made of money, which I certainly felt like I was at the time. (My fiance would say otherwise though! Buahahaha!)
  6. I LOL'ed. @thorpe Your mouse looks like a gardening shovel! I just have a regular desktop with a single 30" HD monitor; that gives me plenty of space to have several things open. There's a small stack of books on my desk, some relating to programming and others to Warhammer. Sometimes a cat sleeps on my desk. The area (when I hurt my foot, and it's still giving me trouble) The cats
  7. I consider myself experienced and I always make stupid mistakes. Usually they only take a few seconds to fix though. The worst mistake I've made lately, which was still a few months ago, was naming a function parameter with an upper case 'C' but then referring to it in the function as if it were a lower case 'c'. That took a while to find.
  8. Good point! Anyways, no harm no foul.
  9. Wait a minute. How come the MySQL error looks like it's referring to unparsed PHP code? You have constants in there (TABLE_) that I'm guessing are defined with, well, define(). I think I found the source of your original error. http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html You have a table named condition, which is also a reserved word.
  10. I don't even know why I'm taking the time to respond to this, but oh wells. You're right, there's nothing wrong with using header() to redirect to a different page. But since the OP is wanting two forms on the same page to each direct to a different page, which is a perfectly valid thing to do, it would make sense to figure out what is wrong with the HTML. The benefits of this include helping the OP have a page that validates as well as teaching them to be more careful when writing their HTML. Plus, the solution is simpler and more direct. Place the proper closing <form> in the proper place and you're done, the problem is solved. If you go with the PHP band-aid of using the header method, you're left with an HTML page that doesn't validate. Then you have to go to the trouble of setting some sort of $_SESSION variable so the $_POST data will be available on the next page. Bleh. When giving someone advice you should always strive to give them the correct solution to the problem, rather than leading them down some convoluted path. If you came to these forums and asked how to import a CSV file into MySQL and cumulatively you and I spent 4 hours and 15 posts going over a PHP script to open the file, parse it, generate SQL, and then execute it, that would be fine. But then someone else comes along and says, "Hey, MySQL has a built in query for this: http://dev.mysql.com/doc/refman/5.0/en/load-data.html" You'd have wished they'd come along sooner and helped you. But you're right, it was rude of me to tell you what not to say. I won't let that happen again. Ltj_bukem, stop listening to anyone telling you to fix this particular problem with header(); ken's advice is much more preferable. If you still haven't got it sorted, post the HTML source that your script is generating.
  11. Everything. Algebra is the basis for calculus which is the basis for physics. Physics forms the basis for everything you take for granted in life. Without this stuff there would be no electronics, no space exploration, no way to engineer earthquake safe buildings, etc. Likewise, many of physical equations allow us to prove certain things. For example, by measuring the length of skid marks you can estimate very accurately how fast someone was driving before a collision. This would be useful in court when trying to prove someone is at fault for causing an accident because they were driving too fast for the weather conditions. Just learn the process now. Gradually over time you will learn the application. Of course, if your greatest ambition in life is to flip hamburgers then you don't need to pay any attention at all.
  12. &&, ||, ! are the preferred syntaxes.
  13. Stop trying to tell the OP to fix this with calls to header(), kenrbnsn has already pointed out the source of the problem.
  14. Forgive me for laughing, but lol. First, making a calculator to solve those for you is significantly more difficult than just solving them on pen and paper. Second, I had a ton of trouble with algebra when it was first introduced to me. Let's see, I was in 7th grade, had missed some school, came back and went to math class. Then the teacher assigns us some work and I see all these letters all over the place in my otherwise normal problems. I'm thinking, "WTF?!" I asked my teachers and class mates about it numerous times, but no one explained it properly so I was confused as shit for a while. Not only that, but until that point I'd been a whiz at math so I was very frustrated to not know what was going on. So here's my explanation for you. 1 + 3 * 4 Let's say I was talking to you in real life and I wanted to tell you that I had thirteen apples. Which of the following two sentences would I use in real life if I were talking: #1: "I have 1 plus 3 times 4 apples!" #2: "I have 13 apples!" Obviously I would use sentence #2. It is easier for me to say and you don't have to think about the number thirteen, you already understand 13. But if I told you how many apples I had as math formula, you'd have to compute it in your head before you knew how many apples I had; that's inconvenient for you. The process of taking a math formula and solving it as much as possible is called simplification. In the problems you posted the teacher is probably wanting you to simplify the math formulas. Let's say you are holding 2 nickels in your left hand and 3 nickels in your right hand; how many nickels are you holding altogether? Easily enough we know you're holding 5. But how do we write that in algebra? Let's let n stand for a nickel. You have two nickels in your left hand, so 2n represents your left hand. You have three nickels in your right hand, so 3n represents your right hand. 2n + 3n If we add 2 n's to 3 n's, we'll have a total of 5 n's. In other words, we have 5 nickels, which we knew already. We write this as an equality using an equal sign: 2n + 3n = 5n Basically, those letters in the formulas represent arbitrary things in the real world. The numbers next to them represent how many of them you have. Here, you have 2 x's 2x Now you have 3 y's 3y An important concept in algebra is what we call like terms. "Like terms" are those with the same variable. The following are like terms since they all contain x: 3x 4x 20x The following are not like terms since they all contain different variables (letters): 2a 3b 5c Whenever you see variables in a formula, you can combine the like terms. 2a + 3b +7a +4c -1b First we rewrite the formula so that like terms appear near each other: 2a + 7a + 3b - 1b + 4c Now we perform the math where the variables are the same (we combine the a terms with the other a terms, the b terms with the other b terms, and there is only a single c term so it remains unchanged) 9a + 2b +4c Let me know if that helps some.
  15. I've been programming c-syntax-style languages for about a decade now so the syntax is very natural, so natural that it sometimes creeps into my regular typing. I remember very well things that I do often, such as using certain functions, code libraries, etc. so I rarely have to look them up. My IDE saves me the trouble of looking up the order of function parameters, but even when I'm not using it I can find them in 2 or 3 seconds. It will save you some time if you can remember absolutely everything, but very few people can do that. The trick then is to have the information handy or have a system of finding what you need quickly. Some sites provide cheat sheets that are useful, I have a couple printed out but truthfully I rarely refer to them. Let's say I'm doing something with arrays and want to know if a certain feature is built in, like sorting. I'll just hop to google, search for "php array" and the top hit is "PHP: Arrays" in the manual. Going to that page, there is a list of all the PHP functions dealing with arrays. Using FF, I just ctrl + f (shortcut for find) and type "sort"; then I select "highlight all." Now I can quickly scroll through the page and easily see every thing about arrays and sorting.
  16. Well that's about all I can suggest. Maybe fenway or barand will come by and sort you out.
  17. SELECT p.products_id, pd.products_name, p.products_price, m.manufacturers_name, c.categories_id, l.location_name, con.condition_name, cd.categories_name, c.parent_id FROM products p inner join products_to_categories p2c on p.products_id = p2c.products_id inner join categories c on p2c.categories_id = c.categories_id products_to_categories p2c left join manufacturers m on p.manufacturers_id = m.manufacturers_id left join products_description pd on p.products_id = pd.products_id and pd.language_id = '1' left join specials s on p.products_id = s.products_id left join location l on p.location_id = l.location_id left join condition con on p.condition_id = con.condition_id left join categories_description cd on p2c.categories_id = cd.categories_id where c.categories_status=1 and products_status = '1' ORDER BY c.parent_id, categories_id, products_name I didn't mean to change the LEFT JOINs; you'd have to leave them to get the correct data. I meant the parts of your query that join the products, categories, and products_to_categories tables in the WHERE clause. Anyways, try the query above. I removed the joining statements from the WHERE clause and replaced them with inner join above, which is what fixed my problem. Also, you might want to attach the table alias to the field names where they're missing; I didn't add them because I don't know which table they go with, but it appears they belong with the products table.
  18. I had a similar situation not too long ago. Turned out rewriting the query to use INNER JOIN instead of doing the joins in the WHERE clause fixed it. See this thread for reference: http://www.phpfreaks.com/forums/index.php/topic,162075.0.html I can't say that will fix it, but its worth a shot maybe.
  19. You can use regular mod operator instead of a function call: if( $i % 20 == 0 ){ // echo heading } Also, don't forget to increment $i each time through the loop.
  20. http://www.php.net/sleep
  21. If I understand this correctly, the data is stored correctly in the database. You are also able to correctly pull the table from the database and echo it to the screen with PHP and the data is what it should be. It sounds to me like you're wanting to use this data to set the default value of a form? Let's say the value in your variable is 15" monitor If you were to do this: echo "<input type=\"text\" value=\"{$variable}\" />"; The HTML would become: <input type="text" value="15" monitor" /> Are you sure that's not happening here?
  22. Now that you have it working, you might want to go and clean it up a bit. Break pieces down into functions or something because intermingling PHP & HTML that much becomes difficult to read very fast. Throw in some CSS and Javascript and you have a perfectly unmaintainable site.
  23. file_get_contents(): http://www.php.net/file_get_contents There is a reference there to setting up a stream context, which leads here: http://www.php.net/manual/en/function.stream-context-create.php It looks like you can use the stream context to customize your request method and headers. Try setting a header that identifies your user agent as IE or FF. A list of user agents: http://www.user-agents.org/index.shtml That's as much as I can help you with. You'd have to wait until someone else more familiar with HTTP headers comes along or Google 'HTTP headers' to get more. If you have whatever is required installed, you might be able to just create a test script and use http_get_request_headers() to echo the ones sent by your browser. Then you can just duplicate them in your context stream. http_get_request_headers(): http://www.php.net/manual/en/function.http-get-request-headers.php
×
×
  • 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.