Cant display mysql data


Posted on 16th Feb 2014 07:03 pm by admin

Hey all,

I am learning php and my first goal is to create a simple CMS. At the moment I am stuck on not being able to pull page names and their id`s from my DB and combine them into a list of links (like so/manage_pages.php?page_id=1) so I could grab id`s later for update and delete pages. Problem is when I load the page none of the links are displayed. My php5 is set up so that I could see all of the errors but there are none displayed nor is there anything in the log.

Here are the function I am using:

Code: [Select]<?php
function confirm_query($result_set) {
if (!$result_set) {
die("Database query failed: " . mysql_error());
}
}

function get_all_pages() {
global $connection;
mysql_select_db("content_MS", $connection);
$query = "SELECT *
FROM pages
ORDER BY id ASC";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);
return $result_set;

}

function list_pages(){

global $connection;
$result = get_all_pages();
$output = "<div>";
$output .= "<p>Select the page you would like to edit:</p>";
while($row = mysql_fetch_array($result))
{
$output .="<ul>";
$output .= "<li>";
$output .= "<a href="manage_pages.php?page=" . urlencode($row["id"]) ."">{$row["page_name"]}</a></li>";
$output .="</ul>";
}
$output .="</div>";
return $output;
}
?>

Then I simply echo list_pages function on a page:

Code: [Select]<?php include ("includes/header.php"); ?>
<div id="content">
<div class="in">
<h2>This is the main content</h2>

<?php list_pages();?>
</div>
</div>
<?php include ("includes/footer.php"); ?>

And below is the html code I see when I load the page:

Code: [Select]
<!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" lang="en" xml:lang="en">
<head>
<title>Content Manager - Manage Pages</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="css/back_css.css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div class="in">
<h1>Welcome To Your Content Manager!</h1>
</div>
</div>

<div id="content-wrapper"> <div id="content">
<div class="in">
<h2>This is the main content</h2>

</div>
</div>
</div>
<div id="left"><div class="in">
<h2>Menu</h2>
<ul>
<li><a href="manage_pages.php?name=Manage Pages"> Manage Pages </a></li>
<li><a href="manage_menu.php?name=Manage Menu"> Manage Menu </a></li>
<li><a href="manage_albums.php?name=Manage Albums"> Manage Albums </a></li>
<li><a href="manage_videos.php?name=Manage Videos"> Manage Videos</a></li>
<li><a href="manage_gigs.php?name=Manage Gigs"> Manage Gigs </a></li>
<li><a href="manage_news.php?name=Manage News"> Manage News</a></li>
</ul>
</div></div>
<div id="footer"><span>by AB</span></div>
</div>
</body>
</html>

Any ideas ?

Thanks in advance !

No comments posted yet

Your Answer:

Login to answer
187 Like 16 Dislike
Previous forums Next forums
Other forums

Needing Youtube thumb nail fix.
I have a script on a site that pulls in you-tube videos,
The problem is, that the thumb nails for

Links not updating
I'm trying to fuel a simple navigation system for a news section. It works fine when it comes to ret

Remote Database Access
Hey guys!!

OK, i'm used to only working with databases from the CPANEL, accessing phpMyAdmin

Deleting Partners on the Customer Master.
Does SAP handle removing the Partner from Open Sales Orders when a Partner is deleted in the Custome

Page doesn't expand for content
Hi. I've been testing a query I made. It's here http://lapr1.6te.net/inquerito.php
The page doesn

question about stripslashes and real_escape_string
im cleaning up an old app that I wrote fixing some of the vulernabilities from attacks.

I hav

Basic Question Regarding PHP Includes
Hi

Just starting out with PHP.

Working on a site that uses some basic includes, these

HTML Viewer HIDE scrollbar
How can I disable scrollbars in a HTML Viewer control? I can't hide them. Even i have enough space b

Undefined variable: adHTML
Hello:

While checking my site error logs, I've noticed one repetitive error that fills the lo

timezone change with date()
so i put all my times for posts in my made from scratch forum(not phpbb3 or sm)
in my mysql db u

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash