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


PHP mysqli_close函数代码示例

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


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

示例1: obtenerPacientes

function obtenerPacientes($palabra)
{
    // Error 1: los pack estaban mal referenciados antes ../modelo/Diseno.php
    // forma correcta ../modelo/diseno.php
    include_once '../modelo/diseno.php';
    $ds = new diseno();
    // Conexi�n a la base de datos, cambiar los par�metros si se requiere
    $conexionBD = mysqli_connect('localhost', 'root', 'sql', 'admproy_cuidados_paliativos_panama');
    //$conexionBD = mysqli_connect('mysql3000.mochahost.com','admproy_panama','cppanama2014','admproy_cuidados_paliativos_panama');
    if (!$conexionBD) {
        die('No se pudo conectar: ' . mysqli_error($conexionBD));
    }
    // Error 2: las mayúsculas y minúsculas son relevantes en Linux
    //Procuren que si las tablas de las base de datos están en minúsculas, realizar las consultas
    // en minúsculas
    $consultaSQL = 'SELECT DESCRIPCION, ID_MEDICAMENTO FROM medicamentos WHERE DESCRIPCION LIKE "%' . strtoupper($palabra) . '%" ORDER BY DESCRIPCION LIMIT 100;';
    // Ejecuta la consulta
    $datos = mysqli_query($conexionBD, $consultaSQL);
    $coincidencias = '';
    // Variable con resultados
    while ($valores = mysqli_fetch_array($datos)) {
        // Recorre los datos
        // Arma la lista de palabras que coinciden y su ID
        $coincidencias .= $valores['DESCRIPCION'] . '|' . $valores['ID_MEDICAMENTO'] . "\n";
    }
    mysqli_close($conexionBD);
    // Cierra la conexi�n
    return UTF8_encode($coincidencias);
    // Devuelve la lista
}
开发者ID:EdgardoPitti,项目名称:cuidadospaliativos,代码行数:30,代码来源:buscar_medicamento.php

示例2: __destruct

 public function __destruct()
 {
     if ($this->dbConn) {
         mysqli_close($this->dbConn);
         $this->dbConn = null;
     }
 }
开发者ID:nicocin,项目名称:silverstripe-framework,代码行数:7,代码来源:MySQLiConnector.php

示例3: query

/**
 * Make a sql query to the database.
 *
 * @param string $sql
 * @return integer
 */
function query($sql)
{
    $connection = connect();
    $res = mysqli_query($connection, $sql);
    mysqli_close($connection);
    return $res;
}
开发者ID:KINOTO,项目名称:apymeco-web,代码行数:13,代码来源:_main2.php

示例4: 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

示例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: Modificar

function Modificar()
{
    global $connect;
    $query = "UPDATE product SET name='{$_POST['name']}', price='{$_POST['price']}', stock='{$_POST['stock']}',\n\t category = '{$_POST['idFkCategory']}', brand='{$_POST['idFkBrand']}' idFkSize = '{$_POST['idFkSize']}',\n\t idFkColor='{$_POST['idFkColor']}' WHERE DNI='{$_POST['id']}';";
    mysqli_query($connect, $query) or die(mysqli_error($connect));
    mysqli_close($connect);
}
开发者ID:jlpsoft,项目名称:Proyecto_Moviles,代码行数:7,代码来源:Modificar.php

示例7: disconnect

 function disconnect()
 {
     if ($this->connectionId) {
         mysqli_close($this->connectionId);
         $this->connectionId = null;
     }
 }
开发者ID:knevcher,项目名称:limb,代码行数:7,代码来源:lmbMysqliConnection.class.php

示例8: myAccount

function myAccount()
{
    global $connect;
    $data = json_decode(file_get_contents('php://input'), true);
    $response = array();
    if (!$data) {
        $response['error']['message'] = "Invalid request.";
    } else {
        if (!isset($data['token']) || empty(trim($data['token']))) {
            $response['error']['message'] = "Token is required.";
        } else {
            $token = trim($data['token']);
            $query = mysqli_query($connect, "SELECT firstname, lastname, email, last_login FROM users WHERE token ='{$token}'");
            if ($query->num_rows > 0) {
                while ($row = $query->fetch_assoc()) {
                    $firstname = $row['firstname'];
                    $lastname = $row['lastname'];
                    $email = $row['email'];
                    $lastLogin = $row['last_login'];
                }
                $response = array('okay' => array('firstname' => ucwords(strtolower($firstname)), 'lastname' => ucwords(strtolower($lastname)), 'email' => $email, 'last_login' => date('F d, Y', strtotime($lastLogin))));
            } else {
                $response['error']['message'] = "Token is not correct.";
            }
            mysqli_close($connect);
        }
    }
    echo json_encode($response);
}
开发者ID:johnrobox,项目名称:Personal,代码行数:29,代码来源:myAccount.php

示例9: showVotes

function showVotes($db_handle, $db_found)
{
    $func_message = "";
    $username = $_SESSION['username'];
    $uid = getUID($db_handle, $username);
    if ($db_found) {
        //next query to find all files UID has voted on
        $SQL_stmt = "SELECT images_voted FROM users WHERE uid = '{$uid}'";
        $query_result = mysqli_query($db_handle, $SQL_stmt);
        if ($query_result) {
            $actual_result = mysqli_fetch_assoc($query_result);
            $images_voted = $actual_result['images_voted'];
            if ($images_voted != '') {
                $image_array = explode(',', $images_voted);
                foreach ($image_array as $image_id) {
                    $SQL_stmt = "SELECT fname FROM files WHERE fid = '{$image_id}'";
                    $query_result2 = mysqli_query($db_handle, $SQL_stmt);
                    $actual_result2 = mysqli_fetch_assoc($query_result2);
                    //echo $actual_result2['fname'] . "<br>";
                    echo "<a href='imageload.php?image=" . $actual_result2['fname'] . "'>" . $actual_result2['fname'] . " </a><br>";
                }
            } else {
                $func_message = "No files found";
            }
        } else {
            $func_message = "Error querying database";
        }
        mysqli_close($db_handle);
    } else {
        $func_message = "Error connecting to database";
    }
    return $func_message;
}
开发者ID:jeffwagner,项目名称:contest,代码行数:33,代码来源:userpage.php

示例10: insertarTweetInfo

function insertarTweetInfo($id_tweet, $tweet, $rts, $favs, $fecha_creacion, $usuario, $url_imagen, $followers, $followings, $num_tweets)
{
    //Creamos la conexión a la base de datos
    $conexion = mysqli_connect("localhost", "root", "", "twitterdata");
    //Comprobamos laconexión
    if ($conexion) {
    } else {
        die('Ha sucedido un error inexperador en la conexion de la base de datos<br>');
    }
    //Codificación de la base de datos en utf8
    mysqli_query($conexion, "SET NAMES 'utf8'");
    mysqli_set_charset($conexion, "utf8");
    //Creamos la sentencia SQL para insertar los datos de entrada
    $sql = "insert into tweets (id_tweet,tweet,rt,fav,fecha_creacion,usuario,url_imagen,followers,followings,num_tweets) \n            values (" . $id_tweet . ",'" . $tweet . "'," . $rts . "," . $favs . ",'" . $fecha_creacion . "','" . $usuario . "','" . $url_imagen . "'," . $followers . "," . $followings . "," . $num_tweets . ");";
    $consulta = mysqli_query($conexion, $sql);
    //Comprobamos si la consulta ha tenido éxito
    if ($consulta) {
    } else {
        die("No se ha podido insertar en la base de datos<br><br>" . mysqli_error($conexion));
    }
    //Cerramos la conexión de la base de datos
    $close = mysqli_close($conexion);
    if ($close) {
    } else {
        die('Ha sucedido un error inexperado en la desconexion de la base de datos<br>');
    }
}
开发者ID:dmoreno19949,项目名称:Sentimientos_twitter,代码行数:27,代码来源:insertarBD.php

示例11: get_search

function get_search()
{
    $strSQL = '';
    if (isset($_POST['searchtext'])) {
        $searchtext = $_POST['searchtext'];
        if ((string) (int) $searchtext == $searchtext) {
            $price = intval($searchtext);
            $strSQL = "SELECT m.deviceid,m.model FROM mobiles m, features f\n\t\t\t\t\t\tWHERE f.price BETWEEN {$price}-50 AND {$price}+50 AND m.DeviceID = f.DeviceID;";
        } else {
            $strSQL = "SELECT m.deviceid,m.model FROM mobiles m WHERE m.manufacture = '" . $searchtext . "' OR m.model = '" . $searchtext . "';";
        }
        $con = mysqli_connect("127.0.0.1", "root", "", "mobistore") or die(mysql_error());
        $rs = mysqli_query($con, $strSQL);
        $mobiles = array();
        while ($object = mysqli_fetch_object($rs)) {
            $mobiles[] = $object;
        }
        $display_str = "<table><tr>  <th>Sl No. </th> <th> DEVICES </th> </tr> ";
        $i = 0;
        foreach ($mobiles as $mobile) {
            if (intval($mobile->deviceid) < 50) {
                $display_str .= ' ' . "<tr> <td> " . ++$i . "</td> <td> <a href=" . $mobile->deviceid . ".php>" . $mobile->model . "</a> </td> </tr>";
            } else {
                $display_str .= ' ' . "<tr> <td> " . ++$i . "</td> <td> <a href=defaultdevice.php>" . $mobile->model . "</a> </td> </tr>";
            }
        }
        $display_str .= ' ' . "</table>";
        mysqli_close($con);
        return $display_str;
    }
}
开发者ID:saiushiv,项目名称:Web-Programming,代码行数:31,代码来源:search.php

示例12: validate

 private function validate()
 {
     if (DB_DRIVER == 'mysql') {
         if (!($connection = @mysql_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD))) {
             $this->error['warning'] = $this->language->get('error_db_connect');
         } else {
             if (!mysql_select_db(DB_DATABASE, $connection)) {
                 $this->error['warning'] = 'Error: Database "' . DB_DATABASE . '" does not exist!';
             }
             mysql_close($connection);
         }
     }
     if (DB_DRIVER == 'mysqli') {
         $link = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
         if (mysqli_connect_errno()) {
             $this->error['warning'] = 'Error database connect: "' . mysqli_connect_error() . '"';
             exit;
         }
         if (!mysqli_ping($link)) {
             $this->error['warning'] = 'Error database server: "' . mysqli_error($link) . '"';
         }
         mysqli_close($link);
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:packetlost,项目名称:OpenCart-Overclocked,代码行数:29,代码来源:upgrade.php

示例13: fetchdata

function fetchdata()
{
    if (connectdb()) {
        $conn = connectdb();
    }
    echo "<html><head><script type=\"text/javascript\" src=\"script.js\"></script>\n\t\t<link href=\"editpage.css\" rel=\"stylesheet\" type=\"text/css\">\n\t\t</head>";
    $data1 = mysqli_query($conn, "Select * from formdata");
    echo "<h1> Subscriber details </h1>";
    echo "<h2 id='message'></h2>";
    echo "<table border=1 width=100>\n\t\t<tr>\n\t\t<th>Name</th>\n\t\t<th>Sex</th>\n\t\t<th>Email</th>\n\t\t<th>Country</th>\n\t\t<th>State</th>\n\t\t<th>Address</th>\n\t\t<th>Mobileno</th>\n\t\t<th>Interests</th>\n\t\t<th>Favorites</th>\n\t\t<th>EDIT</th>\n\t\t<th>Delete</th>\n\t\t</tr>";
    while ($result = mysqli_fetch_array($data1)) {
        echo "<tr >";
        echo "<form method='post' style='width:200px'>";
        echo "<td>" . "<input type='text' name='name' value='" . $result['name'] . "'></td>";
        echo "<td>" . "<input type='text' name='sex' value='" . $result['sex'] . "'></td>";
        echo "<td>" . "<input type='text' name='email' value='" . $result['email'] . "'></td>";
        echo "<td>" . "<input type='text' name='country' value='" . $result['country'] . "'></td>";
        echo "<td>" . "<input type='text' name='state' value='" . $result['state'] . "'></td>";
        echo "<td>" . "<input type='text' name='address' value='" . $result['address'] . "'></td>";
        echo "<td>" . "<input type='text' name='mobileno' value='" . $result['mobileno'] . "'></td>";
        echo "<td>" . "<input type='text' name='interests' value='" . $result['interest'] . "'></td>";
        echo "<td>" . "<input type='text' name='favorites' value='" . $result['favorites'] . "'></td>";
        echo "<td>" . "<input type='button' name='edit' value='edit' onclick='modifydata(this)'>" . "</td>";
        echo "<td>" . "<input type='button' name='delete' value='delete' onclick='modifydata(this)''>" . "</td>";
        echo "</form>";
        echo "</tr>";
    }
    echo "</table>";
    echo "</html>";
    mysqli_close($conn);
}
开发者ID:ranajitbanerjee,项目名称:ranajitbanerjee.github.io,代码行数:31,代码来源:EditAndDelete.php

示例14: Decider

function Decider($dname, $dmail)
{
    $name = $dname;
    $mail = strtolower($dmail);
    //connect to the database
    $con = mysqli_connect("eu-cdbr-azure-west-a.cloudapp.net", "b8592f1b44ff9a", "fecb2128", "TeamProject");
    $name = mysqli_real_escape_string($con, $name);
    if (mysqli_connect_errno()) {
        return "f";
    }
    $query = "SELECT Email FROM Subscriber WHERE Email='" . $mail . "'";
    $result = mysqli_query($con, $query);
    if (mysqli_num_rows($result) > 0) {
        $result = Unsub($mail);
    } else {
        if (empty($mail)) {
            $result = Unsub($name);
        } else {
            $result = Subscribe($name, $mail);
        }
    }
    // Free result set
    mysqli_free_result($result);
    mysqli_close($con);
    return $result;
}
开发者ID:alexandroskou,项目名称:Repository1,代码行数:26,代码来源:SubDecide.php

示例15: insertDatabaseFunc

function insertDatabaseFunc($username, $password, $queryType, $entity)
{
    require_once 'queryDatabaseHelper.php';
    if (validUsernameAndPassword($username, $password)) {
        $link = mysqli_connect("localhost", "Tommy", "pickles", "Model");
        if (strcmp($queryType, 'Unsubs') == 0) {
            $query = 'DELETE FROM `subscription` WHERE `username`=\'' . $username . '\' AND `orgnumber`=\'' . $entity . '\'';
        } elseif (strcmp($queryType, 'RSVP') == 0) {
            $query = 'INSERT IGNORE INTO `rsvp`(`username`, `eventnumber`) VALUES (\'' . $username . '\',' . $entity . ')';
        } elseif (strcmp($queryType, 'Subs') == 0) {
            $query = 'INSERT INTO `subscription`(`username`, `orgnumber`) VALUES (\'' . $username . '\',\'' . $entity . '\')';
        } elseif (strcmp($queryType, 'AndroidDevice') == 0) {
            $query = 'INSERT IGNORE INTO `androiddevice`(`username`, `device_id`) VALUES (\'' . $username . '\',\'' . $entity . '\')';
        }
        if (mysqli_connect_errno()) {
            printf("Connect failed: %s\n", mysqli_connect_error());
            exit;
        }
        if (mysqli_query($link, $query)) {
            echo 'true';
        } else {
            echo 'false';
        }
        mysqli_close($link);
    } else {
        echo 'false';
    }
}
开发者ID:dongreenberg,项目名称:Bookie,代码行数:28,代码来源:insertDatabaseHelper.php


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