I actually got this to work after I read a post about the record having to be UNIQUE. I now realize that UPDATE and INSERT are two differant commands and only work in certain situations. The record "title" is origianlly blank so only INSERT will work to add a record to the field "title". UPDATE will then update an existing record. If anyone has an idea or script on how we can check for a record and either UPDATE or INSERT according to the record status, PLEASE let me know.
Okay here's what I have so far:
dbtables.sql text file:
#
Table structure for Website Title
#
DROP TABLE IF EXISTS per_web;
CREATE TABLE per_web (
title varchar(50)
);
header:
<?
$title = $_POST[title];
$connection = mysql_connect("localhost","username","password")
or die ("Couldn't connect to server.");
$db = mysql_select_db("sbcompse_login", $connection) or die("Couldn't select database.");
$query = "SELECT title FROM per_web";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
$title = mysql_fetch_array($result);
?>
<html>
<title><? echo $title['title']; ?></title>
<body><br>
<table>
<tr><td>
form:
/**
Website Title
/
?>
<h3>Website Title </h3>
<FORM METHOD=POST ACTION="add.php3">
Enter the website title information to personalize this website. <br>
<input type="text" name="title">
<input type="submit" value="Website Title">
</form>
</td>
</tr>
add.php3 script:
<?
$DBhost = "localhost";
$DBuser = "username";
$DBpass = "password";
$DBName = "sbcompse_login";
$table = "per_web";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$sqlquery = $sql = "UPDATE per_web SET title = '$title'";
$results = mysql_query($sqlquery) or die(mysql_error());
mysql_close();
print "<HTML><TITLE> PHP and MySQL </TITLE><BODY
BGCOLOR=\"#FFFFFF\"><center><table border=\"0\"
width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blockquote>";
print "Website Title : $title<p></blockquote></td></tr></table>
</center></BODY></HTML>";
?>