예제 #1
0
function CreateNews($sql)
{
    $dir = __DIR__ . "/../content/";
    move_uploaded_file($_FILES['content']['tmp_name'], $dir . $_FILES['content']['name']);
    dbConnect();
    mysql_query($sql);
}
예제 #2
0
function editEquipInfo()
{
    if (isset($_POST)) {
        $equipid = $_POST['update_equipid'];
        $equipname = $_POST['edit_equipname'];
        $equiptype = $_POST['edit_equiptype'];
        $status = $_POST['edit_status'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANITATION_EQUIP SET EQUIPID = '{$equipid}', EQUIPNAME = '{$equipname}' , EQUIPTYPE = '{$equiptype}', STATUS = '{$status}' WHERE EQUIPID = {$equipid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_equip.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
예제 #3
0
function selectReadings()
{
    $db = dbConnect();
    // $select = $db->query("SELECT * FROM yun");
    $select = $db->query("SELECT * FROM yun ORDER BY time DESC LIMIT 1");
    echo '"value": ' . "[";
    $values = "";
    /*while($row = $select->fetch()) {
      	$values .= $row['value'] . ",";
      }*/
    $values = $select->fetch()['value'];
    $values = rtrim($values, ",");
    echo $values;
    echo "], ";
    // $select = $db->query("SELECT * FROM yun");
    $select = $db->query("SELECT * FROM yun ORDER BY time DESC LIMIT 1");
    echo '"room": ' . '["';
    $rooms = "";
    /*while($row = $select->fetch()) {
        $rooms = 
      }*/
    $rooms = $select->fetch()['room'];
    $rooms = rtrim($rooms, ",");
    echo $rooms;
    echo '"]';
}
예제 #4
0
파일: s.php 프로젝트: barce/ezmvc
 function t()
 {
     $s_tag = $_SERVER['REQUEST_URI'];
     $s_tag = str_replace('/s/t/', '', $s_tag);
     $dbh = dbConnect();
     $sql = "select url from links where short_link = '{$s_tag}'";
     $res = mysql_query($sql, $dbh);
     $row = mysql_fetch_assoc($res);
     $url = $row['url'];
     if (strlen($url) <= 0) {
         return;
     }
     $sql = "select clicks from links where short_link = '{$s_tag}'";
     $res = mysql_query($sql, $dbh);
     $row = mysql_fetch_assoc($res);
     $clicks = (int) $row['clicks'];
     $clicks++;
     $sql = "update links set clicks = {$clicks} where short_link = '{$s_tag}'";
     $res = mysql_query($sql, $dbh);
     mysql_close($dbh);
     header("location: {$url}");
     echo "<script>\n";
     echo "window.location='{$url}';";
     echo "</script>\n";
 }
function markSessionExpired($id)
{
    $conn = dbConnect();
    $sql = " UPDATE fbUsers SET `sessionExpires`='" . date("Y-m-d", strtotime('yesterday')) . "' WHERE id='{$id}'";
    mysql_query($sql, $conn);
    mysql_close($conn);
}
예제 #6
0
function addContact()
{
    $conn = dbConnect();
    $name = '';
    $email = '';
    $mobile = '';
    $position = '';
    if (isset($_POST['name'])) {
        $name = $conn->real_escape_string($_POST['name']);
    }
    if (isset($_POST['email'])) {
        $email = $conn->real_escape_string($_POST['email']);
    }
    if (isset($_POST['mobile'])) {
        $mobile = $conn->real_escape_string($_POST['mobile']);
    }
    if (isset($_POST['position'])) {
        $position = $conn->real_escape_string($_POST['position']);
    }
    $sql = "INSERT into contactus(name,position,email,mobile) VALUES('{$name}','{$position}','{$email}','{$mobile}')";
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../contact.php");
    } else {
        echo "Some error occured..:(";
    }
}
예제 #7
0
파일: part.php 프로젝트: neas5791/dbPart2
function list_part()
{
    header('Content-Type: application/json');
    // get database connection object
    $pdo = dbConnect();
    try {
        $sql = 'SELECT
						tbPart.id AS "PID",  
			 			tbPart.descr AS "DESCRIPTION", 
			 			tbPart.image AS "IMAGE",
						IFNULL(tbDrawing.drawing_number,"") AS "DRAWING"
			 		FROM tbPart
			 		LEFT JOIN tbDrawing ON tbPart.id = tbDrawing.partid
			 		ORDER BY PID';
        $s = $pdo->prepare($sql);
        $s->execute();
        $results = $s->fetchAll();
        $th = array('PID', 'DESCRIPTION', 'DRAWING');
    } catch (PDOException $e) {
        $error = 'Error getting Type list:<br>' . $e->getMessage();
        echo $error;
    }
    // send $results array
    echo json_encode($results);
}
예제 #8
0
function db_query($sql, $proxyFields)
{
    $con = dbConnect();
    if ($con == null) {
        return null;
    }
    foreach (array_keys($proxyFields) as $key) {
        $value = mysqli_real_escape_string($con, $proxyFields[$key]);
        if (is_string($value)) {
            $value = "\"{$value}\"";
        }
        $sql = str_replace($key, $value, $sql);
    }
    $result = mysqli_query($con, $sql);
    if (!$result) {
        echo "has error";
        print_r(debug_backtrace());
        $firstCall = end(debug_backtrace());
        $errMsg = "Error calling " . $firstCall["function"];
        $errMsg .= " on line " . $firstCall["line"];
        $errMsg .= " in " . $firstCall["file"] . ": " . mysqli_error($con);
        dbErrorMsg($errMsg);
        return false;
    } else {
        if (strpos($sql, "INSERT") !== false) {
            return mysqli_insert_id($con);
        } else {
            return new result($result);
        }
    }
    dbClose($con);
}
예제 #9
0
function makeContent($user, $password)
{
    if (isset($_GET['dbConnect'])) {
        createFormular($GLOBALS['formularAction']);
        dbConnect($user, $password);
    } elseif (isset($_GET['dbShowAll'])) {
        createFormular($GLOBALS['formularAction']);
        listCompany($user, $password);
    } elseif (isset($_GET['logout'])) {
        createFormular($GLOBALS['formularAction']);
        session_start();
        unset($_SESSION);
        session_destroy();
        session_write_close();
        header('Location: http://localhost/');
        die;
    } elseif (isset($_GET['dbAdd'])) {
        createFormular($GLOBALS['formularAction']);
        createDBAddFormular($GLOBALS['formularAction']);
    } elseif (isset($_GET['dbTryAdd'])) {
        createFormular($GLOBALS['formularAction']);
        createDBAddFormular($GLOBALS['formularAction']);
        addCompany($user, $password);
    } elseif (isset($_GET['dbDel'])) {
        createFormular($GLOBALS['formularAction']);
        createDBDelFormular($GLOBALS['formularAction']);
    } elseif (isset($_GET['dbTryDel'])) {
        createFormular($GLOBALS['formularAction']);
        createDBDelFormular($GLOBALS['formularAction']);
        delCompany($user, $password);
    } else {
        createFormular($GLOBALS['formularAction']);
    }
}
예제 #10
0
function editCarPlate()
{
    if (isset($_POST)) {
        $carid = $_POST['update_carid'];
        $carplate = $_POST['edit_carplate'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANICAR SET CARID = '{$carid}', CARPLATE = '{$carplate}' WHERE CARID = {$carid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_garbage.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
예제 #11
0
function getListOfBuyClicks($dt)
{
    global $mycatid;
    $str = "";
    $lnk = dbConnect('localhost', 'root', 'lyntik');
    $query = "SELECT b.fdate as fdate,b.ip as cip,b.goodid as gid,b.name as sname,b.source as src,b.price as price  FROM buylog b WHERE b.date='{$dt}' AND b.mycat_id={$mycatid} ORDER BY b.ip,b.fdate";
    $res = exec_query($query);
    $ip = "0.0.0.0";
    $i = 0;
    $str .= "<div class=\"all_clicks\">";
    $str .= "<div class=\"click_row_title\">\n             <div class=\"left click_date title\">Дата</div>\n             <div class=\"left click_id title\">ID товара</div>\n             <div class=\"left click_name title\">Наименование</div>\n             <div class=\"left click_id title\">Цена</div>\n             <div class=\"left click_name title\">Источник</div>\n             " . closeFloat() . "\n            </div>";
    if (mysql_num_rows($res) == 0) {
        $str .= "<div>За выбранную дату нажатий не было</div>";
    } else {
        while ($rows = fetch_array($res)) {
            if ($ip != $rows['cip']) {
                $ip = $rows['cip'];
                if ($i != 0) {
                    $str .= "</div>";
                }
                $str .= "<div class=\"ipclicks\">";
                $str .= "<div class=\"client_ip\">Клики с адреса:<b>" . $rows['cip'] . "</b></div>";
            }
            $str .= "<div class=\"click_row\">\n             <div class=\"left click_date\">" . $rows['fdate'] . "</div>\n             <div class=\"left click_id\">" . $rows['gid'] . "</div>\n             <div class=\"left click_name\">" . $rows['sname'] . "</div>\n             <div class=\"left click_id\">" . $rows['price'] . "</div>\n             <div class=\"left click_name\">" . $rows['src'] . "</div>\n             " . closeFloat() . "\n            </div>";
        }
        $str .= "</div>";
    }
    $str .= "</div></div>";
    mysql_free_result($res);
    dbDisconnect($lnk);
    return $str;
}
예제 #12
0
function checkIn()
{
    if (isset($_POST)) {
        $carregno = $_POST['carregno'];
        $carzone = $_POST['parkzone'];
    }
    $conn = dbConnect();
    if ($conn) {
        $insert_checkinout = "INSERT INTO EMM_ZOO.PARKCHECKINOUT (TICKETPARKID, CARREGNO, ZONES, DATES, CHECKIN, CHECKOUT) VALUES (DEFAULT, '{$carregno}', '{$carzone}', current date, current time, null);";
        //echo $insert_checkinout;
        $stmt1 = db2_exec($conn, $insert_checkinout);
        if ($stmt1) {
            $insert_his = "INSERT INTO EMM_ZOO.PARKHISTORY (VEHI_ID, VEHI_REGNO, CHECKIN, CHECKOUT, DATES, FEE) VALUES (DEFAULT, '{$carregno}', current time, null, current date, 0.00);";
            $stmt2 = db2_exec($conn, $insert_his);
            // $sql3 = "UPDATE EMM_ZOO.ANIMAL SET CAGEID = " . $cage . " WHERE ANIMALID = '" . $animal . "';";
            //$rc2 = db2_exec($conn, $sql3);
        }
        if ($stmt1 & $stmt2) {
            header("Refresh:0; url=checkinout.php");
        } else {
            header("Refresh:0; url=checkinout.php");
        }
        db2_free_stmt($stmt1);
        db2_free_stmt($stmt2);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
    db2_free_stmt($stmt1);
}
/**
 * Establishes and checks connection to the database and runs the provided queries. 
 * Finally, it outputs JSON that the App will parse. 
 *
 * @param sqlToAvail the SQl query to make machines available
 * @param sqlUpdate the SQL query to update the database
 * @param sqlQuery the SQL query that will output information from the database 
*/
function runQueries($sqlToAvail, $sqlUpdate, $sqlQuery)
{
    $link = dbConnect();
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    if (isset($sqlToAvail)) {
        mysqli_query($link, $sqlToAvail);
    }
    if (isset($sqlUpdate)) {
        mysqli_query($link, $sqlUpdate);
    }
    if (isset($sqlQuery)) {
        $result = mysqli_query($link, $sqlQuery);
        if (isset($result)) {
            $resultArray = array();
            $tempArray = array();
            while ($row = $result->fetch_object()) {
                $tempArray = $row;
                array_push($resultArray, $tempArray);
            }
            echo json_encode($resultArray);
        }
    }
    mysqli_close($link);
}
예제 #14
0
파일: sessions.php 프로젝트: elodieT/Swip
function verifAcces($id, $mdp)
{
    /*
     * Définition des variables globales $idIsValid et $mdpIsValid
     * permettant de vérifier que l'identifiant et le mot de passe entrés
     * sont corrects.
     */
    global $idIsValid, $mdpIsValid;
    $idIsValid = $mdpIsValid = false;
    global $currentID, $currentMdp;
    $currentID = $id;
    $currentMdp = $mdp;
    // connexion à la base de données de swip
    dbConnect();
    // liste de tous les administrateurs et comparaisons avec l'identifiant et le mot de passe donnés
    $sqlQuery = "select * from administrators;";
    processSqlQuery($sqlQuery, function ($resp) {
        global $idIsValid, $mdpIsValid, $currentID, $currentMdp;
        // pour chaque entrée trouvée
        while ($data = mysql_fetch_assoc($resp)) {
            if ($currentID == $data['id']) {
                $idIsValid = true;
                if ($currentMdp == $data['mdp']) {
                    $mdpIsValid = true;
                }
            }
        }
    });
    return $idIsValid && $mdpIsValid;
}
예제 #15
0
function executeQuery($query)
{
    // call the dbConnect function
    $conn = dbConnect();
    try {
        // execute query and assign results to a PDOStatement object
        $stmt = $conn->query($query);
        do {
            if ($stmt->columnCount() > 0) {
                $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
                //retreive the rows as an associative array
            }
        } while ($stmt->nextRowset());
        // if multiple queries are executed, repeat the process for each set of results
        //Uncomment these 4 lines to display $results
        //    echo '<pre style="font-size:large">';
        //   print_r($results);
        //    echo '</pre>';
        //   die;
        //call dbDisconnect() method to close the connection
        dbDisconnect($conn);
        return $results;
    } catch (PDOException $e) {
        //if execution fails
        dbDisconnect($conn);
        die('Query failed: ' . $e->getMessage());
    }
}
예제 #16
0
function orderoldfood()
{
    if (isset($_POST)) {
        $food_id = $_POST['food_id'];
        $food_name = $_POST['food_name'];
        $food_type = $_POST['food_type'];
        $add_amount = $_POST['add_amount'];
        $price_per = $_POST['price_per'];
        $total = $add_amount * $price_per;
    }
    $conn = dbConnect();
    if ($conn) {
        $sql0 = "SELECT AMOUNT FROM EMM_ZOO.FM_STOCK WHERE FOODID = {$food_id};";
        $stm = dbQuery($conn, $sql0);
        while ($row = dbFetchArray($conn, $stm)) {
            $amountx = $row[0];
        }
        $amount_now = $amountx + $add_amount;
        $sql1 = "INSERT INTO EMM_ZOO.FOODANIMAL_EXPENSE (FOODEXPENSE_ID,DATES,FOODID,COST,RESPONPERSONID) VALUES (DEFAULT,CURRENT DATE,{$food_id},{$total},'5678');";
        $cb = db2_exec($conn, $sql1);
        $sql2 = "UPDATE EMM_ZOO.FM_STOCK SET AMOUNT = {$amount_now} WHERE FOODID = {$food_id};";
        $cc = db2_exec($conn, $sql2);
        if ($cc && $cb) {
            $resultMessage = 1;
            return $resultMessage;
            header('Location: FoodStock.php#food_list');
        } else {
            $resultMessage = 0;
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    }
}
예제 #17
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $tickettourID = $_POST['tourid_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $insert = " INSERT INTO EMM_ZOO.TICKETTOUR_TRANSACTION (TICKETTOUR_ID, TOUR_ID, DATE) VALUES (DEFAULT, '{$tickettourID}', CURRENT DATE);";
        echo $insert;
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            header("Refresh:0; url=TourTicket.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
예제 #18
0
파일: config.php 프로젝트: ncgr/lis_site
/**
 * This function must check the user session to be sure that he/she is
 * authorized to upload and access files in the File Browser.
 *
 * @return boolean
 */
function CheckAuthentication()
{

    //
    // Validate the user's existing session and most privileged role.
    //
    // Sessions are stored in the database. Lookup a sesion via the cookie
    // _lis_site_session. If it's valid, extract the ckfinder_role value
    // and validate it.
    //

    $cookie = $_COOKIE['_lis_site_session'];
    $value = explode('--', $cookie);
    $value = $value[0];

    $conn = dbConnect();
    $query = mysql_real_escape_string($value);
    $session = execQuery("SELECT * FROM sessions WHERE session_id = '$query'", "dbResultToArray");

    $session_data = explode("\n", $session[0]['data']);

    $valid_roles = array("superuser", "admin");

    foreach ($session_data as $s) {
        $role = preg_replace('/[^a-z]/', '', base64_decode($s));
        for ($i = 0; $i < count($valid_roles); $i++) {
            if (strstr($role, $valid_roles[$i])) {
                return true;
            }
        }
    }

	return false;
}
예제 #19
0
function selectReadings()
{
    $db = dbConnect();
    $select = $db->query("SELECT * FROM yun");
    echo '"temp": ' . "[\n";
    $temps = '';
    while ($row = $select->fetch()) {
        $temps .= $row['temp'] . ',';
    }
    $temps = rtrim($temps, ",");
    echo $temps;
    echo " ],\n";
    $select = $db->query("SELECT * FROM yun");
    echo '"humidity": ' . "[\n";
    $humiditys = '';
    while ($row = $select->fetch()) {
        $humiditys .= $row['humidity'] . ',';
    }
    $humiditys = rtrim($humiditys, ",");
    echo $humiditys;
    echo " ],\n";
    $select = $db->query("SELECT * FROM yun");
    echo '"AQ": ' . "[\n";
    $AQs = '';
    while ($row = $select->fetch()) {
        $AQs .= $row['AQ'] . ',';
    }
    $AQs = rtrim($AQs, ",");
    echo $AQs;
    echo " ]\n";
}
예제 #20
0
function updateTicket()
{
    // connect db=> stmt sql => insert => refresh page
    if (isset($_POST)) {
        $ticketshowID = $_POST['showid_value'];
    }
    $conn = dbConnect();
    // start connect db
    if ($conn) {
        $insert = " INSERT INTO EMM_ZOO.TICKETSHOW_BUYING (TICKETSHOW_ID, SHOWID, ROUNDID , BUYING_DATE) VALUES (DEFAULT, '{$ticketshowID}',CURRENT TIME, CURRENT DATE);";
        echo $insert;
        $rc = db2_exec($conn, $insert);
        if ($rc) {
            header("Refresh:0; url=ShowList.php");
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error($stmt));
        }
        // finish all query statement
        db2_free_stmt($rc);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
}
예제 #21
0
 /**
  * Tests connect() -- rest
  * 
  * @runInSeparateProcess
  */
 public function testConnect()
 {
     // connect
     dbConnect();
     // already connected
     $this->assertNull(DB::connect('', '', '', '', ''));
 }
예제 #22
0
function uploadBioInfo()
{
    if (!isset($_SESSION['current_user_name']) && !isset($_COOKIE[$cookie_name])) {
        header('Location: ../login.php');
        exit;
    } else {
        //print_r($_POST);
        if (isset($_POST)) {
            $AnimalID = $_POST['AnimalID'];
            $species = $_POST['species'];
            $Phylum = $_POST['Phylum'];
            $Class = $_POST['Class'];
            $Order = $_POST['Order'];
            $Family = $_POST['Family'];
            $Genus = $_POST['Genus'];
            $warmblooded = $_POST['warmblooded'];
            $Cover = $_POST['Cover'];
            $Reproduction = $_POST['Reproduction'];
            $Habitat = $_POST['Habitat'];
            $food = $_POST['food'];
            $BodyTemp = $_POST['BodyTemp'];
            $EnviTemp = $_POST['EnviTemp'];
            $LifeSpan = $_POST['LifeSpan'];
            // an array that want to insert this can be multiple array at the time.
            $data = array($AnimalID, $species, $Phylum, $Class, $Order, $Family, $Genus, $warmblooded, $Cover, $Reproduction, $Habitat, $food, $BodyTemp, $EnviTemp, $LifeSpan);
            // print var_dump to display an array of variable data with type that prepare for query.
            //echo var_dump($data) ."<br>";
        }
        require_once '/var/www/html/app/model/connect.php';
        $conn = dbConnect();
        if ($conn) {
            // DEFAULT if you set generated as identify with specifier this will auto increament for integer.
            $sql = 'INSERT INTO EMM_ZOO.BIOINFO (SPECIESID,SPECIESNAME, PHYLUM, CLASS, ORDER, FAMILY, GENUS, WARMBLOODED, BODYCOVER, REPRODUCTION, HABITAT, COMMONFOOD, BODYTEMP, ENVITEMPRANGE, LIFESPAN) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);';
            //echo $sql;
            // prepare statement using connection and sql
            $stmt = db2_prepare($conn, $sql);
            // If statement is valid execute it to db2
            if ($stmt) {
                //echo "SQL is valid<br>";
                $result = db2_execute($stmt, $data);
                if ($result) {
                    $resultMessage = "Successfully added to Biological information";
                    echo "Successfully added";
                    header('Location: BioInfo.php');
                    exit;
                } else {
                    $resultMessage = "Failed to query into database";
                }
            } else {
                // If statement is error why see the code
                die('Critical error:' . db2_stmt_error());
            }
            db2_free_stmt($stmt);
            db2_close($conn);
        } else {
            echo db2_conn_errormsg();
        }
    }
}
예제 #23
0
파일: addEmp.php 프로젝트: Juklabs/emmaline
function insertSaniEmp()
{
    //print_r($_POST);
    if (isset($_POST)) {
        $empid = $_POST['empid'];
        $zoneid = $_POST['zoneid'];
        $jobid = '17';
        $firstname = $_POST['firstname'];
        $lastname = $_POST['lastname'];
        $birthdate = $_POST['birthdate'];
        $sex = $_POST['sex'];
        $nationality = $_POST['nationality'];
        $hiredate = $_POST['hiredate'];
        $address = $_POST['address'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $salary = $_POST['salary'];
        $bonus = $_POST['bonus'];
        // an array that want to insert this can be multiple array at the time.
        $data = array($empid, $zoneid, $jobid, $firstname, $lastname, $birthdate, $sex, $nationality, $hiredate, $address, $email, $phone, $salary, $bonus);
        // print var_dump to display an array of variable data with type that prepare for query.
        //echo var_dump($data) ."<br>";
    }
    // define $conn from model
    $conn = dbConnect();
    if ($conn) {
        $sql = 'INSERT INTO EMM_ZOO.EMPLOYEE (EMPID, ZONEID, JOBID, FIRSTNAME, LASTNAME, BIRTHDATE, SEX, NATIONALITY, HIREDATE, ADDRESS, EMAIL, PHONE, SALARY, BONUS) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);';
        //$sql2 = 'INSERT INTO EMM_ZOO.EMP_SANI (EMPID) VALUES (?);';
        //echo $sql;
        // prepare statement using connection and sql
        $stmt = db2_prepare($conn, $sql);
        // If statement is valid execute it to db2
        if ($stmt) {
            //echo "SQL is valid<br>";
            $result = db2_execute($stmt, $data);
            if ($result) {
                $resultMessage = "Successfully added to sanitation employee";
                //echo "Successfully added";
                echo "<script>";
                echo "alert('Added successfully')";
                echo "</script>";
                header('Location: addEmpHome.php');
                exit;
            } else {
                $resultMessage = "Failed to query into database";
                echo "<script>";
                echo "alert('Failed to query into database')";
                echo "</script>";
            }
        } else {
            // If statement is error why see the code
            die('Critical error:' . db2_stmt_error());
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
function cek()
{
    $res = dbConnect("SELECT * FROM kategori");
    while ($data = mysql_fetch_array($res)) {
        $result[] = array('id_kategori' => $data['id_kategori'], 'kategori' => $data['kategori']);
    }
    return $result;
}
예제 #25
0
function dbQuery($query)
{
    // perform a query
    $connection = dbConnect();
    $result = $connection->query($query) or die('Failed to query database.' . mysqli_error($connection));
    $connection->close();
    return $result;
}
예제 #26
0
function findVersion()
{
    global $error, $conf_centreon;
    $db = dbConnect($conf_centreon['hostCentreon'], $conf_centreon['user'], $conf_centreon['password'], $conf_centreon['db'], true);
    $reqVersion = mysql_query("SELECT mod_release FROM modules_informations WHERE name='Discovery';");
    $version = mysql_fetch_array($reqVersion);
    return $version['mod_release'];
    dbClose($db);
}
예제 #27
0
function queryUser($user_id)
{
    require_once "connection.inc.php";
    $conn = dbConnect('read');
    $sql = "SELECT * FROM users WHERE user_id = '" . $user_id . "'";
    $result = $conn->query($sql) or die(mysqli_error($conn));
    $row = $result->fetch_assoc();
    return $row['user_id'];
}
예제 #28
0
/**
 * @param $username
 * @param $password
 * @param $email
 * @param $phone
 *
 * @return bool|string
 */
function saveUser($username, $password, $email, $phone)
{
    $resource = dbConnect();
    $query = "INSERT INTO users VALUES ('0','{$username}', '{$password}', '{$email}', '{$phone}', NOW());";
    if (mysqli_query($resource, $query)) {
        return true;
    } else {
        return mysqli_error($resource);
    }
}
예제 #29
0
 function getQuery($myQuery, $par_Order = FALSE, $typeQuery = "GET")
 {
     list($dbDatabase, $Connect) = dbConnect($par_Order);
     mysql_select_db($dbDatabase, $Connect);
     if ($typeQuery != "GET") {
         mysql_real_escape_string($myQuery);
     }
     $processQuery = mysql_query($myQuery, $Connect) or die($myQuery . '<br/><strong>Query process error: </strong>' . mysql_error());
     return $processQuery;
 }
예제 #30
0
function createModuleCombo()
{
    dbConnect();
    echo '<select name="id">';
    $res = dbQuery("SELECT M.`id-module`, M.intitule, D.intitule, M.no_semestre\r\n\r\n            FROM module M, diplome D \r\n\r\n            WHERE D.`id-diplome` = M.`id-diplome`\r\n\r\n            ORDER BY D.intitule, M.no_semestre");
    while ($row = mysql_fetch_array($res)) {
        echo '<option value="' . $row[0] . '">' . $row[2] . ' - SEM' . $row[3] . ' - ' . $row[1] . '</option>\\n';
    }
    echo '</select>';
    dbClose();
}