Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. Just for fun, here is how you can eliminate most of your code in favor of a single loop: <?php while(($row = mysql_fetch_row($result)) != false){ $location = $row[2]; $location = getlocationname($location); $type = $row[3]; $type = gettypename($type); for($i = 1; $i <= 6; $i++){ $rowAdmin = $row[$i + 7]; $rowTitle = $row[$i + 20]; ${'image' . $i} = $rowAdmin; if($rowAdmin != ''){ ${'image' . $i} = "<a href=\"admin/{$rowAdmin}\" " . "rel=\"lightbox[{$row[0]}]\" " . "title=\"{$rowTitle}\">"; if($i == 1){ // I'm not sure why you only set this for one image ${'image' . $i} .= "<img src='designs/camera2.png' border=0>"; } ${'image' . $i} .= '</a>'; } } echo "<table id='resultsrow' width='575' height='155' border='0' cellpadding='0' cellspacing='0'>"; echo "<tr>"; echo "<td rowspan='3' width='124' style='padding-left:15px;' align='center'><img src='admin/". $row[14] . "' border=1></img></td>"; echo "<td align='left' width='105' style='padding-left:12px; color:#719DC0;'><b>". $type ."</b></td>"; echo "<td align='left' width='200' style='padding-left:12px; color:#0A1871;'><b>". $row[27] . "</b></td>"; echo "<td align='left' width='70' style='padding-left:12px;'><b>€". number_format($row[4]) . "</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='3' align='left' valign='top' style='padding-left:12px; padding-right:12px; padding-top:7px;'>". substr($row[5], 0, 150) . '...' . "</td>"; echo "</tr>"; echo "<tr>"; for($i = 1; $i <= 6; $i++){ $tmp = ${'image' . $i}; echo "<td colspan='3' align='right' valign='bottom' width='70' style='padding-right:12px;'><a href='property.php?property_id=".$row[0]."'><img src='designs/house2.png' border='0'></img>".$tmp."</td>"; } echo "</tr>"; } ?>
  2. I had a neighbor that never shut up about Delphi. He worked for Toshiba.
  3. I'd say that if they really understood what they were getting into and possible consequences, then they'd choose to wait until they were older and had less on their plate, so to speak. I know that's what I did.
  4. I'd also recommend using mysql_fetch_assoc() and using associative arrays when dealing with database columns. 6 months from now, trying to remember what $row[0], $row[5], etc. mean will be difficult. And should you alter the table, the indexes may change. That would be a maintenance nightmare. (edit) Also, never blindly copy and paste code from the web, forums, etc. into your program. Always try and see what the other person did and then apply the general solution to your problem, not the specific code solution they provided. This serves many purposes. The first is that it enhances your capabilities and understanding of what's occurring. The second is that it protects you from other peoples' mistakes; you never know when they have a typo or logic error in their code that does something drastic (such as deleting the wrong files). As always, and I learned this in physics, after you come up with any answer you must always ask yourself the most important question: Does this make sense?
  5. I just wanted to clarify this statement. 2 months is not a long time by any means. I don't think anyone your age should be having sex; no matter what you think, you're just not smart enough to realize what you're getting yourself into. That 2 months I spoke of is for people who are already ready to have sex. There are tons of people who jump into new relationships, have sex way too early, and then the relationships ends. Many of them feel bad about sex with a non-committing partner. The reason is because they had sex during that infatuation phase.
  6. This is the main point behind age of consent laws. The problem is that the majority of young people make very, very, very bad decisions and very, very, very rarely learn anything from them. When you are young you feel invulnerable to everything. Age of consent laws are there to protect you from what are essentially predators: men (and women) that prey on the naivety of younger people. The best class I took in college was arguably Human Sexuality. One of the topics we covered was that of projection, which is a psychological behavior almost all humans engage in. It works like this, in your head you have an image of what the ideal man or woman is. Then you meet someone and are physically attracted to them. Initially, all you see are their good qualities. What you are actually doing is mentally projecting the image of your ideal mate on this new person; you are fooling yourself into thinking they are what they might not be. Sometimes this is referred to as infatuation. And it lasts a good deal of time, 4 to 6 weeks on average. You might notice that most couples (all ages) only date for 1 to 2 months before calling it off. What happens is you start seeing that person for who they really are and not who you wanted them to be; eventually you realize you don't like them so much after all. You're young, you can make mistakes, you have your whole life to bounce back from one, right? Well not all the time. Some mistakes simply can't be undone. Here's my advice: keep your pants on and take your time with things. Date someone for a long time before you decide to be more intimate with them, at least 2 months. Learn to see people for who they are and not who you want them to be. Some STDs are for life. Lastly, should you become pregnant, a guy can easily walk away from that situation while you're stuck with the consequences, abortion or not. You may not like it but you're hitting that age where one bad mistake can take a gigantic toll on your life.
  7. I assume you want this stuff to echo down where all the table stuff is. You have to look at what the code is doing and think about it. Here is the loop: for($i = 1; $i <= 6; $i++){ echo print_r(${'image' . $i}, true); $tmp = ${'image' . $i}; } I put that echo print_r() in there just to show you that it works and accesses your variables. There is a very good chance you do not want to keep it. Second, the loop sets a variable $tmp but does nothing with it, so essentially you will set $tmp 6 times and then after the loop $tmp is equal to the final value. So after the loop executes, we've printed information we didn't need / want and $tmp is only equal to the last value set. Then your code prints the table stuff. Do you see what's wrong with that picture? Here is a fixed version: echo "<table id='resultsrow' width='575' height='155' border='0' cellpadding='0' cellspacing='0'>"; echo "<tr>"; echo "<td rowspan='3' width='124' style='padding-left:15px;' align='center'><img src='admin/". $row[14] . "' border=1></img></td>"; echo "<td align='left' width='105' style='padding-left:12px; color:#719DC0;'><b>". $type ."</b></td>"; echo "<td align='left' width='200' style='padding-left:12px; color:#0A1871;'><b>". $row[27] . "</b></td>"; echo "<td align='left' width='70' style='padding-left:12px;'><b>€". number_format($row[4]) . "</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan='3' align='left' valign='top' style='padding-left:12px; padding-right:12px; padding-top:7px;'>". substr($row[5], 0, 150) . '...' . "</td>"; echo "</tr>"; echo "<tr>"; for($i = 1; $i <= 6; $i++){ $tmp = ${'image' . $i}; echo "<td colspan='3' align='right' valign='bottom' width='70' style='padding-right:12px;'><a href='property.php?property_id=".$row[0]."'><img src='designs/house2.png' border='0'></img>".$tmp."</td>"; } echo "</tr>"; Do you see now how the loop has been moved to where you intended to use the values?
  8. You can't effectively stop people from sharing account information. IP addresses aren't reliable, neither are cookies. Don't even waste your time tackling this headache. The solution lies elsewhere. Instead of trying to limit people from sharing accounts, you should just allow them X number of people logged in at any one time. Let them create any number of accounts that they want for the employees; after all the overhead on your DB for extra user records is minimal. If they have purchased licensing for 5 people, as long as no more than 5 people are logged in at a time it's not really a problem. That actually works out better on your end because more people will want to use the software, but be unable to because of all available licenses in use, and then they'll likely order more licenses.
  9. rondog; rather than just flat out tell you, I'm going to teach you to be resourceful. Here again is the link I gave you above: http://www.php.net/mysql_real_escape_string That's a lot of reading, so press ctrl+f on your keyboard to bring up the find window for your browser and search for the term 'magic' Should take you right to it.
  10. 1) Use mysql_real_escape_string() 2) You do not run it on the entire query. You do run it on any and every bit of data you receive from the user that you use in a query. $uname = mysql_real_escape_string($_POST['uname']); $pass = mysql_real_escape_string($_POST['pass']); $sql = " SELECT * FROM `users` WHERE `uname`='{$uname}' AND `pass`='{$pass}' "; $q = mysql_query(); You should also note that if magic quotes is on, you first need to stripslashes(). The manual has examples of doing so: http://www.php.net/mysql_real_escape_string
  11. I'm retarded; I thought you were just trying to recursively copy a directory from one location to another. Here's what I found: http://rep.oio.dk/oio%20services/WebDAV%20User%20guide_0.6__1.0_.pdf Maybe that will work in other browsers as well, or maybe you have konqueror already installed.
  12. I just noticed in your OP you said you had 5 variables but I wrote a loop for 8; just make sure you didn't copy my code verbatim and include my mistake.
  13. The most likely causes are that you had a syntax error in your .htaccess or the main httpd.conf has AllowOverride set to None. You shouldn't need a directory section in the .htaccess since the .htaccess should be in the directory you want to protect. The only line you should need is: Options -Indexes
  14. Well the easiest thing to do is use an array next time, then you can just use a foreach loop. However, if you don't want to change code, you can take advantage of PHP's { } variable syntax (I don't know what the official name is). Let's say you had a variable named 'Hello'. The next two lines of code are equivalent: $Hello = 'Tom'; ${'Hello'} = 'Tom'; Basically, if you have the following sequence: dollar sign, open curly bracket, any PHP expression, and then a closed curly bracket, the PHP expression becomes the variable name. So in your case: for($i = 1; $i <= 8; $i++){ echo '<pre>' . print_r(${'image' . $i}, true) . '</pre>'; // echo's image1 through image8 // To avoid a bunch of funny syntax in your code, I'd set a temp variable and use that $tmp = ${'image' . $i}; // Use $tmp from this point forward }
  15. Did you check the man page? It's in there. It's also on Google searching for "cp copy directory" Here you go: http://www.unet.univie.ac.at/aix/cmds/aixcmds1/cp.htm
  16. Ditto on the delay. Remember the flash is there to show potential clients you're capable of using it, so you don't want them to miss it.
  17. No problem. If this is a test server you don't have to worry about anything. But on a live production server you need to take care that there are multiple places where you can set this directive. You can set it globally for the entire server, which could be dangerous. The preferred approach is to set this on a per-directory basis down in the NameVirtualHosts stuff. Again, if it's a test server, don't worry about it.
  18. Look in httpd.conf for a setting: AllowOverride and see what it's set to. If AllowOverride is set to None then .htaccess files won't be allowed to override anything.
  19. I think he means languages like basic that have: IF blahblah THEN END IF The answer to your question is simple. Those languages were created for business-users who get easily confused over syntax based on punctuation. Also, since the intended users aren't real programmers they're not inherently lazy, so they don't mind typing THEN and END IF when { and } would suffice!
  20. Do you mean division or the <div> markup tag?
  21. So the fiance has been running Ubuntu since late last week and so far she loves it. In her words, "It's like it knows how a person would want to use the computer efficiently."
  22. You need two things to learn effectively in most areas: 1) The will to practice it on your own 2) A mentor who knows better / more than you I started teaching myself c++ when I was 15 from a "Teach Yourself XYZ in 21 Days." I rewrote all of the examples in the book, just to get into the habit of writing code. When I felt I knew enough, I started branching out and writing small programs of my own. The very first program I wrote on my own displayed a menu, allowed a user to make a choice, and then performed actions. I think it was supposed to keep track of bar tabs. Rewriting something from a web tutorial or out of a book is a great place to start. There is more to be gained from actually rewriting it than just copying and pasting it and seeing if it will compile or work. However, rewriting code verbatim can only take you so far. Eventually you have to write your own code. This is where #1 from above comes in. Give yourself a small project and then see it through. Don't overshoot, keep it simple, and all that. After you've written it, analyze your work. Could you have designed it better? If you completed the same mundane task, call it A, a bunch of times, is there something you could have done to have made that easier? Think about if you wanted to build off the code you wrote to enhance the application. How easy would that be and if it wouldn't be easy, why not? Go through this all on your own and find your own answers. Now rewrite it and see if it's better. This is why you keep the project simple. Repeat this process a few times until you can't possibly do it any better. Finally, seek out your mentor and show them what you've done. Ask for their advice. "This is how I accomplished this task with what I know. You know more than me, how would you have done it?" That is how humans learn any and all subjects.
×
×
  • 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.