READ Movie Clip;
function loadEntries(act, increment) {
// Define NumLow as a Number
num = new Number(NumLow);
// Act accordingly
if(act == "Next") {
// Add increment
NumLow = num + increment;
} else if(act == "Previous") {
NumLow = num - increment;
} else {
// Load default - i.e. 0
NumLow = 0;
}
// Update Statistics
NumLow = NumLow;
NumHigh = Number(NumLow) + 20;
// Show Please wait text
entries = "Loading entries... Please wait...";
// Begin Loading
myEntries = new LoadVars()
myEntries.ref = this
myEntries.load("GuestBook.php?action=read&r="+random(999)+"&NumLow="+NumLow)
myEntries.onLoad = function(success){
if(success){
// Assign output to components and objects
entries = this.entries;
totalEntries = this.totalEntries;
loadEntries("Default", 20);
stop();
}
}
}Where the entries/info is to appear its VAR = entries
Where the totalEntries are to appear its VAR - totalEntries
Now here is the php code;
// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
$DBhost = "server"; // Database Server
$DBuser = "user name"; // Database User
$DBpass = "(******)"; // Database Pass
$DBName = "my dbname"; // Database Name
$table = "table name"; // Database Table
$numComments = 20; // Number of Comments per page
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
// Part Two - Choose what action to perform
$action = $_GET['action'];
switch($action) {
case 'read' :
// Fetch all comments from database table
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
// Generate Output for Flash to Read
print '&totalEntries=' . $numallComments . '&';
print "<br>&entries=";
if($numallComments == 0) {
print "No entries in the guestbook, as yet..";
} else {
while ($array = mysql_fetch_array($fewComments)) {
$name = mysql_result($fewComments, $i, 'name');
$email = mysql_result($fewComments, $i, 'email');
$website = mysql_result($fewComments, $i, 'website');
$state = mysql_result($fewComments, $i, 'state');
$comments = mysql_result($fewComments, $i, 'comments');
$time = mysql_result($fewComments, $i, 'time');
print '<b>Name: </b>' . $name . '<br><b>Email: </b>' . $email . '<br><b>Website: </b>' . $website . '<br><b>State: </b>' . $state . '<br><b>Comments: </b>' . $comments . '<br><i>Date: ' . $time . '</i><br><br>';
$i++;
}
}
// Print this only when there aren't any more entries..
if($_GET['NumLow'] > $numallComments) {
print 'No More Entries!&';
}
break;
case 'write' :
// Recieve Variables From Flash
$name = ereg_replace("&", "%26", $_POST['yourname']);
$email = ereg_replace("&", "%26", $_POST['youremail']);
$website = ereg_replace("&", "%26", $_POST['yourwebsite']);
$state = ereg_replace("&", "%26", $_POST['yourstate']);
$comments = ereg_replace("&", "%26", $_POST['yourcomments']);
$submit = $_POST['submit'];
// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());
// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
' (`ID`,
`name`,
`email`,
`website`,
`state`,
`comments`,
`time`
)
VALUES
(\'\','
. '\'' . $name . '\','
. '\'' . $email . '\','
. '\'' . $website . '\','
. '\'' . $state . '\','
. '\'' . $comments . '\','
. '\'' . $submitted_on . '\'
)';
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());
// If you want your script to send email to both you and the guest, uncomment the following lines of code
// Email Script Begin
/* <-- Remove this line
$MyName = "Name";
$MyEmail = "Email";
$Subject = "$name has just signed your guestbook.";
$EmailBody = "Hello "",\n$name has just signed your guestbook available at http://your domian. THe following were the details submitted into your guestbook:\n\nName: $name\nEmail: $email\nComment:\n$comments\n";
$EmailFooter = "~~~~~~~~~~~~~~~\nThe guestbook was signed by $name and thus this email got activated by $name from $REMOTE_ADDR from http://your domain\n~~~~~~~~~~~~~~~\nThanking you,\n"";
$Message = $EmailBody.$EmailFooter;
mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
--> Remove this line */
// Email Script End
print "&error= &done=yes&";
return;
}
print "&error=Error!&";
break;
}
?>Only problem I am having is getting the entries and totalEntries to post. If someone could look over this and let me know what possibly could be wrong. Have tried all kinds of different things and no worky.
Thanks Kevin

Help














