Jump to content

roopurt18

Staff Alumni
  • Posts

    3,746
  • Joined

  • Last visited

    Never

Everything posted by roopurt18

  1. Possibly a bug or constraint in how arrays (or foreach) are implemented?
  2. My desire to go into game development did spark my interest in computer programming. But I quickly became more interested in programming than I did game development. True I had the dream of being a game developer for many years, from about 1995 to 2005 or 2006, but I'd decided a long time ago if I couldn't program games I'd program something else. Hardware, CAD programs, microwaves, cell phones, whatever; I like problem-solving with computers and I've known that for a long time now. I didn't go to college to learn how to be a game developer though. Like many in this thread I knew I could learn anything I needed to on my own. I went to college to avoid the fate of my father, who I watched struggle to run his own business for a decade. He struggled because he didn't have the proper work ethic or mind to run his own business. But he also had a family to support and couldn't take time to go back to school or learn the necessary skills to get an office job. Meanwhile his brother and sister, both college educated, had steady jobs, steady income, steady hours, paid vacations, weekends off, and worked in air conditioned offices on the hottest summer days while I helped my dad install cabinets and melted in the heat. I went on jobs with him from the time I was 5 or 6 through high school and even a few here and there during college. I decided "fuck this" a long time before most kids even think about college. So no, I didn't go to college to be a game developer. I went to college because I associate not having a degree with working crazy hours, not being able to provide for your family, always telling people I don't know when I can pay them, having to settle for Top Ramen for a week at a time, wearing shit clothes, only going out when there's coupons, constantly bartering for shit, always getting the shit end of the stick, having to ask family members for financial help, marital arguments, etc. I associate having a degree with coasting through life. That's sure what my aunt and uncle seemed to do. I had three consecutive next-door neighbors that were computer programmers with degrees that looked like they were coasting through life; my dad worked 13 or 14 hour days on Sunday in the summer heat while those guys sat in lawn chairs and drank ice cold beer. I went to college because I saw the success it brought others. I also saw that our world is moving towards one that requires a degree for just about every job under the sun. Tie this together with the fact that I plan to have kids some day and I wanted to set a good example for them. I'm not meaning to gloat, but I'm faring pretty well in this shit storm of an economy. I plan to fare just as well, or better, when I have children. And I also plan to make sure they associate all that I provide or that we obtain as a family as originating from that degree on the wall. To anyone that thinks 4 years of their time to obtain a higher education may be difficult or asking too much of them, I scoff. Try having a wife and kids expecting you to provide for them when you don't have the means. See how difficult that is after 30 or 40 years, if your marriage makes it that long. I'm not saying things work out equally for everyone though. Every person is allowed to gamble with their own life as they see fit as long as it doesn't endanger others. I'm not a gambling man though and I always try to stack the odds in my favor. I had an English teacher in high school that always said, "Set yourself up for success, not stress." How right she is. Now having said all that, college used to be for the elite and, at the very least, intelligent. It seems to me that college has become more and more accessible in recent years to the detriment of the worth of a college education. I know I was consistently disappointed by my peers in college, having believed when I arrived there I'd be surrounded by the best of the best. "These are the brightest kids in America? We're so !@#$ed." (edit for typos)
  3. Well that's interesting. But why not just use: <?php foreach( $data as $key => $value ) { echo $key; }
  4. Coming from a C background and knowing that you really mean strings in PHP, that's a pretty funny statement! (I'm not poking fun at you; I'm just saying if you really know what was happening under the hood, then you'd be really, really afraid of strings!)
  5. The best way to learn is via good mentors. With the invention of the internet you can find mentors who don't even know they're mentoring you! 1) Hang out in the proper IRC channels. Find the most active channels for PHP, MySQL, PostgreSQL, MSSQL, Linux, security, whatever you're interested in. Be a lurker, not a contributor. Read the conversations that occur. Just be watching people ask questions and reading responses you'll learn all sorts of things. 2) Write code. Then rewrite it to be better. Then rewrite it to be better again. And keep doing this until you can't possible make it better. Then post your final version here asking for help on making it even better and hope someone comes along and helps you out. Like this fellow did here: http://www.phpfreaks.com/forums/index.php/topic,296449.msg1404483.html#msg1404483 (I only post one in which I replied because it was easier for me to pull it up, not for self-advertising or some such nonsense.) 3) There are many, many experienced and talented individuals in this community as well as on other online communities. For example, if you've read the MySQL board long enough, then you know fenway is (or at least once was) a very active and knowledgeable member there. So if you wanted to take some time to learn about MySQL, you might look at fenway's most recent posts. There you will see people asking questions and how fenway goes about solving the problems. Find the talented members on these boards and just read their post history. You'll learn loads about how they go about solving problems. 4) Branch out to other areas. Most of us here are interested in web development and if you're just learning web development, then you should stick with web development topics. Once you become comfortable with web development, you will only help yourself by reading about topics that are not directly related to web development. Read about software design or engineering. Buy a book like Game Programming Gems and see the nifty types of tricks programmers apply in other fields; believe it or not, that stuff will affect how you solve programming problems for web-based stuff because your base knowledge will have expanded outside your normal thinking box. 5) Invent problems and create solutions. For example, solve this problem: You maintain a PHP and database application. It is installed in various locations and does not have an automatic update procedure. Each new version of the software can potentially come with database schema changes. Support technicians are constantly struggling when updating the software at client locations with which database schema changes need to be applied. If the database schema is not correct for the program version, then the program is unstable and crashes. Add a command to the program such that when a technician updates the code at a client location, they can run this one command and the program will apply the necessary schema changes. This command should be generic enough that it can be used for any application.
  6. I've got something else to add to this thread. Remember earlier that I said a degree guarantees nothing but may grant options. Now consider the following: 1) The world is gravitating more and more towards one that favors educated people with certificates. Sure the world really boils down to who you know and their station, but if you're network is small a degree can be a boost. 2) It's infinitely easier to go get that degree now while you're young than it is when you're middle aged with a wife, kids, and mortgage to support. I've seen several men with families struggling to get degrees later in life; it really takes a toll on them. 3) If you plan on having kids, then that degree is a great example to them. Because I have a degree, when my kids are giving me shit about not wanting to do their homework I can point to the degree on my wall and say, "Why do you have to do your homework? Because that's what you do. I got where I am in life because of my degree and I got that degree by coming home and doing my homework. Now go do your damn homework." Of course I'm lying about doing my homework, but they won't know that! My advice is to get that degree now while it's easy and make sure it's usable after you graduate.
  7. No. You can't do it any other way than with a unique key and be 100% certain it will always work. Why? Because today your application is the only one that interacts with the database. Tomorrow maybe someone else may import data into your app. Will they ensure that only unique values are inserted? Probably not. These types of rules must be enforced by the database, not the application. So I refer the OP to the MySQL documentation on creating an index: http://dev.mysql.com/doc/refman/5.0/en/create-index.html create unique index ...
  8. This is an odd question. What exactly do you mean by alternative method? If you want to calculate an md5 hash in PHP code then you use the built-in function named md5() and you pass it one argument, the value you want hashed. Therefore if you want to use md5 to hash the value google using a PHP program, your program would contain at least this: <?php md5( 'google' ); ?> Now that small program calculates the md5 hash of the value google, but it doesn't echo the value nor does it save it in a variable, file, or database. So you probably want at least this much: <?php $hashed = md5( 'google' ); ?> That calculates the md5 and stores it in the variable $hashed. But the value in $hashed is not used for anything. So here is where you decide what to do with the hashed value. Will you echo it to the screen? <?php $hashed = md5( 'google' ); echo $hashed; ?> Will you insert it into a database? <?php $hashed = md5( 'google' ); $user = 'joesmith'; $db = mysql_connect( 'host', 'user', 'pass', 'dbname' ); // Not that I've not called mysql_real_escape_string, but you should! mysql_query( "insert into users ( username, password ) values ( '{$user}', '{$hashed}' )" ); ?> Most of us are having a hard time figuring out exactly what you're asking.
  9. $time_zone_difference = 25200; // 7 hours x 3600 You shouldn't perform timezone conversions in such a way. Which version of PHP do you have? Is it at least 5.2?
  10. I've since re-written this code to not use PDO and just use the sequence of: pg_connect(); pg_query( $script ); pg_close(); And it works fine. But I can't seriously be the only programmer on these boards with this issue and PDO? Has nobody else tried this?
  11. roopurt18

    Invoices

    If you are adding and subtracting dollar amounts, then you should be using arbitrary precision functions like those in bcmath or gmp. People on the business end of things can be very forgiving about a lot of things. One thing they are not forgiving about is when the money amounts are wrong.
  12. My father was a general contractor and he primarily built custom cabinets for homes. He was a one man shop which meant he had to find clients, nurture relationships, and then put in the necessary time to get the actual work done. It's really a two person job unless you're established to the point that clients are coming to you. This is where working for a company or at least with a partner who specializes in the business aspect of things can help. They'll wade through the bullshit that I don't have patience for to get the work orders in. Just be prepared to work a lot unless you land a really good gig.
  13. Why not just do this: <?php $stripped = preg_replace( '/[^a-z0-9_]/i', '', $string ); ?> Might have to adjust the regexp a bit to get the desired affect.
  14. roopurt18

    Invoices

    @btherl For partial cents why not use numeric(9,3) or numeric(9,4) along with arbitrary precision math libraries? Oh. I just saw but it's ok for the situations we use it in, which I suppose answers my question. But I'm still replying so the OP can see alternative solutions.
  15. This is probably because your hidden input is named submit. In JavaScript, form.submit() is normally a function that submits the form. However, in some (or all?) browsers, form.ident will also refer to controls in your form. For example, if you have a text input on your form called first_name, in your JavaScript you can use: alert( form.first_name.value ); Now like I said, form.submit() should be a function. But you've named a hidden input submit. So now form.submit refers to a hidden input and form.submit() is probably a JavaScript error.
  16. Individuals who succeed without degrees are the exception, not the rule. Having a degree doesn't guarantee anything while not having a degree can be a substantial road block. A degree is typically only important for that first job, but I wouldn't hold it past future employers to be weary of hiring someone who doesn't hold a degree. I have a B.S. in computer science and a minor in physics. I've worked full-time, approximately 6 to 8 hours per day, for almost five years now at two different small private businesses. I think I started in the low 60K U.S.D. and am now in the low 70K U.S.D.; I'm not entirely sure because my wife handles all of the finances. Honestly though I think a degree is just a special certificate that says, "Yes. I can fall in line, complete a goal, and tolerate the politics and bullshit of the professional world."
  17. I can't help you with numbers or your exact questions, but I can say that I always buy Altec Lansing or Klipsch and rarely am I disappointed.
  18. Does anyone know how run a script.sql via PDO for PostgreSql? A while back, I initially tried this: <?php $sql = file_get_contents( 'script.sql' ); $pdo->query( $sql ); ?> But it failed. I eventually found that this was the way: <?php $sql = file_get_contents( 'script.sql' ); $st = $pdo->prepare( $sql ); $st->execute(); ?> It worked for a long time on Windows. Then when I migrated my code to Linux it stopped working and I had to update my code to do this: <?php $sql = file_get_contents( 'script.sql' ); $st = $pdo->prepare( $sql, array( PDO::ATTR_EMULATE_PREPARES => true ) ); $st->execute(); ?> Then I had a script.sql with regular expressions in queries. The regular expressions had question marks in them. So then PDO's prepare() method thought my query had parameters and wouldn't run them. So I had to change my code to this: <?php $sql = file_get_contents( 'script.sql' ); $sql = str_replace( '?', "\\077", $sql ); $st = $pdo->prepare( $sql, array( PDO::ATTR_EMULATE_PREPARES => true ) ); $st->execute(); ?> Now I've moved my code to a new Linux box that has, what I believe, are the latest versions of libpq, PDO, and pdo_pgsql and it doesn't work. I'm getting errors about bound parameters again, even though I've used str_repalce() to change question marks to their octal equivalent. This leads me to believe that PDO might be translating the octal codes back to question marks. Is there any way to accomplish this task with PDO?
  19. I don't see why you don't just change the column type to datetime and instead of storing 2010-04 just store 2010-04-01 00:00:00. VARCHAR(64) is 57 more bytes more than you need. datetime is usually 8 or 9 bytes which is 1 or 2 more than you need, but it allows you to use the datetime functions which make calculating date differences very easy. Alternatively you could CONCAT '-01' to your column value and CAST that to datetime and still use the datetime functions. But VARCHAR(64) is a bad design decision.
  20. <?php ob_start(); echo 'abc'; $output = ob_get_clean(); echo $output; ?>
  21. What's the datatype for the column that stores the 2010-04 Is it varchar? Or is it a datetime or timestamp column? Do you want it to display only on the 45th day later? Or should it display as long as it's at least 45 days old?
  22. You can do all of this with wget I believe. It's a free program on GNU/Linux and Win32 versions are available. Just read the documentation and make a BAT or bash script depending on your OS.
  23. Why do you have to do this with JavaScript? Why not use the IE comment-hacks to include a small CSS file with changes for IE? Or why not define a special class in your CSS with these attributes and just add or remove the class to the div element with JavaScript?
  24. In most instances an exception caught at the top-level does mean the application is in an unusable state. This would most like occur when active directory, a domain server, or the database server is unavailable. In those instances, my application can't be used.
×
×
  • 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.