Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //-----GAME FUCNTIONS
- function findGame($gameInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- //Takes in information about a game and outputs a complete record if it exists
- //If more than one game exists, return a list of matching games
- //If the game does not exist=FALSE
- $first = TRUE;
- $query = 'SELECT * FROM Games WHERE ';
- $columns = array('id', 'White', 'Black', 'Result', 'Opening', 'Event', 'Location', 'Round', 'Date', 'PGN');
- for($x = 0; $x < count($columns); $x++){
- $key = $columns[$x];
- if( isset( $gameInfo[ $key ] ) && !empty( $gameInfo[ $key ] ) ){
- if($first){
- $query .= "$key = '".mysqli_real_escape_string( $con, $gameInfo[ $key ] )."'\n";
- }else{
- $query .= "AND $key ='".mysqli_real_escape_string( $con, $gameInfo[ $key ] )."'\n";
- }
- $first = FALSE;
- }
- }
- $result = mysqli_query($con, $query) or die( mysqli_error( $con ) );
- $output = array();
- if($row = mysqli_fetch_array($result)){
- $output = $row;
- }
- $output = ( empty( $output ) ? FALSE : $output );
- return $output;
- }
- function createGame($gameInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- //Takes in information about a game and outputs a complete record if the game was created successully
- //if the game failed to create, return FALSE or DIE
- /*Minimum information to create game:
- -White
- -Black
- -Result
- -PGN
- */
- $White = ( empty( $gameInfo['White' ] ) ? '' : mysqli_real_escape_string( $con, $gameInfo['White' ] ) );
- $Black = ( empty( $gameInfo['Black' ] ) ? '' : mysqli_real_escape_string( $con, $gameInfo['Black' ] ) );
- $Result = ( empty( $gameInfo['Result' ] ) && ! isset($gameInfo['Result']) ? '' : mysqli_real_escape_string( $con, $gameInfo['Result' ] ) );
- $Opening = ( empty( $gameInfo['Opening' ] ) ? 'NULL' : mysqli_real_escape_string( $con, $gameInfo['Opening' ] ) );
- $Event = ( empty( $gameInfo['Event' ] ) ? 'NULL' : mysqli_real_escape_string( $con, $gameInfo['Event' ] ) );
- $Location = ( empty( $gameInfo['Location' ] ) ? 'NULL' : mysqli_real_escape_string( $con, $gameInfo['Location' ] ) );
- $Round = ( empty( $gameInfo['Round' ] ) ? 'NULL' : mysqli_real_escape_string( $con, $gameInfo['Round' ] ) );
- $Date = ( empty( $gameInfo['Date' ] ) ? 'NULL' : mysqli_real_escape_string( $con, $gameInfo['Date' ] ) );
- $PGN = ( empty( $gameInfo['PGN' ] ) ? '' : mysqli_real_escape_string( $con, $gameInfo['PGN' ] ) );
- $output = FALSE;
- if($White != '' && $Black != '' && $Result != '' && $PGN != ''){
- $result = mysqli_query($con, "INSERT INTO Games (White, Black, Result, Opening, Event, Location, Round, Date, PGN)
- VALUES ('$White', '$Black', '$Result', '$Opening', '$Event', '$Location', '$Round', '$Date', '$PGN')") or die( mysqli_error( $con ) );
- $id = mysqli_insert_id($con) or die( mysqli_error( $con ) );
- $result = mysqli_query($con, "SELECT * FROM Games WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- }
- return $output;
- }
- function updateGame($gameInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- //Game must be identified by it's unique ID
- //ELSE return the updated entry
- $columns = array('White', 'Black', 'Result', 'Opening', 'Event', 'Location', 'Round', 'Date', 'PGN');
- $id = ( empty( $gameInfo['id'] ) ? 'ESCAPE' : mysqli_real_escape_string( $con, $gameInfo['id'] ) );
- if($id == 'ESCAPE'){
- return FALSE;
- }
- for($x = 0; $x < count($columns); $x++){
- $column = $columns[ $x ];
- $query = ( empty( $gameInfo[ $columns[ $x ] ] ) ? '' : mysqli_real_escape_string( $con, $gameInfo[ $columns[ $x ] ] ) );
- if($query != ''){
- mysqli_query($con, "UPDATE Games SET $column = '$query' WHERE id = '$id'") or die( mysqli_error( $con ) );
- }
- }
- $result = mysqli_query($con, "SELECT * FROM Games WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- return $output;
- }
- //-----PLAYER FUNCTIONS
- function findPlayer($playerInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- //Takes in information about a game and outputs a complete record if it exists
- //If the game does not exist=FALSE
- $first = TRUE;
- $query = 'SELECT * FROM Players WHERE ';
- $columns = array('id', 'Name', 'ELO', 'FirstGame', 'LastGame', 'Country', 'GamesPlayed');
- for($x = 0; $x < count($columns); $x++){
- $key = $columns[$x];
- if( isset( $playerInfo[ $key ] ) && !empty( $playerInfo[ $key ] ) ){
- if($first){
- $query .= "$key = '".mysqli_real_escape_string( $con, $playerInfo[ $key ] )."'\n";
- }else{
- $query .= "AND $key ='".mysqli_real_escape_string( $con, $playerInfo[ $key ] )."'\n";
- }
- $first = FALSE;
- }
- }
- $result = mysqli_query($con, $query) or die( mysqli_error( $con ) );
- $output = array();
- if($row = mysqli_fetch_array($result)){
- $output = $row;
- }
- $output = ( empty( $output ) ? FALSE : $output );
- return $output;
- }
- function createPlayer($playerInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- //Takes in information about a player and outputs a complete record if the player was created successfully
- //If the player failed to create, return FALSE or DIE
- $Name = ( empty( $playerInfo['Name' ] ) ? '' : mysqli_real_escape_string( $con, $playerInfo['Name' ] ) );
- $ELO = ( empty( $playerInfo['ELO' ] ) ? '0' : mysqli_real_escape_string( $con, $playerInfo['ELO' ] ) );
- $FirstGame = ( empty( $playerInfo['FirstGame' ] ) ? '50000101': mysqli_real_escape_string( $con, $playerInfo['FirstGame' ] ) );
- $LastGame = ( empty( $playerInfo['LastGame' ] ) ? '00000101': mysqli_real_escape_string( $con, $playerInfo['LastGame' ] ) );
- $Country = ( empty( $playerInfo['Country' ] ) ? '' : mysqli_real_escape_string( $con, $playerInfo['Country' ] ) );
- $GamesPlayed= ( empty( $playerInfo['GamesPlayed'] ) ? '0' : mysqli_real_escape_string( $con, $playerInfo['GamesPlayed' ] ) );
- $output = FALSE;
- if($Name != ''){
- $result = mysqli_query($con, "INSERT INTO Players (Name, ELO, FirstGame, LastGame, Country, GamesPlayed)
- VALUES ('$Name', '$ELO', '$FirstGame', '$LastGame', '$Country', '$GamesPlayed')") or die( mysqli_error( $con ) );
- $id = mysqli_insert_id($con);
- $result = mysqli_query($con, "SELECT * FROM Players WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- }
- return $output;
- }
- function updatePlayer($playerInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- //Game must be identified by it's unique ID
- //ELSE return the updated entry
- $columns = array('id', 'Name', 'ELO', 'FirstGame', 'LastGame', 'Country', 'GamesPlayed');
- $id = ( empty( $playerInfo['id'] ) ? 'ESCAPE' : mysqli_real_escape_string( $con, $playerInfo['id'] ) );
- if($id == 'ESCAPE'){
- return FALSE;
- }
- for($x = 0; $x < count($columns); $x++){
- $column = $columns[ $x ];
- $query = ( empty( $playerInfo[ $columns[ $x ] ] ) ? '' : mysqli_real_escape_string( $con, $playerInfo[ $columns[ $x ] ] ) );
- if($query != ''){
- mysqli_query($con, "UPDATE Players SET $column = '$query' WHERE id = '$id'") or die( mysqli_error( $con ) );
- }
- }
- $result = mysqli_query($con, "SELECT * FROM Players WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- return $output;
- }
- //-----POSITION FUNCTIONS
- function findPosition($positionInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $first = TRUE;
- $query = 'SELECT * FROM Positions WHERE ';
- $columns = array('id', 'FEN', 'Side', 'Evaluated', 'Eval', 'EvalTime', 'TimesPlayed', 'WhiteWinRate', 'BlackWinRate', 'DrawRate', 'CoordX', 'CoordY', 'CoordZ');
- for($x = 0; $x < count($columns); $x++){
- $key = $columns[$x];
- if( isset( $positionInfo[ $key ] ) && !empty( $positionInfo[ $key ] ) ){
- if($first){
- $query .= "$key = '".mysqli_real_escape_string( $con, $positionInfo[ $key ] )."'\n";
- }else{
- $query .= "AND $key ='".mysqli_real_escape_string( $con, $positionInfo[ $key ] )."'\n";
- }
- $first = FALSE;
- }
- }
- $result = mysqli_query($con, $query);
- $output = array();
- if($row = mysqli_fetch_array($result)){
- $output = $row;
- }
- $output = ( empty( $output ) ? FALSE : $output );
- return $output;
- }
- function createPosition($positionInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- /*Minimum information required to create a position:
- -FEN
- -Side
- */
- $FEN = ( empty( $positionInfo['FEN' ] ) ? '' : mysqli_real_escape_string( $con, $positionInfo['FEN' ] ) );
- $Side = ( empty( $positionInfo['Side'] ) && !isset($positionInfo['Side'] ) ? '' : mysqli_real_escape_string( $con, $positionInfo['Side'] ) );
- $Evaluated = ( empty( $positionInfo['Evaluated' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['Evaluated' ] ) );
- $Eval = ( empty( $positionInfo['Eval' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['Eval' ] ) );
- $EvalTime = ( empty( $positionInfo['EvalTime' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['EvalTime' ] ) );
- $TimesPlayed = ( empty( $positionInfo['TimesPlayed' ] ) ? '1' : mysqli_real_escape_string( $con, $positionInfo['TimesPlayed' ] ) );
- $WhiteWinRate = ( empty( $positionInfo['WhiteWinRate' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['WhiteWinRate' ] ) );
- $BlackWinRate = ( empty( $positionInfo['BlackWinRate' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['BlackWinRate' ] ) );
- $DrawRate = ( empty( $positionInfo['DrawRate' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['DrawRate' ] ) );
- $CoordX = ( empty( $positionInfo['CoordX' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['CoordX' ] ) );
- $CoordY = ( empty( $positionInfo['CoordY' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['CoordY' ] ) );
- $CoordZ = ( empty( $positionInfo['CoordZ' ] ) ? '0' : mysqli_real_escape_string( $con, $positionInfo['CoordZ' ] ) );
- $output = FALSE;
- if($FEN != '' && $Side != ''){
- $result = mysqli_query($con, "INSERT INTO Positions (FEN, Side, Evaluated, Eval, EvalTime, TimesPlayed, WhiteWinRate, BlackWinRate, DrawRate, CoordX, CoordY, CoordZ)
- VALUES ('$FEN', '$Side', '$Evaluated', '$Eval', '$EvalTime', '$TimesPlayed', '$WhiteWinRate', '$BlackWinRate', '$DrawRate', '$CoordX', '$CoordY', '$CoordZ')") or die( mysqli_error( $con ) );
- $id = mysqli_insert_id($con) or die( mysqli_error( $con ) );
- $result = mysqli_query($con, "SELECT * FROM Positions WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- }
- return $output;
- }
- function updatePosition($positionInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $columns = array('FEN', 'Side', 'Evaluated', 'Eval', 'EvalTime', 'TimesPlayed', 'WhiteWinRate', 'BlackWinRate', 'DrawRate', 'CoordX', 'CoordY', 'CoordZ');
- $id = ( empty( $positionInfo['id'] ) ? 'ESCAPE' : mysqli_real_escape_string( $con, $positionInfo['id'] ) );
- if($id == 'ESCAPE'){
- return FALSE;
- }
- for($x = 0; $x < count($columns); $x++){
- $column = $columns[ $x ];
- $query = ( empty( $positionInfo[ $columns[ $x ] ] ) ? '' : mysqli_real_escape_string( $con, $positionInfo[ $columns[ $x ] ] ) );
- if($query != ''){
- mysqli_query($con, "UPDATE Positions SET $column = '$query' WHERE id = '$id'") or die( mysqli_error( $con ) );
- }
- }
- $result = mysqli_query($con, "SELECT * FROM Positions WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- return $output;
- }
- //-----POSITON RELATION FUNCTIONS
- function findPositionRelation($relationInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $first = TRUE;
- $query = 'SELECT * FROM PositionsRelations WHERE ';
- $columns = array('id', 'PlayedMove', 'ParentID', 'ChildID', 'TimesPlayed');
- for($x = 0; $x < count($columns); $x++){
- $key = $columns[$x];
- if( isset( $relationInfo[ $key ] ) && !empty( $relationInfo[ $key ] ) ){
- if($first){
- $query .= "$key = '".mysqli_real_escape_string( $con, $relationInfo[ $key ] )."'\n";
- }else{
- $query .= "AND $key ='".mysqli_real_escape_string( $con, $relationInfo[ $key ] )."'\n";
- }
- $first = FALSE;
- }
- }
- $result = mysqli_query($con, $query);
- $output = array();
- if($row = mysqli_fetch_array($result)){
- $output = $row;
- }
- $output = ( empty( $output ) ? FALSE : $output );
- return $output;
- }
- function createPositionRelation($relationInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- /*Minimum information required to create a position relation:
- -PlayedMove
- -ParentID
- -ChildID
- */
- $PlayedMove = ( empty( $relationInfo['PlayedMove' ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo['PlayedMove' ] ) );
- $ParentID = ( empty( $relationInfo['ParentID' ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo['ParentID' ] ) );
- $ChildID = ( empty( $relationInfo['ChildID' ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo['ChildID' ] ) );
- $TimesPlayed = ( empty( $relationInfo['TimesPlayed' ] ) ? '1' : mysqli_real_escape_string( $con, $relationInfo['TimesPlayed'] ) );
- $output = FALSE;
- if($PlayedMove != '' && $ParentID != '' && $ChildID != ''){
- $result = mysqli_query($con, "INSERT INTO PositionsRelations (PlayedMove, ParentID, ChildID, TimesPlayed)
- VALUES ('$PlayedMove', '$ParentID', '$ChildID', '$TimesPlayed')") or die( mysqli_error( $con ) );
- $id = mysqli_insert_id($con) or die( mysqli_error( $con ) );
- $result = mysqli_query($con, "SELECT * FROM PositionsRelations WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- }
- return $output;
- }
- function updatePositionRelation($relationInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $columns = array('PlayedMove', 'ParentID', 'ChildID', 'TimesPlayed');
- $id = ( empty( $relationInfo['id'] ) ? 'ESCAPE' : mysqli_real_escape_string( $con, $relationInfo['id'] ) );
- if($id == 'ESCAPE'){
- return FALSE;
- }
- for($x = 0; $x < count($columns); $x++){
- $column = $columns[ $x ];
- $query = ( empty( $relationInfo[ $columns[ $x ] ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo[ $columns[ $x ] ] ) );
- if($query != ''){
- mysqli_query($con, "UPDATE PositionsRelations SET $column = '$query' WHERE id = '$id'") or die( mysqli_error( $con ) );
- }
- }
- $result = mysqli_query($con, "SELECT * FROM PositionsRelations WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- return $output;
- }
- //-----GAME RELATION FUNCTIONS
- function findGameRelation($relationInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $first = TRUE;
- $query = 'SELECT * FROM GamePositions WHERE ';
- $columns = array('id', 'PlayedMove', 'GameID', 'PositionID');
- for($x = 0; $x < count($columns); $x++){
- $key = $columns[$x];
- if( isset( $relationInfo[ $key ] ) && !empty( $relationInfo[ $key ] ) ){
- if($first){
- $query .= "$key = '".mysqli_real_escape_string( $con, $relationInfo[ $key ] )."'\n";
- }else{
- $query .= "AND $key ='".mysqli_real_escape_string( $con, $relationInfo[ $key ] )."'\n";
- }
- $first = FALSE;
- }
- }
- $result = mysqli_query($con, $query);
- $output = array();
- if($row = mysqli_fetch_array($result)){
- $output = $row;
- }
- $output = ( empty( $output ) ? FALSE : $output );
- return $output;
- }
- function createGameRelation($relationInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- /*Minimum information required to create a position relation:
- -PlayedMove
- -GameID
- -ChildID
- */
- $PlayedMove = ( empty( $relationInfo['PlayedMove' ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo['PlayedMove' ] ) );
- $GameID = ( empty( $relationInfo['GameID' ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo['GameID' ] ) );
- $PositionID = ( empty( $relationInfo['PositionID' ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo['PositionID' ] ) );
- $output = FALSE;
- if($PlayedMove != '' && $GameID != '' && $PositionID != ''){
- $result = mysqli_query($con, "INSERT INTO GamesPositions (PlayedMove, GameID, PositionID)
- VALUES ('$PlayedMove', '$GameID', '$PositionID')") or die( mysqli_error( $con ) );
- $id = mysqli_insert_id($con) or die( mysqli_error( $con ) );
- $result = mysqli_query($con, "SELECT * FROM GamesPositions WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- }
- return $output;
- }
- function updateGameRelation($relationInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $columns = array('PlayedMove', 'GameID', 'PositionID');
- $id = ( empty( $relationInfo['id'] ) ? 'ESCAPE' : mysqli_real_escape_string( $con, $relationInfo['id'] ) );
- if($id == 'ESCAPE'){
- return FALSE;
- }
- for($x = 0; $x < count($columns); $x++){
- $column = $columns[ $x ];
- $query = ( empty( $relationInfo[ $columns[ $x ] ] ) ? '' : mysqli_real_escape_string( $con, $relationInfo[ $columns[ $x ] ] ) );
- if($query != ''){
- mysqli_query($con, "UPDATE GamesPositions SET $column = '$query' WHERE id = '$id'") or die( mysqli_error( $con ) );
- }
- }
- $result = mysqli_query($con, "SELECT * FROM GamesPositions WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- return $output;
- }
- //-----OPENING FUNCTIONS
- function findOpening($openingInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $first = TRUE;
- $query = 'SELECT * FROM Openings WHERE ';
- $columns = array('id', 'ECOCode', 'Name', 'PGN', 'TimesPlayed');
- for($x = 0; $x < count($columns); $x++){
- $key = $columns[$x];
- if( isset( $openingInfo[ $key ] ) && !empty( $openingInfo[ $key ] ) ){
- if($first){
- $query .= "$key = '".mysqli_real_escape_string( $con, $openingInfo[ $key ] )."'\n";
- }else{
- $query .= "AND $key ='".mysqli_real_escape_string( $con, $openingInfo[ $key ] )."'\n";
- }
- $first = FALSE;
- }
- }
- $result = mysqli_query($con, $query);
- $output = array();
- if($row = mysqli_fetch_array($result)){
- $output = $row;
- }
- $output = ( empty( $output ) ? FALSE : $output );
- return $output;
- }
- function createOpening($openingInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- /*Minimum information required to create an opening:
- -ECOCode
- -Name
- -PGN
- -TimesPlayed
- */
- $ECOCode = ( empty( $openingInfo['ECOCode' ] ) ? '' : mysqli_real_escape_string( $con, $openingInfo['ECOCode' ] ) );
- $Name = ( empty( $openingInfo['Name' ] ) ? '' : mysqli_real_escape_string( $con, $openingInfo['Name' ] ) );
- $PGN = ( empty( $openingInfo['PGN' ] ) ? '' : mysqli_real_escape_string( $con, $openingInfo['PGN' ] ) );
- $TimesPlayed = ( empty( $openingInfo['TimesPlayed' ] ) ? '0' : mysqli_real_escape_string( $con, $openingInfo['TimesPlayed'] ) );
- $output = FALSE;
- if($ECOCode != '' && $Name != '' && $PGN != ''){
- $result = mysqli_query($con, "INSERT INTO PositionsRelations (ECOCode, Name, PGN, TimesPlayed)
- VALUES ('$ECOCode', '$Name', '$PGN', '$TimesPlayed')") or die( mysqli_error( $con ) );
- $id = mysqli_insert_id($con) or die( mysqli_error( $con ) );
- $result = mysqli_query($con, "SELECT * FROM PositionsRelations WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- }
- return $output;
- }
- function updateOpening($openingInfo, $con = NULL){
- if($con == NULL){
- $con = $GLOBALS['con'];
- }
- $columns = array('ECOCode', 'Name', 'PGN', 'TimesPlayed');
- $id = ( empty( $openingInfo['id'] ) ? 'ESCAPE' : mysqli_real_escape_string( $con, $openingInfo['id'] ) );
- if($id == 'ESCAPE'){
- return FALSE;
- }
- for($x = 0; $x < count($columns); $x++){
- $column = $columns[ $x ];
- $query = ( empty( $openingInfo[ $columns[ $x ] ] ) ? '' : mysqli_real_escape_string( $con, $openingInfo[ $columns[ $x ] ] ) );
- if($query != ''){
- mysqli_query($con, "UPDATE PositionsRelations SET $column = '$query' WHERE id = '$id'") or die( mysqli_error( $con ) );
- }
- }
- $result = mysqli_query($con, "SELECT * FROM PositionsRelations WHERE id = '$id'") or die( mysqli_error( $con ) );
- $output = mysqli_fetch_array($result) or die( mysqli_error( $con ) );
- return $output;
- }
- $con = mysqli_connect("127.0.0.1", "root", "<you aren't getting that!>", "Chess");
- //Location, User, Passkey, Database
- if (mysqli_connect_errno()){
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- } else {
- echo "Successfully Connected to mySQL server!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment