Example #1
0
function startup()
{
    setlocale(LC_ALL, 'ru_RU.UTF-8');
    // Языковая настройка
    mb_internal_encoding('UTF-8');
    session_start();
    return getDbConnect();
}
Example #2
0
function articles_delete($id_article)
{
    $sql1 = "DELETE FROM `articles` WHERE `id_article`='%s'";
    $query = sprintf($sql1, sql_escape($id_article));
    $result = mysqli_query(getDbConnect(), $query);
    if (!$result) {
        die(mysqli_error());
    }
    return true;
}
function getallbook($name)
{
    $conn = getDbConnect();
    $sqlQueryStr = "SELECT * FROM BOOK";
    $result = mysql_query($sqlQueryStr, $conn);
    // execute the SQL query
    //fetch the results as array.
    while ($row = mysql_fetch_array($result)) {
        $items[] = array('cd' => $row['cd'], 'title' => $row['title'], 'author' => $row['author'], 'publisher' => $row['publisher']);
    }
    return json_encode($items);
}
function getallbooks($name)
{
    $conn = getDbConnect();
    $sqlQueryStr = "SELECT * FROM BOOK";
    $result = mysql_query($sqlQueryStr, $conn);
    // execute the SQL query
    //fetch the results as array.
    $bookArray = array();
    while ($row = mysql_fetch_array($result)) {
        $book = array('cd' => $row['cd'], 'title' => $row['title'], 'author' => $row['author'], 'publisher' => $row['publisher']);
        array_push($bookArray, $book);
    }
    return $bookArray;
}
Example #5
0
<?php

require_once 'function.php';
require 'classes.php';
require 'repo.php';
$link = getDbConnect();
$title = "Справочник: Ключевые слова";
$error = false;
$all_wordpairs = WordpairRepository::loadAll($link);
$all_persons = PersonRepository::loadAll($link);
$pair_person = '';
if (isset($_POST['submit'])) {
    $person_id = $_POST['persons'];
    if ($person_id != 0) {
        $person = PersonRepository::load($link, $person_id);
        $one_person = $person->getName();
        $pair_person = WordpairRepository::loadByPerson($link, $person_id);
    } else {
        $error = true;
    }
}
include 'view/header.php';
include 'view/v_wordpairs.php';
include 'view/footer.php';
<?php

// start a session. The session_start() function must appear BEFORE the <html> tag:
session_start();
// require the dbfunction.php file
require 'dbFunction.php';
$adminid = $_POST["adminID"];
// retrieve the adminid from login form
$mypassword = $_POST["password"];
// retrieve the password from login form
$con = getDbConnect();
// invoke the getDbConnect() function to get a database connection
if ($con) {
    // connection to database is successful
    // To protect MySQL injection (more detail about MySQL injection)
    $sqlQueryStr = "SELECT recordid,email " . "FROM account AC " . "WHERE AC.email = '{$adminid}' AND " . "AC.password= '******'";
    $result = mysql_query($sqlQueryStr, $con);
    // execute the SQL query
    //fetch the results as array.
    $arResult = mysql_fetch_array($result);
    $row = mysql_num_rows($result);
    if ($row > 0) {
        // fetch the record
        // $_SESSION['basicinfo'] = $result; // put the record into the session
        $_SESSION['basicinfo'] = $arResult;
        header('Location: homepage.php');
        // redirect to the homepage.
    } else {
        // header('Location: LoginPage.html'); // redirect to the login page.
        echo 'login not successful';
    }
Example #7
0
function sql_select($sql)
{
    // Выполнение запроса
    $result = mysqli_query(getDbConnect(), $sql);
    if (!$result) {
        die(mysqli_error(getDbConnect()));
    }
    // извлекаем из БД данные
    $array = array();
    while ($row = mysqli_fetch_assoc($result)) {
        $array[] = $row;
    }
    return array($array);
}
Example #8
0
function sql_escape($param)
{
    return mysqli_escape_string(getDbConnect(), $param);
}