T
Testin da Cable
Guest
PHP/MySQL werdness
well, I've been looking at this test-script's code for ages so I expect it's right before my eyes...but I just don't see it.
the problem: the insert into the database doesn't happen. why? I dunno the select query works, the insert doesn't.
I want to put data from a variable with the name newnews into the database if the form's 'submit' button gets clicked, changing it's value to SUBMIT. it no workie. help0r please!
well, I've been looking at this test-script's code for ages so I expect it's right before my eyes...but I just don't see it.
the problem: the insert into the database doesn't happen. why? I dunno the select query works, the insert doesn't.
I want to put data from a variable with the name newnews into the database if the form's 'submit' button gets clicked, changing it's value to SUBMIT. it no workie. help0r please!
Code:
<?
include ("dbc.php");
// news has been submitted
if ($submit == "SUBMIT") {
dbConnect("www");
$sql = "INSERT INTO news SET
data = '$newnews'";
if (mysql_query($sql)) {
echo("
The news has been added to the database!</p>");
} else {
echo ("
Error adding news!!</P>");
}
mysql_close();
}
?>
<html>
here are the current newsitems:
<? // get current news
dbConnect("www");
$query = ("SELECT * FROM news");
$result = mysql_query($query);
if ($result) {
while ($r = mysql_fetch_array($result)) {
$user = $r["user"];
$data = $r["data"];
$date = $r["date"];
echo "$user, $data, $date
";
}
mysql_close();
}
?>
add an item to the database?
<form action="<?=$PHP_SELF?>" method="POST">
<textarea wrap name="newnews" rows=15 cols=70></textarea>
<hr noshade color=orange>
<input type="submit" value="SUBMIT">
</form>
</p>
</html>