OSdata.com: holistic issues 

OSdata.com

example source code
addvote.php

    Building a game — open source code This is the actual source code from a new web game. See the game at thissideofsanity.com and read how this was built starting at example code.

    This is example code from the SlamZee project and This Side of Sanity, released under Apache License 2.0.

    Copyright 2013 Milo (for software), Distribution and website handled by Strazbick.com

    Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

    This narrative uses anchor links so that you can follow the building of this software in chronological order. Go to software explanation to start reading. Go to thissideofsanity.com to see the working software.

Google

example source code
addvote.php

    This is example code from the SlamZee project and This Side of Sanity, released under Apache License 2.0.

add vote
first pass

    This PHP file receives an AJAX GET with a celebrity index key number and then uses an SQL UPDATE to increment the selected vote count and then an SQL SELECT to get the new total and echoes the new total, which in turn is placed into the correct target span by JavaScript on the browser side.

<?php

// include function files for this application
   require_once('./php/databasefunctions.php');

session_start();

/******************************/
/* GLOBALS                    */
/******************************/


/******************************/
/* FUNCTIONS                  */
/******************************/


/******************************/
/* Main Page                  */
/* record a hate vote         */
/******************************/

/* INITIALIZATIONS */
if(empty($_GET))
  { /*set to defaults */

    $postingflag = false;

    $asdf = $_GET['asdf'];

  }
else
  { /*collect input from user */

    $postingflag = true;
    $celebritycode = $_GET['celebrity'];

  } /* END if on GET */

$currentuser = $_SESSION['valid_user']; 

/* PREPARE */

/* get visitor information */

/* DATABASE CONNECTION */
$result = ConnectCelebDataBase(0);

if (!$result) exit('failed to connect');

/* PROCESS FORM */
if ($celebritycode == "")
  {
    $celebritycode = "NULL";
    exit('no celebrity chosen');
  }
else
  {
    if (!is_numeric($celebritycode)) /* allows for integer as a string */
      exit('invalid celebrity of '.$celebritycode);
    /*$celebritycode = "'".$celebritycode."'";*/
  }

$dailydate = '2013-09-18'; /* hard coded date */

/* INSERT VOTE INTO DAILY DATA BASE */
/* already connected and selected database */

// mysql_select_db('strazslam');

/* note that during processing we placed the variable inside the single quotes */
$query = "UPDATE celebrity SET votecount = (votecount + 1) WHERE celebnum=".$celebritycode." ";

$updateresult = mysql_query($query);

if(!$updateresult)
  {
    echo "<p>failed data base insert with error message ".mysql_error()."</p>";
  }

/* note failure with bigints that appear to be negative */

$newquery = "SELECT votecount FROM celebrity WHERE celebnum=".$celebritycode." ";

$selectresult = mysql_query($newquery);

$row = mysql_fetch_array($selectresult);

$newvotecount = $row["votecount"];

echo $newvotecount;

?>

return to explanation of source code


OSdata.com is used in more than 300 colleges and universities around the world

Find out how to get similar high web traffic and search engine placement.


OSdata.com is used in more than 300 colleges and universities around the world

Read details here.


    A web site on dozens of operating systems simply can’t be maintained by one person. This is a cooperative effort. If you spot an error in fact, grammar, syntax, or spelling, or a broken link, or have additional information, commentary, or constructive criticism, please e-mail Milo. If you have any extra copies of docs, manuals, or other materials that can assist in accuracy and completeness, please send them to Milo, PO Box 1361, Tustin, CA, USA, 92781.

    Click here for our privacy policy.


previous page next page
previous page next page

home page


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2013 Milo

    Last Updated: September 18, 2013

    Created: September 15, 2013

previous page next page
previous page next page