1. virtual pet mascot

    Virtual Pets

    Welcome to the Virtual Pet list forum!
    We're a virtual pets and sim games community and the largest forum in our industry. Game owners can use our forum to their advatange by promoting/advertising their games to our users and receive feedback/reviews from those members that try their games out. We support developers of all kinds from RPG developers, sim game developers to virtual pet site developers. We want to see more games in our industry come across more success and that's why we try our best to release as many guides/articles regarding online gaming development as we can.
    We're unlike other forums in our industry because we try our best to be there for our users no matter what and give them advice whenever they ask for it. Running an online game isn't an easy task, but with our many resources that we've built since 2011, you'll learn a lot from our online community. Please don't ever be afraid to ask a question on the forums because if you never ask, then you'll never receive an answer to your question and you can only improve by asking other users for help/advice.
    We have a lot of virtual pet sites' owners and sim game owners that are very frequent visitors on our online community. Along with artists, writers and programmers that come here looking for work and games to work for. Our members who are artists sell art in our art marketplace and programmers are allowed to sell their scripts in the programming marketplace. We also allow game owners to sell their game in our general marketplace
    In early 2011, we decided to make a comeback to the internet because in 2010, we had a minor setback and we had to re-launch without any content, but with a lot of time, patience, hardwork and effort, we've managed to rebuild the Virtual pet list community into something better than it was before. We actually registered our domain name on November 4th, 2004, but we were only a directory then and all we had was a basic comments system for users to post things on their favorite games..
    So, what are you waiting for, why don't you join today? If you have any problems figuring out our security code, then here's a hint, it has millions upon users and has been around since 1997.
    Our list of virtual pet sites and directory of sim games have a lot of different games listed, so we're pretty sure that you may find some games that suits your needs as a player of sim games or virtual pet sites.
    If you're still curious about a certain game that you'd like to play, then please check out some of our game reviews that were written by some of our great contributors and our interviews with respective virtual pet site owners, sim game owners, artists, writers and programmers that have worked in this industry.

  2. Check out our latest guide on how to grow your user base!
    Paladore - Boopets - Icepets - Corepets open beta
    Virtual Pet Directory
    Are you looking for new virtual pet sites or sim games to play?

Enclosing code in quotes.

Discussion in 'Programming General' started by SpotOnTech, Jun 28, 2012.

  1. SpotOnTech
    Offline

    SpotOnTech New Member VPL Member

    Reputations:
    0
    Joined:
    Jun 21, 2012
    Messages:
    15
    Likes Received:
    2
    Trophy Points:
    0
    While working on my newest client's site I noticed that most (almost all) of the code I saw in the files was formatted like this:
    PHP:
    if($_POST[attribute]
    function();

    if(!
    $_POST[attribute]
    function();
    No braces, no quotes. Although somewhat functional, there were more errors when I set the ini to display all errors than I care to mention. As I closed tags, removed print and changed it to echo I noted that all the errors cleared out. This is truly a sign of not only a beginning programmer, but a lazy one as well. Quotes are your friend, as are braces (and include files). 153 files in the root with no include files. Quite frustrating to say the least.

    Secondary rant: indenting. Indent your code, people. It makes going back over your code at a later date and makes your (or the next programmer's) life much easier.

    Yet another rant: comments. Comments are your friend.

    Yep, one more: non-escaped $_GET and $_POST. $_GET is fine if you HAVE to make the URL show data (user profiles and search results are a good example), but $_POST is best. It's harder to hijack, looks nicer when the whole site isn't set with ?action and ?id tags on the end of the URL.

    Source: 16 years as a programmer in Python, RoR, PHP/MySQL/MySQLi, ASSEMBLY, PERL, HTML/XHTML, CSS, Java, Javascript and BASIC (yes, BASIC).
     
    Last edited: Jun 28, 2012
    Avalanche likes this.
  2. Avalanche
    Offline

    Avalanche Supporter VPL Supporter

    Reputations:
    0
    Joined:
    May 30, 2011
    Messages:
    428
    Likes Received:
    82
    Trophy Points:
    0
    Location:
    USA
    I've only been programming for a little over four years. And I'll admit I'm self taught. But it was interesting to see the turning point where I felt as though I was no longer a newbie at programming. When I started fixing code that was terrible. I not only could recognize it, I could fix it. When I first realized that it was a big deal and I was so proud that I was better at someone else in programming.

    Now, I wish all programmer's were perfect gods so I wouldn't have to fix all their dumbass mistakes. >.> Amazing how the times change.
     
  3. ThomasMosey
    Offline

    ThomasMosey Member VPL Member

    Reputations:
    0
    Joined:
    Feb 5, 2012
    Messages:
    252
    Likes Received:
    34
    Trophy Points:
    28
    Gender:
    Male
    Location:
    Coventry, UK
    I've been programming a little over 6 years now, and to all the people who code like the example given in the OP:

    [​IMG]

    It just simply should not be done, especially if it's for commercial purposes.
     
  4. SpotOnTech
    Offline

    SpotOnTech New Member VPL Member

    Reputations:
    0
    Joined:
    Jun 21, 2012
    Messages:
    15
    Likes Received:
    2
    Trophy Points:
    0
    Here's a snippet of code from the contact form that I haven't gone over yet. By the time you read this, it'll be fixed since it's open in Notepad++, but this is as it stands as of posting:

    PHP:
    <?php
    $loggedin
    =notnecessary;
    include 
    "header.php";

    if(isset(
    $_GET['email'])){
    $name=$_POST['name'];
    $subject=$_POST['subject'];
    $emailaddy=$_POST['emailaddy'];
    $email=$_POST['email'];

    $to="[REDACTED]";
    $subject "Contact Form";
    $body "From: $name\nSubject: $subject\nEmail Address: $emailaddy\n\n

    $email";
    $from_header="From: [REDACTED]";
    mail($to,$subject,$body,$from_header);

    print 
    "Email successfully sent.";
    include 
    "footer.php";
    exit;
    }

    print 
    "<form method=post action=contact.php?email=yes>
    Your Name: <input type=text name=name><br>
    Your Email: <input type=text name=emailaddy><br>
    Subject: <input type=text name=subject><br>
    <textarea rows=20 cols=30 name=email>Email content here.</textarea><br>
    <input type=submit name=submit value='Send Email'></form>"
    ;

    include 
    "footer.php";
    ?>
    Oh, and no, it was not indented. Personally I enclose all my functions with parentheses to make it explicit. aka: echo("foo"); include("foo"); and I don't use print for anything.
     
  5. judda
    Offline

    judda Bringer of Awesome Moderator Pet Game Owner Programming Moderator

    Reputations:
    18
    Joined:
    Jan 23, 2011
    Messages:
    1,547
    Likes Received:
    422
    Trophy Points:
    83
    Not only will it throw warning, but it also executes a lot slower (approximately 4x).

    Speed test ... http://lnked.me/x9idd

    isset / empty should be used instead of forcing a hard read of the variable (i.e. isset($_POST['foo']) instead of $_POST['foo']). This is just wrong ...

    ~judda
     
  6. SpotOnTech
    Offline

    SpotOnTech New Member VPL Member

    Reputations:
    0
    Joined:
    Jun 21, 2012
    Messages:
    15
    Likes Received:
    2
    Trophy Points:
    0
    ...and that's exactly what I'm running into with over 20k lines of code in this site. I should have charged my per/hr rate instead of a flat fee.

    Edit: Also, since there are multiple arrays being passed, I usually cross-check it since say, if(isset($_GET['foo']) && $_GET['foo'] == "bar"). I'm not sure who the coders were of this site, but I'd like to hit them with my old Windows 3.11 manual.
     
    Last edited: Jun 28, 2012

Share This Page