Odd Error
Posted: Fri Oct 20, 2006 1:43 pm
feyd | Please use
I would be very grateful if anyone can see anything obvious.
Thanks,
Robert
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am just starting on PHP and have encountered a very odd error (obviously I have encountered lots of errors, but this one is odd). I have a page I have built based around an online tutorial at http://www.kushan.org/php/form.php. It is a single page which displays a form and then posts the information to itself and displays the result. Now the weird thing is I added a section to append the data into a MySQL database. But nothing happens - the form continues to pass the data and redisplay it as before, but no error, and not data gets into the table. The input seems to work when seperated from the rest, so I am at a bit of a loss. Here is the code:Code: Select all
<?php
//Access the database
include("db.php");
//Variables passed from the post function
$name = $_POST["name"];
$message = $_POST["message"];
$topic = $_POST["topic"];
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
Name:<input type="text" size="20" maxlength="20" name="name"><br />
Subject:<input type="text" size="20" maxlength="20" name="topic"><br />
<textarea rows="5" cols="20" name="message" wrap="physical"></textarea><br />
<input type="submit" value="submit" name="submit">
</form>
<?
// if the page is submitted to itself
} else {
echo "You just posted this message<p><b>".$topic."</b><br>".$message."<br>".$name.".<br />";
[b]$sql = 'INSERT INTO `comment` (`postnumber`, `date`, `subject`, `message`,
`author`, `page`) VALUES (\'1\', \'2006-10-19\', $topic, $message,
$name, \'http://www.kushan.org/test.php\')'; [/b]
}
?>Thanks,
Robert
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]