First,
I never figured out what I did wrong the other day with my simple web application: the simple guest book. I removed the form where users add guest book entries. I'm using myPhpAdmin to add new rows to the table for testing purposes. Once I figure out what's going on then I will continue with the form.
my guestbook's address: http://tearsfall.pcriot.com/guestbook.php
First, my guest book's table structure and each attributes defining feautres:
guestbook (guestID,guest_name,guest_message)
guestID: int(4), not null, auto increment, primary key
guest_name: varchar(19), not null
guest_message: varchar(255), not null
Second, my database_connection.php (so that you will understand that I'm trying to make my site with OOP).
guestbook.php
OKay, my guestbook.php is bringing up all the rows following the first row. I don't know why the first row is not being included on my guestbook.php. I will show you the code that I know is in question with my database_connection.php and my guestbook.php files, respectively.
database_connection.php: these lines appear to be okay, but maybe someone with more PHP experience can point something out to me
guestbook.php
That's all that I have pressing on my mind. Every bit of help I receive will be great.
TearsFall
I never figured out what I did wrong the other day with my simple web application: the simple guest book. I removed the form where users add guest book entries. I'm using myPhpAdmin to add new rows to the table for testing purposes. Once I figure out what's going on then I will continue with the form.
my guestbook's address: http://tearsfall.pcriot.com/guestbook.php
First, my guest book's table structure and each attributes defining feautres:
guestbook (guestID,guest_name,guest_message)
guestID: int(4), not null, auto increment, primary key
guest_name: varchar(19), not null
guest_message: varchar(255), not null
Second, my database_connection.php (so that you will understand that I'm trying to make my site with OOP).
Code:
<?php
class DatabaseConnection {
private $connection_resource;
private $hostname;
private $username;
private $password;
private $database_name;
function __construct($hostname,$username,$password,$database_name) {
$this->hostname = $hostname;
$this->username = $username;
$this->password = $password;
$this->database_name = $database_name;
}
public function connect() {
$this->connection_resource = mysql_connect($this->hostname,
$this->username,
$this->password);
$this->connection_resource += mysql_select_db($this->database_name);
}
public function disconnect() {
mysql_close($this->connection_resource);
}
}
?>
guestbook.php
Code:
<?php
require "database_connection.php";
$myconnection = new DatabaseConnection('localhost','tearsfal_admin','*********','tearsfal_forums');
$myconnection->connect();
$result = mysql_query("SELECT * FROM guestbook") or die(mysql_error());
if(mysql_fetch_array($result) < 1) {
echo "No entries.";
}
else {
while($row = mysql_fetch_array($result)) {
echo $row['guestID'] . " " . $row['guest_name'] . "<br />" . $row['guest_message'] . "<br /><br />";
}
}
?>
OKay, my guestbook.php is bringing up all the rows following the first row. I don't know why the first row is not being included on my guestbook.php. I will show you the code that I know is in question with my database_connection.php and my guestbook.php files, respectively.
database_connection.php: these lines appear to be okay, but maybe someone with more PHP experience can point something out to me
Code:
public function connect() {
$this->connection_resource = mysql_connect($this->hostname,
$this->username,
$this->password);
$this->connection_resource += mysql_select_db($this->database_name);
}
guestbook.php
Code:
if(mysql_fetch_array($result) < 1) {
echo "No entries.";
}
else {
while($row = mysql_fetch_array($result)) {
echo $row['guestID'] . " " . $row['guest_name'] . "<br />" . $row['guest_message'] . "<br /><br />";
}
That's all that I have pressing on my mind. Every bit of help I receive will be great.
TearsFall