Jump to content

Recommended Posts

Alright, I have a script here and I have two sections to it: View (one page, includes some functions), and the Administration (a couple pages, displays fine).

 

My one page, view.php, doesn't echo anything while the Administration does (view.php's source is completely empty).

 

The display_errors is set to E_ALL, so it displays everything... there aren't any errors.

 

view.php:

<?php
/* View Readerboard
* Script by Alex Crooks
* Copyright 2009, protected under Creative Commons Licence
*/
include("config.php");
$functionset = "display";

$output = "<div id=\"content\">\n"
         ."<div id=\"slider1\" class=\"sliderwrapper\">\n"
         .retrieveContent()
         ."</div>\n"
         ."<div id=\"paginate-slider1\" class=\"pagination\"></div>\n"
         ."<script type=\"text/javascript\">\n"
         ."featuredcontentslider.init({\n"
     ."id: \"slider1\",  //id of main slider DIV\n"
     ."contentsource: [\"inline\", \"\"],  //Valid values: [\"inline\", \"\"] or [\"ajax\", \"path_to_file\"]\n"
         ."toc: \"#increment\",  //Valid values: \"#increment\", \"markup\", [\"label1\", \"label2\", etc]\n"
         ."nextprev: [\"\", \"\"],  //labels for \"prev\" and \"next\" links. Set to \"\" to hide.\n"
         ."revealtype: \"click\", //Behavior of pagination links to reveal the slides: \"click\" or \"mouseover\"\n"
         ."enablefade: [true, 0.2],  //[true/false, fadedegree]\n"
         ."autorotate: [true, 10000],  //[true/false, pausetime]\n"
         ."onChange: function(previndex, curindex){  //event handler fired whenever script changes slide\n"
         ."//previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)\n"
         ."//curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)\n"
         ."}})\n"
         ."</script>\n"
         ."</div>\n"
         ."<div id=\"block\">\n"
         //.retrieveBlockOrder() needs to be added
         ."</div>\n"
         ."<div id=\"messages\">\n"
         ."<b>Messages at the Office for:</b><br />\n"
         .retrieveMessages()
         ."</div>\n"
         ."<div id=\"time\">\n"
         .retrieveTime()
         ."</div>\n"
         ."</div>\n";

$pagecontents = $output;
include("layout.php");
?>

 

config.php

<?php
/* Readerboard Configuration Page
* Script by Alex Crooks
* Copyright 2009, protected under Creative Commons Licence.
*/
error_reporting("E_ALL"); // Display all errors. & ~E_NOTICE

// Define database information
$mysql['host'] = "localhost";
$mysql['database'] = "gphostin_readerboard";
$mysql['username'] = "gphostin_readerb";
$mysql['password'] = "********";
$mysql['dbprefix'] = "rdbd";

// Define table names
define("TABLE_CONTENT", $mysql['dbprefix']."_content");
define("TABLE_MESSAGES", $mysql['dbprefix']."_messages");
define("TABLE_SETTINGS", $mysql['dbprefix']."_settings");

// Connect to the database
if($mysql['conn'] = mysql_connect($mysql['host'], $mysql['username'], $mysql['password']))
{
$mysql['select'] = mysql_select_db($mysql['database'], $mysql['conn']);

if(!$mysql['select'])
{
echo "<b>Error:</b> Failed connection to database.<br /><br />".mysql_error();
}
}
else
{
echo "<b>Error:</b> Failed connection to server.<br /><br />".mysql_error();
}
// Access Settings
$sql = "SELECT * FROM ".TABLE_SETTINGS." WHERE ID = '1'";
$exe = mysql_query($sql);
$row = mysql_fetch_array($exe);
$sitelive = $row['live'];

// Retrieve Functions File
include("functions.php");
?>

 

layout.php:

<?php
/* Readerboard Layout File
* Script by Alex Crooks
* Copyright 2009, protected under Creative Commons Licence.
*/
if($functionset == "admin")
{
$navrowlink[] = "<a href=\"".$_SERVER['PHP_SELF']."?page=status\">Manage Status</a>";
$navrowlink[] = "<a href=\"".$_SERVER['PHP_SELF']."?page=content\">Manage Content</a>";
$navrowlink[] = "<a href=\"".$_SERVER['PHP_SELF']."?page=messages\">Manage Messages</a>";
//$navrowlink[] = "<a href=\"".$_SERVER['PHP_SELF']."\">Manage Block Order</a>";
$navrowlink[] = "<a href=\"".$_SERVER['PHP_SELF']."?page=stylesheet\">Manage Stylesheet</a>";
$navrowlink[] = "<a href=\"view.php\">View Readerboard</a>";
$navrow = implode("<br />\n", $navrowlink);

$top = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
      ."<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
  ."<head>\n"
  ."<title></title>\n"
  ."<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n"
      ."<style type=\"text/css\">\n"
      ."body { margin: 5px; font-family: Verdana, Arial, sans-serif; font-size: 10pt; background-color: white; color: black; }\n"
  ."img { border: 0; }\n"
  ."#outer { height: 100%; }\n"
      ."#left { float: left; clear: left; width: 15%; height: 100%; }\n"
      ."#right { float: center; clear: right; margin-left: 15%; }\n"
      ."</style>\n"
      ."</head>\n"
      ."<body>\n"
      ."<div id=\"outer\">\n"
      ."<div id=\"left\">\n"
      ."<span style=\"font-weight: bold; font-size: 14pt;\">Navigation</span><br /><br />\n"
      .$navrow
      ."</div>\n"
      ."<div id=\"right\">\n"
      ."<span style=\"font-weight: bold; font-size: 14pt;\">".$pagetitle."</span><br /><br />\n";
  
$bot = "</div>\n"
      ."</div>\n"
      ."</body>\n"
      ."<!-- Copyright 2009, protected under the Creative Commons Licence -->\n"
  ."</html>\n";

echo $top.$pagecontents.$bot;
}
if($functionset == "display")
{
include("config.php");

$sql = "SELECT ID, stylesheet FROM ".TABLE_SETTINGS." WHERE ID = '1'";
$row = mysql_fetch_array(mysql_query($sql));

$top = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"
      ."<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
  ."<head>\n"
  ."<title></title>\n"
  ."<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n"
  ."<script type=\"text/javascript\" src=\"javascript.js\">\n"
  ."/* Content Glider Script by Dynamic Drive (dynamicdrive.com)\n"
  ." * JQuery New Wave Script by John Resig (jquery.com)\n"
  ." * Date and Time Script by Dynamic Drive (dynamicdrive.com)\n"
  ." * All protected under respective copyrights.\n"
  ." */\n"
  ."</script>\n"
  ."<style type=\"text/css\">\n"
  .$row['stylesheet']
  ."</style>\n"
  ."</head>\n"
  ."<body scroll=\"no\" onLoad=\"goforit()\">\n"
  ."<div id=\"outer\">\n"
      ."<div id=\"header\">\n"
  ."</div>\n"
  ."</div>\n";
  
$bot = "</div>\n"
      ."</body>\n"
      ."<!-- Copyright 2009, protected under the Creative Commons Licence -->\n"
  ."</html>\n";

echo $top.$pagecontents.$bot;
}
?>

 

functions.php

<?php
/* Functions File
* Script by Alex Crooks
* Glider Content Script by Dynamic Drive
* Copyright 2009, protected under Creative Commons Licence
*/
Function retrieveContent()
{
$gc['output'] = "";

$sql = "SELECT * FROM ".TABLE_CONTENT;
if($exe = mysql_query($sql))
{
  while($row = mysql_fetch_array($exe))
  {
  $gc['output'] .= "<div class=\"contentdiv\">\n"
                  .stripslashes($row['body'])."\n"
			  ."</div>\n";
  }
}

return $content;
}
Function retrieveMessages()
{
$sql = "SELECT * FROM ".TABLE_CONTENT;
$msg = "";
if($exe = mysql_query($sql))
{
  while($row = mysql_fetch_array($exe))
  {
  $msg .= stripslashes($row['body'])."<br />\n";
  }
}
$messages = $msg;

return $messages;
}
Function retrieveBlocks()
{
$block = "blah";

return $block;
}
Function retrieveTime()
{
$dt = "<script type=\"text/javascript\">\n"
     ."var dayarray=new Array(\"Sunday\",\"Monday\",\"Tuesday\",\"Wednesday\",\"Thursday\",\"Friday\",\"Saturday\")\n"
     ."var montharray=new Array(\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\")\n"
     ."function getthedate(){\n"
     ."var mydate=new Date()\n"
     ."var year=mydate.getYear()\n"
     ."if (year < 1000)\n"
     ."year+=1900\n"
     ."var day=mydate.getDay()\n"
     ."var month=mydate.getMonth()\n"
     ."var daym=mydate.getDate()\n"
     ."if (daym<10)\n"
     ."daym=\"0\"+daym\n"
     ."var hours=mydate.getHours()\n"
     ."var minutes=mydate.getMinutes()\n"
     ."var seconds=mydate.getSeconds()\n"
     ."var dn=\"AM\"\n"
     ."if (hours>=12)\n"
     ."dn=\"PM\"\n"
     ."if (hours>12){\n"
     ."hours=hours-12\n"
     ."}\n"
     ."if (hours==0)\n"
     ."hours=12\n"
     ."if (minutes<=9)\n"
     ."minutes=\"0\"+minutes\n"
     ."if (seconds<=9)\n"
     ."seconds=\"0\"+seconds\n"
     ."//change font size here\n"
     ."var cdate=\"<b>\"+dayarray[day]+\", \"+montharray[month]+\" \"+daym+\", \"+year+\" \"+hours+\":\"+minutes+\":\"+seconds+\" \"+dn\n"
     ."+\"</b>\"\n"
     ."if (document.all)\n"
     ."document.all.clock.innerHTML=cdate\n"
     ."else if (document.getElementById)\n"
     ."document.getElementById(\"clock\").innerHTML=cdate\n"
     ."else\n"
     ."document.write(cdate)\n"
     ."}\n"
     ."if (!document.all&&!document.getElementById)\n"
     ."getthedate()\n"
     ."function goforit(){\n"
     ."if (document.all||document.getElementById)\n"
     ."setInterval(\"getthedate()\",1000)\n"
     ."}\n"
     ."</script>\n"
     ."<span id=\"clock\" style=\"font-size: 10pt;\"></span>\n";

return $dt;
}
?>

 

Those are really the only files, except for the Javascript file and the admin file (which works completely fine).

 

But yeah.. I can't figure out why this wont display anything...

1. Are the constants like TABLE_SETTINGS defined?

2. $content is undefined.

Function retrieveContent()
{
$gc['output'] = "";

$sql = "SELECT * FROM ".TABLE_CONTENT;
if($exe = mysql_query($sql))
{
  while($row = mysql_fetch_array($exe))
  {
  $gc['output'] .= "<div class=\"contentdiv\">\n"
                  .stripslashes($row['body'])."\n"
  ."</div>\n";
  }
}

return $content;
}

 

3. You don't need to include config.php in layout.php; it's already included in view.php before you included layout.php.

if($functionset == "display")
{
include("config.php");

 

Well that's my code review.

1. Those are defined in the config.php file:

 

$mysql['dbprefix'] = "rdbd";
...
// Define table names
define("TABLE_CONTENT", $mysql['dbprefix']."_content");
define("TABLE_MESSAGES", $mysql['dbprefix']."_messages");
define("TABLE_SETTINGS", $mysql['dbprefix']."_settings");

 

2. Fixed

3. Fixed

 

And...

 

It works! Thank you, yet again!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • 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.