KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
AFAIK, there's no technical name for either style. Keep in mind - what your partner does would actually make a lot of sense if you were writing OOP*. PHP has a mechanism (well, a couple of them, actually) that allows for dynamic class loading - __autoload. That way you don't have to manually keep track of your includes. If you're just writing procedural code, the most widely used style would be to simply stuff reused functions in a library file (or several, based on theme) and include them when necessary. Functions needed for a particular page would be written in that page's code. *Stuffing a bunch of related-by-theme functions into a class isn't truly OOP. That, however, is a discussion outside of the scope of this topic.
-
I don't think that there's a clear winner in either case. His main code is more readable, but requires you to dig through his function definitions to get the full gist of what everything does. Yours takes away the bloat of the function definitions at the expense of overall readability. The two of you should come to a consensus about style, though, if you're going to be working on code together. It'll save yourselves future headaches.
-
I'd like to believe you on that, but man, there are still a lot of completely computer illiterate people around in my area of the world (NH, USA). What really baffles me is that a lot of them are in the same age range as I am, so it's not like it's a generational thing with all of them.
-
Try: $query = "INSERT INTO product_features (" . implode(', ', $checkBoxes) . ") VALUES (" . implode(', ', $data) . ")"; Or, even better, something like: $formBoxes = implode(', ', $checkboxes); $formData = implode(', ', $data); $query = "INSERT INTO product_features ($formBoxes) VALUES ($formData)";
-
Here's what I'd do: 1. Let the kid spec out what he wants - processor, HDD, GPU, etc. Make sure the kid bases these specs based on what he knows about the courses he'll likely take. 2. Go to various vendor sites (Asus, Dell, Toshiba, etc.) and price out a notebook with those specs. 3. Once you have a few options in a price range that's comfortable for you, visit review sites for reviews on those specific models. 4. Buy the one with the best aggregate reviews. There's no bulletproof brand out there. Instead, do your due diligence to ensure you get a good investment for your money.
-
That's definitely an idea, but I was hoping to not have a separate review for the same game on multiple platforms. Of course, I could always have a platforms_reviews pivot table... hmm.
-
I'm currently working on a game review site, and have hit a small snag with my db design. A lot of games are offered on multiple platforms, for example, the Grand Theft Auto series - the main games are available on PS3, XBOX 360, and the PC. I'm just wondering how I should model that, as right now I have a sketch that looks like: table reviews( id unsigned int not null auto-increment primary key, title varchar(45) not null, permalink varchar(45) not null, content text not null, genre_id unsigned int not null foreign key (genres) ) I'm just not sure how to properly tie the platform info to the reviews. Maybe a pivot table linking games to platforms?
-
I write my PHP through the sheer force of my will. The nose bleeds can get annoying, though.
-
Yup, which is encouraging. I doubt IE will ever be fully W3C compliant given Microsoft's track record to date, but so long as they cover the most widely used 75%-80% of the spec, I think most will be happy. It's kind of like those special kids in school - they may not make the honor roll, but so long as they're not eating the paste and disturbing the other students, it's a victory. It'll never replace FF for me, but I won't feel queasy using it when testing. Also, just for comparison, the current version of FF scores a 92/100 on the Acid3 test. In general, I thought MIX10 was pretty cool, from what I've read/seen. Thoughts: A lot of it was spent pimping WinPho 7, but that's to be expected. I'm actually interested in developing some apps for it, I just need to familiarize myself with Silverlight. Visual Studio 2010 looks great, and ASP.NET 4.0 will actually generate well-formed, semantic code and play nice with CSS. jQuery is now part of Visual Studio, which is a plus - intellisense, syntax highlighting, and all that jazz. Their Open Data Protocol is already in the wild, and I plan on using Netflix's OData for a project of mine. What's nice is that it's truly open - I downloaded their PHP module, and it seems fairly straightforward. Bill Buxton is a crazy dude.
-
Like Thorpe said, you need to validate all incoming data. Running data through an escape (like mysql_real_escape_string) should be the last step before database insertion.
-
Protip: If you do use Kohana, be sure to use mysqli in the database configuration if you're using a MySQL database. There's a bug in the low-level system code that stops the more familiar mysql option from working. It's not hard to fix, but I wouldn't recommend diving into the system files unless you know what you're looking for. It's a simple isset issue, but it's buried in the system. Hopefully they'll fix it in the next release. Other than that, I have had no complaints with Kohana so far. It's stupidly simple to use.
-
Pick your poison: setTimeout() setInterval() Most likely, you'll want to use setTimeout().
-
Instead of storing that info in an array, why not store it in an object?* It just seems like a simpler way to look at it, and it would increase readability. I mean, how would you access the info stored in a tile with the way you have it now? Something like: (map[1][5])[0]; // whatever that's supposed to return Right? With a tile object, you could have a method that makes it a lot easier to see what's going on: map[1][5].GetId(); //return the id of the tile at coordinates 1-5 This would also allow you to plug in other functionality into each individual tile. Are some tiles due for a buff/debuff? Add an observer. Do some give different bonuses? Wrap a decorator around them. The point is to not fight against Java's OO nature. Arrays are a useful tool, but not the only one available to you. Regarding your syntax error, I can't help you there. I don't know Java. My mostly-OO language of choice is C#, which is pretty similar to Java, from what I hear. *Yes, I know that arrays are objects in Java. I mean a proper object. ;-)
-
Why don't you tell us what you hope to do with this map? It's hard to get an idea of what you're attempting to do when you're being so vague. What is the map supposed to represent? What about each tile?
-
Frameworks are a good idea when writing production, "I have a project for a client and need to get results" code. There's really no good reason not to use one as they greatly increase productivity without impacting your own creativity. It's nice not having to write yet more database connection code, or yet another set of form validation statements. Seeing how frameworks work is also a good way to learn how professionals code, not just in terms of style, but with their technique as well. CodeIgniter is a good, popular choice. You may also want to check out the Zend Framework and Kohana (the PHP 5 version of CodeIgniter). Rolling your own has value, too, but mostly in terms of expanding your own knowledge. Learn why things work, experiment and dabble, but when it's time to pay the bills you'll be happy you chose a framework. I don't recommend using a template engine at all, regardless of the project. Native PHP is more than suited for the job, and doesn't incur the overhead of a 3rd party template system.
-
Thats ok if your headers havent been sent, othwise youll need javascript: function redirect( $url ){ if (! headers_sent( ) ){ header( "Location: ".$url ); exit( 0 ); } echo "<script language=Javascript>document.location.href='".$url."';</script>"; exit( 0 ); } redirect('http://www.yoursite.com/'); //redirect to any url Even better - code properly, so all of your PHP processing happens before headers are sent.
-
Also, just because this is a pet peeve of mine, JavaScript != Java. Aside from name, the two have nothing to do with one another. They're not even made by the same people.
-
Quickie - returning specific info from a Select * request
KevinM1 replied to spenceddd's topic in PHP Coding Help
SELECT ID, OX FROM PortfolioItems SELECT can do far more than merely return everything. -
I think some of the confusion stems from there not being much of a difference between a 'college' and 'university' in the US. A place like Boston College, for instance, is actually a four-year school, where one gets their Bachelor's upon graduation (if they don't stick around for their Master's or even Ph D.). In the US, the distinction is made between technical/community colleges/schools, which tend to be two-year, Associate's level affairs, and all the rest. The quality of technical/community schools tend to run the gamut. There are decent ones out there (Great Bay Community College comes to mind), and some not-so-great (Hesser, McIntosh when it was still around, Seacoast Community College). Starting at a two-year school would probably be the best for the OP. They focus on more job-oriented skills than the four-year schools do, and the time/money involved is low enough so that if they don't feel like it's a good fit, they can just leave with minimal effort. Just be sure to research the local schools. Ensure that they're actually accredited and actually give out real degrees. Around here, a lot of schools (I use the term lightly) give out 'certificates' upon completion, which are about as useful as used toilet paper when you add it on your resume (the aforementioned Seacoast Community College is one such place). Just IMO.
-
Well, I don't think there's much difference between using a db versus a text file in this case, aside from the reading/writing/updating mechanics. I'm a bit more comfortable using db's than writing to/reading from files simply because I interact with db's far more often in my daily activities.
-
Computer science is not about programming. Look for some sort of software engineering program if you want to do programming. Have a look at the course listing on your local university/college and see what they offer. My university only had one major called 'Computer Science' that spanned everything from digital logic to software engineering, programing and more. Same here. CS was the software engineering degree at my university.
-
Why not store and update the value in a db? <?php function maintenance_on_off($maint_on_off) { $query = "UPDATE table SET maintenance = $maint_on_off"; $result = mysql_query($query); if ($maint_on_off == "On") { header("Location: ../maintenance.php"); } else if ($maint_on_off == "Off") { /* do non-maintenance stuff */ } else { /* error */ } } if (isset($_POST['submit'])) { maintenance_on_off($_POST['maintStatus']); } ?> <!DOCTYPE html> <html> <head></head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> On: <input type="checkbox" name="maintStatus[]" value="On" /> Off: <input type="checkbox" name="maintStatus[]" value="Off" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> If you want to post to a different page, instead of having the form post to itself like I have it do above, simply put the path to the form handling code file as the form's action. Within that file, simply access the data through the $_POST superglobal array like always. So, in that file, you'd still access the checkbox data with $_POST['maintStatus'], and so on.