Hey, just wondering if anyone would mind having a look at my code to tell me what i'm doing wrong.
What i'm trying to do is build a guestbook. I have:
'Guestbook.html' - The form for signing the guestbook
'Gsign.php' - the script that adds the entry to the database
'Gview.php' - the script that gets the data from the database and prints it on screen
The trouble i am having is the only thing that 'Gview.php' is displaying is '1'
Here is the code i am using:
----Gsign.php----
<?php
$dbhost = "localhost";
$dbname = "steven";
$dbpass = "scarred9";
$connection = @mysql_connect($dbhost, $dbname, $dbpass) or die("Error connecting");
$result1 = @mysql_select_db('mydatabase',$connection) or die("Error3");
$name = ($_POST['name']);
$message = ($_POST['message']);
$date_added = date("l dS of F Y h:i:s A");
$sql = "INSERT INTO gbook_data
(gbookname, gbookmessage, gbookdate)
VALUES
(\"$name\", \"$message\", \"$date_added\")
";
$result = mysql_query($sql, $connection) or die("Error4");
echo ("<p align='center'>Your message has been added successfully.<br>Click <a href='Gview.php'>here</a> to view the guestbook");
unset($connection);
unset($result);
unset($result1);
---Gview.php----
<?php
$db_name = "scarred_mydatabase";
$dbhost = "localhost";
$dbname = "steven";
$dbpass = "scarred9";
$connection = @mysql_connect($dbhost, $dbname, $dbpass) or die("Error connecting");
mysql_select_db($db_name, $connection) or die("Error selecting database");
$sql = "SELECT * FROM gbook_data ORDER BY gbookdate DESC LIMIT 0,50";
$result = @($sql, $connection) or die("Couldnt execute query");
while ($row=mysql_fetch_array($result)) {
$name = $row['gbookname'];
$message = $row['gbookmessage'];
$date_added = $row['gbookdate'];
$display_block = "<b>Name: </b>$name<br><b>Date Added: </b>$date_added<br><b>Message: </b>$message<hr>";
}
echo ("display_block") or die("Couldn't echo");
?>
As i say, all i get from 'Gview.php' is the number '1'. And i cant figure out why. Thanks in advance...
BIOSTALL