Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
<li id="fat-menu" class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
<?php $sql = mysql_query("SELECT * FROM agentes "); /*nome da tabela referida*/
while ($coluna = mysql_fetch_array($sql)){ ?>
<i class="icon-user"></i><?php echo $coluna[agent_nome]?>
<i class="icon-caret-down"></i>
</a>
<?php } ?>
Alguém sabe porque ta dando este erro quando vai consultar o mysql, coloquei o código acima do script da consulta.
ERRO
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/moedadeo/public_html/pasta/arquivo.php on line 19
DE O ERRO ( No database Selected ) MAIS NÃO ENTEDIE PQ TA TUDO CONECTADO COM O BANCO! :(
Posta os scripts, assim fica mais facil te ajudar! :assobiando:
outras paginas funcionam?
vc tem um linha com mysql_select_db() ?
<?php
include 'Connections/config.php';
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
// Logout the current user.
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "logoff.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "Admin";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "restrito.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?><html xmlns="[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="stylesheets/theme.css">
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="stylesheets/theme.css">
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.css">
<link rel="shortcut icon" href="../assets/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png">
<script src="lib/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="lib/bootstrap/js/bootstrap.js"></script>
<script src="lib/jquery.validate.js" type="text/javascript"></script>
<title>Admin</title>
</head>
<?php require_once("navbar.php"); ?>
<?php require_once("menu.php"); ?>
<body>
<div class="content">
<?php
$eco = $_GET["exe"];
$pag[1] = "home.php";
$pag[2] = "pagina01.php";
$pag[3] = "pagina02php";
if (!empty ($eco)) //Se a variavel link não estiver vazia
{
if (file_exists($pag[$eco])) //se o arquivo existir
{
include $pag[$eco]; // inclua o arquivo
}
else
{
include "inicial.php";
}
}
else
{
include "inicial.php";
}
?>
</div>
</body>
</html>
O script acima e a index2 depois que logado então onde estar o erro e no arquivo que incluído no topo da index (navbar.php).
script (navbar.php)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<ul class="nav pull-right">
<li><a href="#" class="hidden-phone visible-tablet visible-desktop" role="button">Configurações</a></li>
<li id="fat-menu" class="dropdown">
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown">
<?php
$sql = mysql_query("SELECT * FROM agentes") or die(mysql_error()); /*nome da tabela referida*/
while ($coluna = mysql_fetch_array($sql)){ ?>
<i class="icon-user"></i><?php echo $coluna['agent_nome']; ?>
<i class="icon-caret-down"></i>
</a>
<?php } ?>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">Meu perfil</a></li>
<li class="divider"></li>
<li><a tabindex="-1" class="visible-phone" href="#">Settings</a></li>
<li class="divider visible-phone"></li>
<li><a tabindex="-1" href="<?php echo $logoutAction ?>">Sair</a></li>
</ul>
</li></ul>
<a href="index2.php"><img src="images/topo-final.png" width="899" height="128" border="0" /></a>
</div>
</div>
</body>
</html>posta o codigo do config.php.........
ta ai acima!
a mensagem do erro diz claramente q o banco não foi selecionado........
so para teste tenta dar um include de config.php em navbar.php
Achei o proposito do erro, quando fui criar uma conexão no Dreamweaver fiz pelo menu DATABASE..... então ele criou o arquivo abaixo
<?php
$hostname_config = "localhost";
$database_config = "banco";
$username_config = "root";
$password_config = "senha";
$config = mysql_pconnect($hostname_config, $username_config, $password_config) or trigger_error(mysql_error(),E_USER_ERROR);
?>
Então refiz ai ficou dessa forma e o erro desapareceu.
<?php
$host="localhost";
$usuario="user";
$senha="senha";
$db=mysql_connect($host,$usuario,$senha) or die("Não foi possivel fazer a conexão com o servidor de banco de ");
mysql_select_db("moedadeo_emprestsys",$db) or die("Não foi possivel fazer a conexão com o banco de dados");
date_default_timezone_set('America/Sao_Paulo');
?>
Obrigado pela as ajudas... GRATA
Dreamweaver :cry:
DW é foda.... ¬¬'
deu erro na sua consulta.
deixe o codigo assim, vai exibir a msg do erro.
$sql = mysql_query("SELECT * FROM agentes") or die(mysql_error());
e aqui
deixe assim