function __construct() { $db = mysqli(DB_HOST, DB_USER, DB_PASSWORD); //or die('Could not connect to MySQL server.'); //if($db->connect_errno > 0){ //if($db->connect_error > 0){ if ($db->mysqli_connect_error()) { die('Unable to connect to database [' . $db->mysqli_connect_error() . ']'); //die('Unable to connect to database [' . $db->connect_error . ']'); } //$__dblink = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD) or die('Could not connect to MySQL server.'); //mysqli_select_db(DB_DATABASE, $__dblink); }
/** * @see \Fine47\DbOne\Prototype::tcpConnect() */ public function tcpConnect($host, $user, $pass, $db = '', $port = -1) { if (1 > $port) { $port = 3306; } $this->dbc = \mysqli($host, $user, $pass, $db, $port); if (!$this->dbc) { throw new DatabaseError('Unable to connect to host [' . $host . ']', 500, 0x883e); } $this->raisePossibleError(0x99fe); // Set auto-commit to active by default. $this->autoCommit(true); }
function server_connect($dbserver, $dbuser, $dbpass) { $con = mysqli($dbserver, $dbuser, $dbpass) or die("unable to connect to server"); return $con; }
<?php if (!isset($_SESSION)) { session_start(); } require_once "inc/mysql.php"; if (isset($_SESSION['log_usu']['autenticado']) && $_SESSION['log_usu']['autenticado']) { } else { header("Location:index.php"); } $sSQL = "DELETE FROM usuarios " . "WHERE usuario_id = {$_GET['id']} "; if ($oUsuario = mysqli($sSQL)) { header("Location:listado.php"); }
<?php require "cabecera.php"; require_once "inc/mysql.php"; if (isset($_SESSION['log_usu']['autenticado']) && $_SESSION['log_usu']['autenticado']) { $bien = $_POST["txtBien"]; $consulta = "SELECT indices.codIndice,CONCAT(notarios.nom_not,' ',notarios.mat_not,' ',notarios.pat_not) AS notario,indices.otorgante,indices.favorecido,indices.fecha,indices.subserie,indices.folio,indices.escritura,indices.bien FROM indices INNER JOIN notarios ON indices.codNotario=notarios.cod_not WHERE indices.bien LIKE '%{$bien}%'"; $result = mysqli($consulta); $total = $result->num_rows; } else { header("Location:index.php"); } require "menu.php"; ?> <div class="container"> <div class="row"> <div class="col-md-12"> <center><h3>Lista de Índices por Nombre del Bien</h3></center> <?php echo "<h4>Número de Índices Encontrados: {$total} Índices</h4> "; ?> <table class="table table-striped table-bordered table-condensed" > <thead> <tr> <th>Número</th> <th>Nombre Notario</th> <th>Otorgante</th>
<?php //print_r($_POST); //Por aqui hacer el require de db.php require "inc/mysql.php"; $sSQL = "UPDATE usuarios SET " . "paterno = '{$_POST['txt-paterno']}', " . "materno = '{$_POST['txt-materno']}', " . "nombres = '{$_POST['txt-nombres']}', " . "usuario = '{$_POST['txt-usuario']}', " . "clave = '{$_POST['txt-clave']}' " . "WHERE usuario_id = {$_POST['txt-id']}"; $oResponse = array(); if ($oResultado = mysqli($sSQL)) { $oResponse['success'] = TRUE; } else { $oResponse['success'] = FALSE; } echo json_encode($oResponse);
$esay = mysqli_num_rows($soal_esay); if (!empty($pilganda) and !empty($esay)) { if (!empty($_POST['soal_pilgan'])) { $benar = 0; $salah = 0; foreach ($_POST['soal_pilgan'] as $key => $value) { $cek = mysqli_query($db, "SELECT * FROM tb_soal_pilgan WHERE id_pilgan = '{$key}'") or die($db->error); while ($c = mysqli_fetch_array($cek)) { $jawaban = $c['kunci']; /** * ------------------------ * | id | jawaban | siswa | * ------------------------ */ $query = "INSERT INTO tb_jawaban_pilgan VALUES(null, '{$value}', '{$_SESSION['siswa']}')"; mysqli($db, $query) or die($db->error); } if ($value == $jawaban) { $benar++; } else { $salah++; } } $jumlah = $_POST['jumlahsoalpilgan']; $tidakjawab = $jumlah - $benar - $salah; $hasil = $benar; mysqli_query($db, "INSERT INTO tb_nilai_pilgan VALUES ('', '{$id_tq}', '{$_SESSION['siswa']}', '{$benar}', '{$salah}', '{$tidakjawab}', '{$hasil}')") or die($db->error); } else { if (empty($_POST['soal_pilganda'])) { $jumlah = $_POST['jumlahsoalpilgan']; mysqli_query($db, "INSERT INTO tb_nilai_pilgan VALUES ('', '{$id_tq}', '{$_SESSION['siswa']}', '0', '0', '{$jumlah}', '0')") or die($db->error);
<?php mysql_connect("localhost", "root", "70sunogo") or die("Could not connect to the server"); mysql_select_db("photo") or die("Unable to connect to database"); mysql_query('SET NAMES utf8'); if (isset($_POST['log'])) { $nm = $_POST['nm']; $ds = $_POST['dl']; foreach ($_FILES['files']['tmp_name'] as $key => $name_tmp) { $name = $_FILES['files']['name'][$key]; $tmpnm = $_FILES['files']['tmp_name'][$key]; $type = $_FILES['files']['type'][$key]; $size = $_FILES['files']['size'][$key]; $dir = "img/photoedit/" . $name; $move = move_uploaded_file($tmpnm, $dir); if ($move) { $hsl = mysqli("INSERT into `photo`.`photoedit` VALUES ('', '{$nm}', '{$ds}', '{$name}', '{$type}', '{$size}')"); if ($hsl) { echo "<script>alert('Добавлено')</script>"; } else { echo "<script>alert('Помилка бази данних')</script>"; } } else { echo "<script>alert('Помилка папки')</script>"; } } } ?> <div class="col-md-2 col-lg-2 col-sm-2 col-xs-0"> </div> <div class="col-md-8 col-lg-8 col-sm-8 col-xs-12 form_edit"> <p class="form_edit_name"> Тут ви можете додати відредаговані фото: </p>
<?php $ruta = "127.0.0.1"; $usuario = "root"; $password = "******"; $basedatos = "fail"; $puerto = "3306"; $conn = mysqli($ruta, $usuario, $password, $basedatos, $puerto); if ($conn->errno != 0) { die("Error de Conexion a la Base de Datos Fail"); } echo "No murio."; $conn->set_charset('utf8');
$result = mysqli($consulta); $total = $result->num_rows; } else { header("Location:index.php"); } require "menu.php"; //echo $notario; ?> <div class="container"> <div class="row"> <div class="col-md-12"> <?php $sql = "SELECT CONCAT(nom_not,' ',mat_not,' ',pat_not)as notario from notarios where cod_not={$notario}"; //echo $sql; $nombre = mysqli($sql); $nom = $nombre->fetch_assoc(); ?> <center> <?php echo "<h3>Lista de Índices por el Notario {$nom['notario']}</h3>"; ?> </center> <?php echo "<h4>Número de Índices Encontrados: {$total} Índices</h4> "; ?> <table class="table table-striped table-bordered table-condensed" > <thead> <tr> <th>Número</th>
<?php //cadena de conexion $conn = mysqli_connect("localhost", "root", "root", "TOMO2"); //DEBO PREPARAR LOS TEXTOS QUE VOY A BUSCAR si la cadena existe if ($busqueda != '') { //CUENTA EL NUMERO DE PALABRAS $trozos = explode(" ", $busqueda); $numero = count($trozos); if ($numero == 1) { //SI SOLO HAY UNA PALABRA DE BUSQUEDA SE ESTABLECE UNA INSTRUCION CON LIKE $cadbusca = "SELECT subcategory, name FROM Productos WHERE subcategory LIKE '%{$busqueda}%' OR name LIKE '%{$busqueda}%' LIMIT 50"; } elseif ($numero > 1) { //SI HAY UNA FRASE SE UTILIZA EL ALGORTIMO DE BUSQUEDA AVANZADO DE MATCH AGAINST //busqueda de frases con mas de una palabra y un algoritmo especializado $cadbusca = "SELECT subcategory, name , MATCH ( name, subcategory ) AGAINST ( '{$busqueda}' ) AS Score FROM Productos WHERE MATCH ( name, subcategory ) AGAINST ( '{$busqueda}' ) ORDER BY Score DESC LIMIT 50"; } $result = mysqli($conn, $cadbusca); while ($row = mysqli_fetch_object($result)) { //Mostramos los titulos de los articulos o lo que deseemos... $subcategory = $row->subcategory; $name = $row->name; echo $subcategory . " - " . $name . "<br>"; } }
<div class="col-md-12"> <h3>Modificar Usuario</h3> <?php if (isset($_SESSION['mensaje']) and $_SESSION['mensaje'] != '') { ?> <div class="alert alert-info"> <?php echo $_SESSION['mensaje']; unset($_SESSION['mensaje']); ?> </div> <?php } $sSQL = "SELECT u.* " . "FROM usuarios u " . "WHERE usuario_id = {$_GET['id']} "; $oUsuario = mysqli($sSQL); $aUsuario = $oUsuario->fetch_assoc(); ?> <form class="form-horizontal" method='post' name='fregistro' id='fregistro' action='estudiante.modifica.guarda.php' role='form'> <input type="hidden" id="txt-id" name="txt-id" value = "<?php echo $aUsuario['usuario_id']; ?> " > <div class="form-group"> <label for="txt-paterno" class="col-sm-2 control-label">Paterno :</label> <div class="col-sm-2"> <input type="text" class="form-control" id="txt-paterno" name="txt-paterno" placeholder="Apellido Paterno" maxlength="25" value = "<?php echo $aUsuario['paterno']; ?>
} require_once "inc/mysql.php"; $_SESSION['log_usu']['log_usu'] = $usuario = $_POST['txt-usuario']; $clave = $_POST['txt-clave']; $boton = $_POST['btn-aceptar']; /* echo $usuario; echo $clave; echo $boton; */ //$sConsulta = "SELECT NOW() as fechita"; //$oFecha = mysqli($sConsulta); //$aFecha = $oFecha->fetch_assoc(); //print_r($aFecha); $sConsulta = "SELECT u.* " . "FROM usuarios u " . "WHERE u.log_usu = '{$usuario}'"; if ($oUsuario = mysqli($sConsulta)) { //Almacenamos la cantidad de resultados (rows) $nUsuario = $oUsuario->num_rows; //Cuando solo existe un usuario if ($nUsuario == 1) { $aUsuario = $oUsuario->fetch_assoc(); if ($aUsuario['psw_usu'] == $clave) { $_SESSION['log_usu']['nombre'] = TRUE; $_SESSION['log_usu']['autenticado'] = TRUE; $_SESSION['log_usu']['id'] = $aUsuario['cod_usu']; header("Location:bienvenido.php"); } else { ?> <div class="alert alert-error"> <p><strong>Error!!!</strong>Contraseña incorrecta</p> </div>