Jump to content
n0TTT_

Erro(Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in index.php on line 26)

Recommended Posts

n0TTT_

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in index.php on line 26

Linha:

<?php
while($row = mysql_fetch_array($sql)){ //Linha 26

$sectionID = $row["id"];
$sectionTitle = $row["title"];
$displayList .= '<br /><a href="section.php?id=' . $sectionID . '"><img src="style/sectionPic.jpg" width="61" height="23" alt="Section" />
					 ' . $sectionTitle . '</a><br /><hr />';
}
?>

Edited by Rui Carlos
Formatação do código.

Share this post


Link to post
Share on other sites
n0TTT_

Parece-me que o problema está na variável $sql, que não mostras como é inicializada.

$sql = mysql_query("10");
$displayList = ""; // Initialize the display variable here
while($row = mysql_fetch_array($sql)){

$sectionID = $row["id"];
$sectionTitle = $row["title"];
$displayList .= '<br /><a href="section.php?id=' . $sectionID . '"><img src="style/sectionPic.jpg" width="61" height="23" alt="Section" />
					 ' . $sectionTitle . '</a><br /><hr />';
}

Edited by Rui Carlos

Share this post


Link to post
Share on other sites
Rui Carlos

O 10 é suposto ser uma query?

O que está a acontecer é que a função mysql_query está a dar erro, e como tal devolve FALSE.

Seria conveniente explicares o que estás a tentar fazer.

Também não devia usar a função mysql_query, como é indicado aqui.

Share this post


Link to post
Share on other sites
n0TTT_

vou mandar o código todo

isto original mente estáva assim :

<?php
session_start();
include_once "../scripts/connect_to_mysql.php"; // Connect to the database
$sql = mysql_query("SELECT * FROM forum_sections ORDER BY ordered ASC LIMIT 10");
$displayList = ""; // Initialize the display variable here
while($row = mysql_fetch_array($sql)){

$sectionID = $row["id"];
$sectionTitle = $row["title"];
$displayList .= '<br /><a href="section.php?id=' . $sectionID . '"><img src="style/sectionPic.jpg" width="61" height="23" alt="Section" />
					 ' . $sectionTitle . '</a><br /><hr />';
}
?>
<!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=utf-8" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<title>Web Intersect Forum</title>
</head>
<body>
<?php include_once("template_header.php"); ?>
<table style="background-color: #F0F0F0; border:#069 1px solid; border-top:none;" width="900" border="0" align="center" cellpadding="12" cellspacing="0">
<tr>
<td width="731" valign="top">
<div id="breadcrumbs"><a href="http://www.webintersect.com">Web Intersect Home</a></div>
<div id="sectionLinks"><ul><?php echo $displayList; ?></ul></div></td>
<td width="189" valign="top"><div style=" width:160px; height:600px; background-color: #999; color: #CCC; padding:12px;">
 <br /><br /><br />
 <h3>Ad Space or Whatever</h3>
</div></td>
</tr>
</table>
<?php include_once("template_footer.php"); ?>
</body>
</html>

tirei o código da net..

Share this post


Link to post
Share on other sites
HappyHippyHippo

nem vou comentar o quanto desactualizado esse código está

altera para isto e diz qual é a mensagem de erro

$sql = mysql_query("SELECT * FROM forum_sections ORDER BY ordered ASC LIMIT 10") or die(mysql_error());


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
n0TTT_

Sim realmente este mod e de 2009, andei a procura e encontrei o actualizado de 2013 xD vou ver se tem erros

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.