8 Hours and I give up. :bemused:
I have a free-standing file that works and this is it. If I load it up in the server it works fine and adds a new entry to the database just as planned.
<html>
<head><title>Store email into database</title></head>
<body>
<?php
if(isset($_POST['submit'])) {
// connect to the database
$username="myname";
$password="mypassword";
$database="findabon_contacts";
mysql_connect("localhost","$username","$password");
@mysql_select_db($database) or die( "Unable to select database");
$query ="INSERT INTO news_email values('$email') ";
mysql_query($query);
MYSQL_CLOSE();
echo "email added!\n";
} else {
// else show the form to submit new data:
?>
<form method="post" action="test.php" id="form">
Email:<br>
<input type="text" name="email" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?
}
?>
</body>
</html>
</body>
</html>
It does the basics of putting an entry into the database, but when I take this and add it to my main page, (ie cut and paste into a paragraph amongst a bit of html) it just doesn't work.
I have looked at adding (") instead of ('),
I've looked at MYSQL_CLOSE instead of mysql_close,
Changed most of the spacing,
I've gone for a walk and then came back,
I've search high and low,
gone over tutorials again and again,
but I give up. :eek:
Please, any help would be appreciated.