当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli_query函数代码示例

本文整理汇总了PHP中mysqli_query函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_query函数的具体用法?PHP mysqli_query怎么用?PHP mysqli_query使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mysqli_query函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: check_user

function check_user($uid, $link)
{
    $query = "SELECT sid FROM " . USERS_TABLE . " WHERE uid='{$uid}';";
    $result = mysqli_query($link, $query) or die(mysqli_error());
    $row = mysqli_fetch_assoc($result);
    return $row["sid"] == SID ? true : false;
}
开发者ID:TssDragon,项目名称:intess,代码行数:7,代码来源:uni-auth.php

示例2: bajaEmpleo

 public function bajaEmpleo($id)
 {
     $conexion = new Conexion();
     $sql = "delete from empleos_anteriores where id={$id}";
     mysqli_query($conexion->link, $sql) or die("Error: " . mysqli_error($conexion->link));
     echo "Empleo borrado correctamente";
 }
开发者ID:nc11040545,项目名称:egresados,代码行数:7,代码来源:empleos_anteriores.class.php

示例3: sc_check_priv

function sc_check_priv($prob_id, $opened, $user)
{
    if (!function_exists('check_priv')) {
        require __DIR__ . '/privilege.php';
    }
    if (isset($_SESSION['user'])) {
        if (strcmp($user, $_SESSION['user']) == 0 || check_priv(PRIV_SOURCE)) {
            return TRUE;
        }
    }
    require __DIR__ . '/../conf/database.php';
    if (!defined('PROB_HAS_TEX')) {
        require __DIR__ . '/../lib/problem_flags.php';
    }
    if ($opened) {
        $row = mysqli_fetch_row(mysqli_query($con, "select has_tex from problem where problem_id={$prob_id}"));
        if (!$row) {
            return _('There\'s no such problem');
        }
        $prob_flag = $row[0];
        if ($prob_flag & PROB_IS_HIDE && !check_priv(PRIV_INSIDER)) {
            return _('Looks like you can\'t access this page');
        }
        if ($prob_flag & PROB_DISABLE_OPENSOURCE) {
            return _('This solution is not open-source');
        } else {
            if ($prob_flag & PROB_SOLVED_OPENSOURCE) {
                if (isset($_SESSION['user'])) {
                    $query = 'select min(result) from solution where user_id=\'' . $_SESSION['user'] . "' and problem_id={$prob_id} group by problem_id";
                    $user_status = mysqli_query($con, $query);
                    $row = mysqli_fetch_row($user_status);
                    if ($row && $row[0] == 0) {
                        return TRUE;
                    }
                }
                return _('You can\'t see me before solving it');
            } else {
                if (isset($_SESSION['user'])) {
                    $res = mysqli_query($con, "SELECT contest.contest_id,co.contest_id from contest\n                                       RIGHT JOIN (select contest_id from contest_status where user_id='" . $_SESSION['user'] . "' and leave_time is NULL) as cs on (contest.contest_id=cs.contest_id)\n                                       LEFT JOIN (select contest_id from contest_problem where problem_id={$prob_id}) as cp on (contest.contest_id=cp.contest_id)\n                                       LEFT JOIN (select contest_id from contest_owner where user_id='" . $_SESSION['user'] . "') as co on (contest.contest_id=co.contest_id)\n                                       where NOW()>start_time and NOW()<end_time and contest.hide_source_code");
                    $num = mysqli_num_rows($res);
                    if ($num > 0) {
                        $accessible = false;
                        while ($row = mysqli_fetch_row($res)) {
                            if (!is_null($row[1])) {
                                $accessible = true;
                            }
                        }
                        if ($accessible) {
                            return TRUE;
                        } else {
                            return _('You can\'t see me before the contest ends');
                        }
                    }
                    return TRUE;
                }
            }
        }
    }
    return _('Looks like you can\'t access this page');
}
开发者ID:CDFLS,项目名称:CWOJ,代码行数:60,代码来源:sourcecode.php

示例4: execute

 public function execute($db)
 {
     if (is_null($this->sql_query)) {
         $this->sql_query = $this->build_director();
     }
     return mysqli_query($db, $this->sql_query);
 }
开发者ID:Ruyka,项目名称:Tam-An-Food-Store-Manager,代码行数:7,代码来源:SQL.php

示例5: getstockprice

function getstockprice()
{
    global $con;
    $sql = "SELECT ROUND(current_stock_price, 1) as ct , ROUND(last_stock_price, 1) as lt from stocks";
    $query = mysqli_query($con, $sql);
    if (!$query && !mysqli_num_rows($query)) {
        throw new Exception('Error in SQL');
    }
    $i = 1;
    $ret = array();
    while ($row = mysqli_fetch_assoc($query)) {
        if ($row['ct'] > $row['lt']) {
            $direction = 'up';
            $color = 'green';
        } else {
            $direction = 'down';
            $color = 'red';
        }
        $arr[$i] = array($row['ct'], $direction, $color);
        array_push($ret, $arr[$i]);
        $i++;
    }
    mysqli_close($con);
    return $ret;
}
开发者ID:ciplpj,项目名称:vsm,代码行数:25,代码来源:common.inc.php

示例6: DetailsInsert

function DetailsInsert($con)
{
    $datecon = $_POST["YYYY"] . "-" . $_POST["MM"] . "-" . $_POST["DD"];
    //$query="INSERT into customers ('check_in', 'check-out', 'room_type', 'adults_per_room', 'children_0_5', 'children_6_12') VALUES ('$checkin.','$checkout','$roomtype','$adults','$child0','$child6');";
    $query = "INSERT INTO `happy_hearts`.`schoolinfo` ( `school_id`, `date_updated`, `children`, `teachers`,`girls`,`boys`,`new_enroll`,`no_left`) VALUES ('" . $_POST["school_id"] . "','" . $_POST["udate"] . "','" . $_POST["children"] . "','" . $_POST["girls"] . "','" . $_POST["boys"] . "','" . $_POST["no_enroll"] . "','" . $_POST["no_left"] . "');";
    //id is auto increment
    echo $query;
    if (mysqli_query($con, $query)) {
        $id = mysqli_insert_id($con);
        //Gives the auto generated id required in employee_master table
    } else {
        return false;
    }
    /*$query1="insert into employee_master(emp_id,emp_username,emp_password) values(".$id.",'".$_POST["user"]."','".$_POST["pass"]."');";	//id is auto increment,we take auto incremented id from the first table to put in employee id in employee_master table and this query stores the username and password from the query  
    
    
    	echo $query1; //see screenshot
    
    
    	if(!mysqli_query($con,$query1)) //Runs the query and returns boolean variable.
    	{
    		return false;
    	}
    	else 
    	{
    		return true;
    	}	//checks the second query just as the first
    	*/
}
开发者ID:T4SG,项目名称:Mumbai-Team-2,代码行数:29,代码来源:insert_schoolinfo.php

示例7: verificar_login

function verificar_login($userid, $pass, &$result)
{
    $servername = "localhost";
    $username = 'root';
    $password = "";
    $dbname = "cmd";
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    $sql = "SELECT * FROM `trabajador` WHERE `userid`=\"" . $userid . "\" and `password`=\"" . $pass . "\"";
    $result = mysqli_query($conn, $sql);
    $count = 0;
    if (!$result) {
        echo "no result";
    } else {
        if (mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_assoc($result)) {
                $_SESSION['userid'] = $row["userid"];
                $_SESSION['rol'] = $row["rol"];
                $count++;
            }
        }
        if ($count == 1) {
            return 1;
        } else {
            return 0;
        }
    }
}
开发者ID:AGonzalezMaillard,项目名称:CMDashboard,代码行数:32,代码来源:index.php

示例8: konprobatuSaioa

function konprobatuSaioa($nora, $errorea)
{
    if (!isset($_SESSION)) {
        session_start();
    }
    if (!isset($_SESSION['posta'])) {
        $user_check = 0;
    } else {
        $user_check = $_SESSION['posta'];
    }
    $sql = "SELECT * FROM  erabiltzaileak where posta like '{$user_check}'";
    require_once __DIR__ . '/../datuBasea/konexioa.php';
    $result = mysqli_query($konexioa, $sql);
    $row = mysqli_fetch_assoc($result);
    $login_session = $row['izenabizen'];
    if (!isset($login_session) && !(isset($_SESSION['posta']) && $_SESSION['posta'] == true)) {
        if ($errorea) {
            echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"js/abixuak/dist/sweetalert2.css\"/>\n<script src=\"js/jquery.js\"></script>\n<script src=\"js/abixuak/dist/sweetalert2.min.js\"></script>\n<body bgcolor=\"#8A0829\">\n<script language=\"JavaScript\">";
            echo "\n        swal({\n                    title: \"GUNE PRIBATUA\",\n                    text: \"Logeatuta egon behar duzu, atal honetan sartzeko.\",\n                    type: \"error\"\n                },\n                function(){\n                    window.location.href = '{$nora}';\n                });\n                    window.onclick = function(){\n                        window.location.href = '{$nora}';\n                        }\n      ";
            echo "</script>\n</body>";
            return false;
        }
    } else {
        return true;
    }
}
开发者ID:aunanue011,项目名称:ws_praktika,代码行数:26,代码来源:userSession.php

示例9: check_login

function check_login($dbc, $name = '', $password = '')
{
    $errors = array();
    if (empty($name)) {
        $errors[] = 'you forget to input your ID';
    } else {
        $e = mysqli_real_escape_string($dbc, trim($name));
    }
    if (empty($password)) {
        $errors[] = 'you forget to input your password';
    } else {
        $p = mysqli_real_escape_string($dbc, trim($password));
    }
    if (empty($errors)) {
        $q = "SELECT name FROM Manager where name= '{$e}' AND Cro = '{$p}'";
        $r = mysqli_query($dbc, $q);
        if (mysqli_num_rows($r) == 1) {
            $row = mysqli_fetch_array($r, MYSQLI_ASSOC);
            return array(ture, $row);
        } else {
            $errors[] = 'your name OR password did not match!';
        }
    }
    return array(false, $errors);
}
开发者ID:HIT1120320110,项目名称:OMG,代码行数:25,代码来源:loginfunction2.php

示例10: fdelete

function fdelete($del)
{
    //echo $del;
    $strSQL = "DELETE FROM companies WHERE id={$del}";
    mysqli_query($link, $strSQL);
    header("Location:http://localhost/companies/index.php?page=companies");
}
开发者ID:PushGit,项目名称:companies,代码行数:7,代码来源:delete.php

示例11: query

 public function query($sql, $unbuffered = false)
 {
     if (defined('FEATHER_SHOW_QUERIES')) {
         $q_start = get_microtime();
     }
     $this->query_result = @mysqli_query($this->link_id, $sql);
     if ($this->query_result) {
         if (defined('FEATHER_SHOW_QUERIES')) {
             $this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
         }
         ++$this->num_queries;
         return $this->query_result;
     } else {
         if (defined('FEATHER_SHOW_QUERIES')) {
             $this->saved_queries[] = array($sql, 0);
         }
         $this->error_no = @mysqli_errno($this->link_id);
         $this->error_msg = @mysqli_error($this->link_id);
         // Rollback transaction
         if ($this->in_transaction) {
             mysqli_query($this->link_id, 'ROLLBACK');
         }
         --$this->in_transaction;
         return false;
     }
 }
开发者ID:beaver-dev,项目名称:featherbb,代码行数:26,代码来源:mysqli_innodb.php

示例12: Populate

function Populate()
{
    //mysql connection
    $con = mysqli_connect("eu-cdbr-azure-west-a.cloudapp.net", "b8592f1b44ff9a", "fecb2128", "TeamProject");
    if (mysqli_connect_errno()) {
        $result = "f";
    } else {
        //query
        $query = "SELECT Name,Email FROM Subscriber";
        $result = mysqli_query($con, $query);
        //initialize arrays
        $i = 0;
        $subnames = array();
        $submails = array();
        //loop through the database populating
        while ($sub = mysqli_fetch_assoc($result)) {
            $subnames[$i] = $sub['Name'];
            $submails[$i] = $sub['Email'];
            $i++;
        }
        //close conection and return
        mysqli_close($con);
        return array($subnames, $submails);
    }
}
开发者ID:alexandroskou,项目名称:Repository1,代码行数:25,代码来源:Notify.php

示例13: validateUser

function validateUser($user, $pass, $pass_confirm)
{
    $valueToRetun = 0;
    $validUsernameOrNot = validUsername($user);
    $validPasswordOrNot = validPassword($pass);
    //check to see if username exists
    $sqlQuery = "SELECT * FROM users WHERE username = '{$user}'";
    $result = mysqli_query($connection, $sqlQuery);
    $row = mysqli_fetch_assoc($result);
    if ($row != "") {
        $valueToReturn = 1;
    } else {
        if ($validUsernameOrNot && $validPasswordOrNot) {
            $valueToReturn = 2;
            //Username and password is valid
        } else {
            if (!$validUsernameOrNot) {
                $valueToReturn = 3;
                //Username is not valid format
            } else {
                if (!$validPasswordOrNot) {
                    $valueToReturn = 4;
                    //Password is not valid format
                } else {
                    if (strcmp($pass, $pass_confirm) !== 0) {
                        $valueToReturn = 5;
                        //Password confirmation is incorrect
                    }
                }
            }
        }
    }
    mysql_free_result($result);
    return $valueToReturn;
}
开发者ID:gdanielyan,项目名称:Email-Scheduler,代码行数:35,代码来源:webservice.php

示例14: generateDataLayer

function generateDataLayer($result, $p, $view, $genre, $category, $sort, $searchName)
{
    require 'includes/connect.php';
    $dataLayerString = "[{'page':'homePage',";
    //movie
    $movieString = "'movies':[";
    while ($row = mysqli_fetch_array($result)) {
        $movieId = mysqli_real_escape_string($conn, $row['movieId']);
        $movieName = mysqli_real_escape_string($conn, $row['name']);
        if ($p == "rating") {
            $averageRatingQuery = "SELECT average FROM `averagerating` WHERE movieId = '" . $movieId . "'";
            $averageRatingResult = mysqli_query($conn, $averageRatingQuery);
            $averageRatingRow = mysqli_fetch_array($averageRatingResult);
            if (!$averageRatingRow) {
                printf("Error: %s\n", mysqli_error($conn));
                //exit();
            }
            $average = $averageRatingRow['average'];
            $movieString .= "{ 'movieId':'{$movieId}', 'movieName':'{$movieName}', 'averageRating':'{$average}' },";
        } else {
            if ($p == "sentiment") {
                $sentCount = "";
                if ($sentSort == "pos") {
                    $sentCount = $row['positive'];
                    $sentType = "positive";
                } else {
                    $sentCount = $row['negative'];
                    $sentType = "negative";
                }
                $movieString .= "{ 'movieId':'{$movieId}', 'movieName':'{$movieName}', '{$sentType}':'{$sentCount}' },";
            }
        }
    }
    $movieString = rtrim($movieString, ",");
    $movieString .= "]";
    $dataLayerString .= $movieString;
    //metric (rating or sentiment)
    $pString = ", 'metric': '{$p}'";
    $dataLayerString .= $pString;
    //view
    $viewString = ", 'view': '{$view}'";
    $dataLayerString .= $viewString;
    //genre
    $genreString = ", 'genre': '{$genre}'";
    $dataLayerString .= $genreString;
    //all/theatre/recent
    $categoryString = ", 'category': '{$category}'";
    $dataLayerString .= $categoryString;
    //sort
    $sortString = ", 'sort': '{$sort}'";
    $dataLayerString .= $sortString;
    //search
    if (!empty($searchName)) {
        $searchString = ", 'searchValue': '{$searchName}'";
        $dataLayerString .= $searchString;
    }
    $dataLayerString .= "}]";
    //echo "datalayer".$dataLayerString;
    return $dataLayerString;
}
开发者ID:113256,项目名称:finalYear,代码行数:60,代码来源:generateDataLayer.php

示例15: team

 function team($abbr)
 {
     global $con;
     $result = mysqli_query($con, "SELECT * from teamnames Where abbr='{$abbr}'") or die(mysqli_error($con));
     $row1 = mysqli_fetch_array($result);
     return $row1['name'];
 }
开发者ID:digideskio,项目名称:Fantasy-Cricket-League,代码行数:7,代码来源:update_form.php


注:本文中的mysqli_query函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。