PDA

View Full Version : Light a candle script



Magiccupcake
13 Aug 2007, 02:30 PM
I am trying to find a script that I can use in a memorial site that I am building where people can light a candle in memory of a loved one. I have found this script http://www.multimedia.com.ro/downloads/society-php_scripts.html which looks like it should work well. But I always get the error "Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\Inetpub\vhosts\...\candle\inmemoriam\Index.php on line 52

This is line 52

$DatabaseRow = MySQL_fetch_object($DatabaseResult);

What do I need to change?

Or does anyone know of a better script that I can use. I am hoping for something with php.






<?php

// Obtain The GMT Time
$timestamp = gmdate("U");

// Build Datetime Strings
$Expires = sprintf("%s %02d %s %04d %02d:%02d:%02d GMT",
gmdate("D", $timestamp), gmdate("d", $timestamp),
gmdate("M", $timestamp), gmdate("Y", $timestamp),
gmdate("H", $timestamp), gmdate("i", $timestamp),
gmdate("s", $timestamp));

$LastModified = sprintf("%s %02d %s %04d %02d:%02d:%02d GMT",
gmdate("D"), gmdate("d"), gmdate("M"), gmdate("Y"),
gmdate("H"), gmdate("i"), gmdate("s"));

// Send Headers That Should Foil Proxy Servers
header("Expires: $Expires");
header("Last-modified: $LastModified");
header("Cache-Control: no-cache");

define("DATABASE_HOST", "localhost"); // localhost will usually suffice
define("DATABASE_USER", "a"); //Your DB Info
define("DATABASE_PASSWORD", "b"); //Your DB Info
define("DATABASE_NAME", "c"); //Your DB Info

//Establish Persistent Connection
$DatabaseLink = MySQL_pconnect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD) or die (MySQL_error());

//Select DB
MySQL_select_db(DATABASE_NAME) or die(MySQL_error());
$nume = $_POST['nume'];
?>
<?

$nume = htmlentities($nume);
if($nume != "")
{
$Query3 = "SELECT ID FROM candle WHERE Name=\"$nume\"";
$DatabaseResult3 = MySQL_query($Query3, $DatabaseLink);
if(!($DatabaseRow = MySQL_num_rows($DatabaseResult3)))
{

mysql_query("INSERT INTO candle(Name) VALUES(\"$nume\") ") or die(mysql_error());
}
}

?>
<?
$Query = "SELECT max(ID) AS Count FROM candle";
$DatabaseResult = MySQL_query($Query, $DatabaseLink);
$DatabaseRow = MySQL_fetch_object($DatabaseResult);
if ($DatabaseRow->Count>0) $TotalCount = $DatabaseRow->Count;
else $TotalCount=0;
?>

<html>
<head>
<title>In Memoriam - Light a candle!</title>
<meta name="description" content="The electronic memorials and virtual online cemetery">
<meta name="keywords" content="in memoriam, light a candle, electronic memorials, virtual online cemetery">
<meta name="language" content="en-us">
<meta name="robots" content="ALL">
<meta name="rating" content="SAFE FOR KIDS">
<meta name="distribution" content="GLOBAL">
<meta name="classification" content="Society">
<meta name="copyright" content="This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License.">
<meta name="author" content="Nicolae Sfetcu">
<meta name="revisit-after" content="1 Day">
<meta http-equiv="reply-to" content="nicolae@sfetcu.com">
</head>
<body bgcolor="#000000" class="text" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF">
<center>
</center>
<form method="post" action="index.php?step=2&Count=<? $submitCount = $TotalCount + 50; print($submitCount); ?>" >
<b>In Remembrance of:</b> Person's Name, Country, Message: <input type="text" name="nume"> &nbsp<input type="submit" name="submit" value="Light an Inspirational Candle">
</form>
</td>
</tr></table>
&nbsp; - Please keep comments short, rational, and peaceful.<br>
&nbsp; - 255 Characters max. and No HTML tags<br>
&nbsp; - Only allow for 1 Inspirational Candle per session.<br>
&nbsp; - Don't forget to click on the Light an Inspirational Candle button to light it.<br>
&nbsp; - An inspirational sound is located at the bottom of the page for you to listen to in remembrance.<br><br>
<b>Candles of Inspiration:&nbsp;

<?
print($TotalCount);
if(!isset($preCount))
{
$preCount = $TotalCount - 100;
}
if(!isset($Count))
{
$Count = $TotalCount + 10;
}

?>
</b><br>
<?
if($submit == "Search" || $yes == "yes")
{
print(" <br>");
print("Search Result: <br><br>");
$Query = "SELECT ID, Name FROM candle WHERE Name LIKE \"%$search%\" ORDER BY ID DESC";
$DatabaseResult = MySQL_query($Query, $DatabaseLink);
while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
{
$id = $DatabaseRow->ID + 5;
print("<a href=\"index.php?Count=$id\">$DatabaseRow->Name</a><br>");
}

if(MySQL_num_rows($DatabaseResult) == 0)
{
print("None found.<br><br>");
print("<a href=\"index.php?Count=$TotalCount\"> Return to Candle Main Page</a><br>");
}
}else
{

?>

<table cellspacing="16"><tr align="center">
<?

if($Count > 100)
{
$preCount = $Count - 100;
}
$interval = 0;
//$Query = "SELECT ID, Name FROM candle ORDER BY ID ASC";

$Query = "SELECT ID, Name FROM candle WHERE ID > \"$preCount\" AND ID < \"$Count\" ORDER BY ID DESC";
$DatabaseResult = MySQL_query($Query, $DatabaseLink);
while($DatabaseRow = MySQL_fetch_object($DatabaseResult))
{
$nume = $DatabaseRow->Name;
print("<td><img src=\"images/candle.gif\" width=\"70\" height=\"79\"><br>$nume</td>");
$interval++;
if($interval == 4)
{
print("</tr><tr>");
$interval = 0;
}
}
?>
<br>
<br>
<br>
<center><table border="0" cellpadding="0" cellspacing="0">
<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img border="0" src="images/top.gif" alt="">
<br><a href="#top"> Top of Page</a></tr></td></table>
<center><table border="0" cellpadding="0" cellspacing="0">
<tr><td><BGSOUND id="BGSOUND_ID" LOOP=1 SRC="../../In_Memoriam-PHP/inmemoriam/jsilence.mid">
<EMBED NAME="inspire" SRC="../../In_Memoriam-PHP/inmemoriam/modules/Inspire/sound/inspire.mid"
LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>
<script language="JavaScript">
<!--
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!="Netscape")?1:0
ns4=(ver>3 && navigator.appName=="Netscape")?1:0
ns3=(ver==3 && navigator.appName=="Netscape")?1:0

function playSound() {
if (ie4) document.all['BGSOUND_ID'].src='sound/inspire.mid';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes['audio/x-midi']
&& self.document.Inspire.IsReady()
)
{
self.document.Inspire.play()
}
}

function stopSound() {
if (ie4) document.all['BGSOUND_ID'].src='jsilence.mid';
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes['audio/x-midi']
)
{
self.document.Inspire.stop()
}
}
//-->
</script>

<form name=myform>
<input type=button value="Play Sound" onClick="playSound()">
<input type=button value="Stop Sound" onClick="stopSound()">
</form></center></tr></td></table>
<?
}
?>
</td>
</tr>
</table>
</center>
</div>

<script LANGUAGE="JavaScript">
<!--
function WindowOpen1()
{
window.open('copyright.php', 'Window1', 'resizable,height=420,width=400');
}
//-->
</script>
<table border="0" width="100%" id="table1">
<tr>
<td align="center">Adapted by <a href="http://www.sfetcu.com">Nicolae
Sfetcu</a></td>
<td align="center"><a href="http://www.multimedia.com.ro/downloads">Free
scripts, content &amp; e-books</a></td>
<td align="center"><a HREF="#" ONCLICK="WindowOpen1();return false">Original PHP-Nuke script</a></td>
</tr>
</table>


</body>
</html>