Forum Moderators: coopster
$username="username";
$password="password";
$database="database";
$date = $_POST['date'];
$news = $_POST['news']
$html = "<p><blockquote>$date-</blockquote><br>$news</p>";
$posting = $_POST['$html'];mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database.");$query = "INSERT INTO news VALUES ('','$posting')";
mysql_query($query);mysql_close();
Thanks,
electricocean
$date = $_POST['date'];
$news = $_POST['news']
$html = "<p><blockquote>$date-</blockquote><br>$news</p>";
$posting = $_POST['$html'];
If you are just trying to put information into the database try this:
$date = $_POST['date'];
$news = $_POST['news'];
$posting = "<p><blockquote>$date-</blockquote><br>$news</p>";
You could probably improve your query to make it more readable by specifying what data goes where:
$query = "INSERT INTO news (field1, field2) VALUES ('','$posting')";
Is there any reason you've specified blank data to go into the first field? If it's always going to be blank you can tell MySQL to give it a default value, that way you don't have to explicitly set it each time.
$date = $_POST['date'];
$news = $_POST['news']
$html = "<p><blockquote>$date-</blockquote><br>$news</p>";
$posting = $_POST['$html'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die(mysql_error());
$query = ("INSERT INTO news (Cloumn1, Column2) VALUES ('','$posting')");
mysql_close();
I assume that another form is creating the POST data (date, news, html) and that $posting is the only variable on this "processing" page.
Column1 and Column2 are the column names of your "news" table, but for Column2 make sure that its type is something like VARCHAR(100) or something.
--Nick
$news = $_POST['news']
This part is missing the terminating ;
$posting = $_POST['$html'];
This is not a valid way of calling an array key and will give syntax errors, plus your $html variable contains data that isn't really of an 'array key type'.
For your database you should have 2 fields. One should be your unique primary key (integers are best) and the other should be your html content. A better way to do it would be to store it in 3 fields (primary key, date and news), that way later on down the track you can enact on data by date (deleting old records etc).
$posting = mysql_real_escape_string($html);
$query = "INSERT INTO news (news) VALUES ('" . mysql_real_escape_string($posting) . "')";