Getting mysql_fetch_array() error
Hi
I'm getting mysql_fetch_array() expects parameter 1 to be resource, boolean,
I check the white space and maybe some can tell me what I did so I can corrrect the mistake. Thanks
<?php
session_start();
header("Cache-control: private");
require_once ('../include/init.php');
include_once("../ckeditor/ckeditor.php");?>
$page = $_GET['page'];
$sqlcats="SELECT * FROM pages WHERE pagename = '".$page."'";
//echo $sqlcats;
$rscats= mysql_query($sqlcats) ;
while($rowcats = mysql_fetch_array($rscats))
{
$thetext = $rowcats["editor1"];
$pagename = $rowcats["pagename"];
}
<html>
<head>
<title>ADMIN</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<style type="text/css">
<!--
.style3 {font-family: Arial, Helvetica, sans-serif;font-size: 16px;font-weight: bold;}
-->
</style>
</head>
<body>
<br>
<p align="center" class="style3">ADMIN</p>
<br>
<p align="center" class="style4">
<a href="index2.php">MAIN MENU</a>
<a href="logout.php">LOG OUT</a>
</p>
<? include("modifymenu.php");?>
<form action="../home.php" method="post" target="_blank">
<?php
$CKEditor->basePath = '/ckeditor/';
$CKEditor = new CKEditor();
$CKEditor->editor("editor1", $initialValue);
$initialValue = '<p>This is some <strong>sample text</strong>.</p>';
?>
<input type="submit" value="Submit"/>
<?
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
$initialized ['Enabled'] = true ;
?>
</form>
</body>
</html>
11 Months Ago
Last Updated
Related Article: mysql_fetch_array Error
is a solved PHP discussion thread by rpv_sen that has 4 replies, was last updated 2 years ago and has been tagged with the keywords: fetch, mysql, php/mysql.
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
@Red Dragon
Thanks for the reply. I will test that now
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
@Red Dragon
It's still saying that
Getting mysql_fetch_array() error
I double check my DB (mysql_select_db), just to make sure it's connected and it's connected.
I'm still getting the same error in this line again
while ($rowcats = mysql_fetch_array($rscats))
I appreciated you taking time to help me!
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
Do I need to create a table in order to retrieve the data?
The only thing I'm trying to retrieve is the home.php it's only things I'm trying to do
That's why used
$page = $_GET['page'];
and I'm using this to retrieve the page
while($rowcats = mysql_fetch_array($rscats))
{
$thetext = $rowcats["editor1"];
$pagename = $rowcats["pagename"];
}
but I'm getting the same error in this line
while ($rowcats = mysql_fetch_array($rscats);
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
@Red Dragon
No, I'm familiar with mysql, I think do have a table. The $page is home.php. On top of home.php I put this
<?php
$sql="SELECT * FROM pages WHERE pagename = 'home'";
$rs= mysql_query($sql);
$row = mysql_fetch_array($rs);
?>
This is the admin page which I posted above in the first post (which has the whole script):
$page = $_GET['page'];
$sqlcats="SELECT * FROM pages WHERE pagename = '".$page."'";
//echo $sqlcats;
$rscats= mysql_query($sqlcats) ;
while($rowcats = mysql_fetch_array($rscats))
{
$thetext = $rowcats["editor1"];
$pagename = $rowcats["pagename"];
}
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
Gosh, I forgot to double check my sentence. I meant to put the word not in the sentence
No, I'm familiar with mysql, I think do have a table. The $page is home.php. On top of home.php I put this
No, I'm not familiar with mysql, I think I do have a table and the $page is home.php. On top of home.php I put this
<?php
$sql="SELECT * FROM pages WHERE pagename = 'home'";
$rs= mysql_query($sql);
$row = mysql_fetch_array($rs);
?>
The home.php is on the server and that's why I'm using that code to to grab the file.
This is the admin page which I posted above in the first post (which has the whole script):
$page = $_GET['page'];
$sqlcats="SELECT * FROM pages WHERE pagename = '".$page."'";
//echo $sqlcats;
$rscats= mysql_query($sqlcats) ;
while($rowcats = mysql_fetch_array($rscats))
{
$thetext = $rowcats["editor1"];
$pagename = $rowcats["pagename"];
}
The issues is that's getting this error:
mysql_fetch_array() expects parameter 1 to be resource, boolean
on this line:
while($rowcats = mysql_fetch_array($rscats))
I read other threads, members & moderator repeatly saying check for white space that's why I'm doing it but it's still saying
mysql_fetch_array() expects parameter 1 to be resource, boolean
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
I'm still getting
mysql_fetch_array() expects parameter 1 to be resource, boolean
on this line:
while($rowcats = mysql_fetch_array($rscats))
I just want to resolve this error so I can go back to solve my original thread. which is
http://www.daniweb.com/web-development/php/threads/424568/create-a-archive-page
I can't work on that thread until I figure out this error:
mysql_fetch_array() expects parameter 1 to be resource, boolean
on this line:
while($rowcats = mysql_fetch_array($rscats))
I appreciated if someone can explain to me what to do and also help me with this. Once I solve this error I can go back to my old thread and work on it. That's why I create this thread to solve the other issue.
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
Hi
I try to switch up from
while($rowcats = mysql_fetch_array($rscats))
to
while($rowcats = mysql_num_rows($rscats))
Instead of this:
mysql_fetch_array() expects parameter 1 to be resource, boolean
Now I have this:
mysql_num_rows() expects parameter 1 to be resource, boolean
Any suggestions>? or explanation will do.
I try the topic to search on DaniWeb and to see some solution but each thread has different answers based on the script itself. It doesn't tell you how to resolve this universal.
Any Advice?
I mean I can post all of the threads just to prove that I'm looking for an solution. That's like 8 years of work.
I'll pick the ones that is closes to mines.
LastMitch
Industrious Poster
4,181 posts since Mar 2012
Reputation Points: 134
Solved Threads: 336
Skill Endorsements: 45
Question Answered as of 11 Months Ago by
Red Dragon