Problem with bank call for listing

-2

Good evening, I'm developing a system of hours, but I was barred by a connection problem so I could do my database listing on the screen ...

When I update the page it presents me with two errors:

  

Warning: mysql_select_db () expects parameter 2 to be resource, object given in C: \ wamp64 \ www \ Project Beauty and Harmony \ Beauty and   Harmonia - site \ Adm \ AdmAgenda.php on line 6

&

  

Warning: mysqli_query () expects parameter 1 to be mysqli, string given in C: \ wamp64 \ www \ Project Beauty and Harmony \ Beauty and Harmony -   site \ Adm \ AdmAgenda.php on line 11

I have tried to sort out the php knowledge that in the case I am new, and I had to solve this problem, in case what would be wrong?

My php code:

<?php
//require_once 'valida.php';
// definições de host, database, usuário e senha
include("../php/conexao.php");

mysql_select_db($bd, $link);

// cria a instrução SQL que vai selecionar os dados
$selecionar = "SELECT id, horas de segunda feira FROM horas_segunda";
// executa a query
$dados = mysqli_query($selecionar, $link) or die(mysql_error());
// transforma os dados em um array
$linha = mysql_fetch_assoc($dados);
// calcula quantos dados retornaram
$total = mysql_num_rows($dados);
?>

    <!DOCTYPE html>
    <html lang="pt-br" ng-app="AngularADM">

    <head>
        <meta charset="utf-8">
        <meta name="description" content="Beleza e Harmonia é um salão de beleza">
        <meta name="author" content="Miyomic">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Administração</title>
        <link rel="shortcut icon" href="../Imagens/favicon.png" type="image/x-png" />



        <link rel="stylesheet" type="text/css" href="../css/visual.css">

        <!-- responsivo -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <link href="../css/bootstrap.min.css" rel="stylesheet">
        <link href="../css/bootstrap.css" rel="stylesheet">
        <link href="../css/bootstrap-theme.css" rel="stylesheet">
        <link href="../css/bootstrap-theme.css.map" rel="stylesheet">
        <link href="../css/bootstrap-theme.min.css" rel="stylesheet">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
        <script src="../js/jqueryAtualizado.js"></script>
        <script src="../js/jqueryAtualizado.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <script src="../js/bootstrap.min.js"></script>
        <!-- Fim responsivo -->
        <script src="../js/angular.min.js"></script>
    </head>

    <body ng-controller="TempoHorasP1">

        <header id="header">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">
                        <div class="block-left">
                            <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                                <div class="container-fluid">
                                    <div class="navbar-header">
                                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                                            <span class="sr-only">toggle navigation</span>
                                            <span class="icon-bar"></span>
                                            <span class="icon-bar"></span>
                                            <span class="icon-bar"></span>
                                            <span class="icon-bar"></span>
                                        </button>
                                        <div class="nav-logo col-md-8 righ-menu">
                                            <img src="../Imagens/logo-branco.png" alt="Studio 7 Hair">
                                        </div>
                                    </div>

                                    <div class="collapse navbar-collapse col-md-4" id="bs-example-navbar-collapse-1">
                                        <ul class="nav navbar-nav">
                                            <li class="active"><a href="AdmAgenda.php" class="item-menu-adm"><span>Seja bem vindo</span></a></li>
                                            <li><a class="item-menu-adm"><span>Configuração da Agenda</span><span class="sr-only">(current)</span></a></li>
                                            <li><a href="cadastro.html" class="item-menu-adm"><span>Cadastrar Administrador</span><span class="sr-only">(current)</span></a></li>
                                            <li><a href="Ajuda.php" class="item-menu-adm"><span>Solicitar Ajuda</span></a></li>

                                        </ul>
                                    </div>
                                </div>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>
        </header>

        <section>
            <div class="container">
                <div class="row">
                    <h1 class="dourado texto-centro cabeca-adm">Beleza e Harmônia</h1>
                </div>

                <div class="alert alert-warning" role="alert">
                   <span class="glyphicon glyphicon-warning-sign"></span> <span class="texto-centro margin-canto10">As configurações selecionadas abaixo sera alterada no Agendamento online. Por favor tomar cuidado nas escolhas das opções seguinte, suas definições são online.
                        <br/> Em caso de congestionamento no servidor aguardar de 5 a 10 minutos.</span>

                </div>

            </div>

        </section>



        <div class="container">
            <div class="row">
                <h2 class="dourado texto-centro margin-top30 bold">Configuração da agenda online</h2>
            </div>

            <div class="row">

                <h3 class="texto-centro dourado">Agenda da 1º semana</h3>
                <hr />

                <div class="col-lg-12 center-block">
                    <div class="col-lg-2 texto-centro">
                        <p>Id</p>
                        <hr />
                    </div>

                    <div class="col-lg-2 texto-centro">
                        <p>Segunda</p>
                        <hr />
                    </div>






                    <?php

    if($total > 0) {

        do {

?>
                        <div class="row">
                            <div class="col-lg-2 texto-centro hora-banco">
                                <p>
                                    <?=$linha['id']?>
                                </p>

                            </div>

                            <div class="col-lg-2 texto-centro hora-banco">
                                <p>
                                    <?=$linha['horas_segunda']?>
                                </p>

                            </div>

                        </div>
                        <?php

        }while($linha = mysql_fetch_assoc($dados));

    }
?>


                </div>
            </div>


            <div class="form-alterar margin-top40 texto-centro">
                <h3 class="margin-top20">Área de alteração dos horários</h3>
            <form name="alterar" method="post" action="">

                <div class="row texto-centro">
            <span>Id = </span> <input type="text" class="campo-alterar texto-centro margin-canto10" placeholder="Insira o id da tabela" /> 

                    <span>Hora = </span> <input type="text" class="campo-alterar texto-centro margin-canto10" placeholder="Hora que deseja" />
            </div>

                            <div class="row texto-centro margin-top20">
                <button ng-click="atualizar()" value="descobrir" class="botao-atualizar">Atualizar <span class="glyphicon glyphicon-send branco"></span></button>

            </div>


            </form>


                <div class="alert alert-danger" role="alert">Para poder ter sucesso na alteração da agenda terá que ver qual id que deseja para poder selecionar</div>

                </div>

        </div>

    </body>


    </html>

    <?php
// tira o resultado da busca da memória
mysql_free_result($dados);
?>

My php connection:

<?php 

$host = "localhost";
$usuario = "root";
$senha = "";
$bd="admin_site";



$link = new mysqli($host, $usuario, $senha, $bd);


if($link -> connect_errno) {
    echo "Falha na conexão: (".$link->connect_errno.") ".$link->connect_error;
}


?>
    
asked by anonymous 10.01.2017 / 00:51

2 answers

4

If not, you've reversed it, it's the $ link first. And in or die(mysql_error()) you have used the stale function mysql and different from the one you are using. The correct would be:

$dados = mysqli_query($link,$selecionar) or die(mysqli_error($link));

In this line the parameters are also reversed, and again the confusion with mysql :

mysql_select_db($bd, $link);

The correct one would be:

mysqli_select_db($link,$bd);

But it is not necessary to select bd again, since in this line $link = new mysqli($host, $usuario, $senha, $bd); you have already selected it, unless you have intentionally changed it.

Check out the documentation:

link

link

    
10.01.2017 / 00:54
-1

You are mixing procedural mysqli with object-oriented mysqli. The following form is correct:

$selecionar = "SELECT id, horas de segunda feira FROM horas_segunda";
$dados = $link->query($selecionar);
$linha = $dados->fetch_assoc();
$total = $dados->num_rows;

Note: in the line-oriented version of mysqli_select_db() is no longer required.

    
10.01.2017 / 01:09