Jump to content
  • 0

Warning: mysql_fetch_array()


novickOk
 Share

Question

Здравствуйте, есть такой код:

<? include ("connect.php");
?>

<?php
$result = mysql_query("SELECT id FROM view_news",$db);

if (!$result)
{
echo "<p>Запрос на выборку данных из базы не прошел.<br> <strong>Код ошибки:</strong></p>";
exit(mysql_error());
}

if (mysql_num_rows($result) > 0)

{
$myrow = mysql_fetch_array($result);
}

else
{
echo "<p>Информация по запросу не может быть извлечена в таблице нет записей.</p>";
exit();
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Все новости</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="container">
<div id="header"><?php include "header.php";?></div>
<div id="sidebar">
<?php include "blocks/sidebar.php"; ?>
</div>
<div id="content">

<?php do
{
printf ("Айди:%s",$myrow["id"]);
}
while ($myrow = mysql_fetch_array($result));?>

</div>
<div id="footer"><?php include ("footer.php"); ?></div>
</div>
</body>
</html>

На сайте выводится только первый айди, затем идет ошибка:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in *cut* on line 44

Строка 44:

while ($myrow = mysql_fetch_array($result));

Вот как это выглядит на сайте:1338638691377.png

Как исправить эту ошибку?

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

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. See more about our Guidelines and Privacy Policy