I was writing some PHP files earlier and everything was working fine. I closed out my browser windows and Notepad++ and walked away from the computer for a while. Now, whenever I open a .php file in FF, it treats it like a .htm file, dumping some of the PHP code to the screen. Also, if I "View Source" in the browser, it shows all of the PHP code.
I was Googling around but the only solution that I found was to add a line to the httpd.conf file, but that didn't seem right. After all, the code was working fine earlier without any changes to the .conf file. Also, it appeared that that was a solution to get .htm files to be parsed with the PHP interpreter instead of giving them the .php extension.
Thinking something with XAMPP or Apache just bailed, I rebooted the server but that didn't help at all. Also, looking in the XAMPP Admin window it shows PHP as being activated.
I can't figure out why, but the PHP interpreter just doesn't seem to want to work. Here's the code from the file:
- Code: Select all
<?php
mysql_connect('*********', '****', '******');
mysql_select_db('char_page');
function build_character_array() {
$char_array = "var characterArray = new Array();";
$nbr_of_chars = get_table_data('COUNT(char_nbr)', 'characters', false);
for ($i = 0; $i < $nbr_of_chars; $i++) {
$char_array .= "\ncharacterArray[" . $i . "] = new character(";
$char_array .= '"' . get_table_data('name', 'characters', 'char_nbr = "' . $i . '"') . "\", ";
$char_array .= '"' . get_table_data('clan', 'characters', 'char_nbr = "' . $i . '"') . "\", ";
$char_array .= get_table_data('city_stat', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('anar_stat', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('cama_stat', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('sabb_stat', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= '"' . get_table_data('office', 'characters', 'char_nbr = "' . $i . '"') . "\", ";
$char_array .= get_table_data('npc', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('founder', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('triumvir', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('council', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= get_table_data('mgd', 'characters', 'char_nbr = "' . $i . '"') . ", ";
$char_array .= '"' . get_table_data('pic', 'characters', 'char_nbr = "' . $i . '"') . "\", ";
$char_array .= '"' . get_table_data('bio', 'characters', 'char_nbr = "' . $i . '"') . "\");";
}
return $char_array;
}
function get_table_data($field, $table, $where) {
$statement = "SELECT " . $field . " FROM " . $table;
if ($where)
$statement .= " WHERE " . $where;
$statement .= ";";
$query = mysql_query($statement) or die("<b>A fatal MySQL error has occured while processing Query:</b>\n" . $statement . "<br />\nError: (" . mysql_errno() . ") " . mysql_error());;
$row = mysql_fetch_array($query);
return $row[$field];
}
?>
<html>
<head>
<meta="author" content="Richard W. Quaid">
<meta="description" content="This page displays characters from the KC Sunshine LARP including bios and other stats.">
<title>KC Sunshine LARP Characters Page</title>
<link rel="stylesheet" href="kc.css" type="text/css" />
<style type="text/css">
.noBox {
border: 0;
background-color: transparent;
}
</style>
<script type="text/javascript" language="javascript">
function character(name, clan, cityStatus, anarchStatus, camarillaStatus, sabbatStatus, office, npc, founder, triumvirate, council, mgd, pic, bio) {
this.name = name;
this.clan = clan;
this.cityStatus = cityStatus;
this.anarchStatus = anarchStatus;
this.camarillaStatus = camarillaStatus;
this.sabbatStatus = sabbatStatus;
this.office = office;
this.npc = npc;
this.founder = founder;
this.triumvirate = triumvirate;
this.council = council;
this.mgd = mgd;
this.pic = pic;
this.bio = bio;
}
<?php echo build_character_array() ?>
function displayCharacters() {
var newHTML = "";
for (var i = 0; i < characterArray.length; i++) {
newHTML += "<div height=\"180\">";
if (i == 0 || i % 2 == 0) {
newHTML += "<img src=\"graphics/charPics/" + characterArray[i].pic + "\" style=\"float: left; padding-right: 15px;\" height=\"180\" width=\"142\" />\n";
newHTML += "<img src=\"graphics/" + characterArray[i].clan + ".gif\" style=\"float: right;\" />\n";
}
else {
newHTML += "<img src=\"graphics/charPics/" + characterArray[i].pic + "\" style=\"float: right; padding-right: 15px;\" height=\"180\" width=\"142\" />\n";
newHTML += "<img src=\"graphics/" + characterArray[i].clan + ".gif\" style=\"float: left;\" />\n";
}
newHTML += "<h2>" + characterArray[i].name + "</h2>\n";
// newHTML += "<h3>" + characterArray[i].sect.substr(0,1).toUpperCase() + characterArray[i].sect.substr(1);
if (characterArray[i].office != "")
newHTML += " " + characterArray[i].office;
newHTML += ", City Status: " + characterArray[i].cityStatus + "</h3>\n";
newHTML += "<p>" + characterArray[i].bio + "</p>\n";
newHTML += "<p align=\"center\">";
if (characterArray[i].npc)
newHTML += "<b>NPC</b>";
else
newHTML += "<span style=\"text-decoration: line-through;\">NPC</span>";
newHTML += " ";
if (characterArray[i].founder)
newHTML += "<b>FPC</b>";
else
newHTML += "<span style=\"text-decoration: line-through;\">FPC</span>";
newHTML += " ";
if (characterArray[i].triumvirate)
newHTML += "<b>Triumvirate</b>";
else
newHTML += "<span style=\"text-decoration: line-through;\">Triumvirate</span>";
newHTML += " ";
if (characterArray[i].council)
newHTML += "<b>Council</b>";
else
newHTML += "<span style=\"text-decoration: line-through;\">Council</span>";
newHTML += " ";
if (characterArray[i].mgd)
newHTML += "<b>MGD</b>";
else
newHTML += "<span style=\"text-decoration: line-through;\">MGD</span>";
newHTML += "</div><br />";
}
document.getElementById('characterDisplay').innerHTML = newHTML;
}
</script>
</head>
<body background="graphics/body.jpg" style="background-attachment: fixed;" onload="displayCharacters()">
<div class="banner"><img src="graphics/CBanner.jpg" class="centered"></div>
<br />
<div id="characterDisplay" class="noBox"> </div>
<br />
<div id="adminTools"><a href="char_reset.php">Reset Characters Database</a></div>
</body>
</html>
This...
"A fatal MySQL error has occured while processing Query:\n" . $statement . "
\nError: (" . mysql_errno() . ") " . mysql_error());; $row = mysql_fetch_array($query); return $row[$field]; } ?>"
...is what shows up at the top of the page when it's loaded.
Thanks in advance to anyone who can shed some light on this.
-Quaid