Driving me crazy.

Hello I am blind or something i am having the hardest time getting my form to post data to my DB. Its very simple form. only 3 fields. My coding is very poor so any help with getting this to work and on clean up would be nice.
[hr]
My form
[hr]
[php]

<?php require_once("config.php"); include("header2.php"); echo <<<HTML

Post News to Home Page

Date:
Title:
Article:
HTML; ?>

[/php]
[hr]
My Form process
[hr]
[php]

<? require_once('config.php'); $date=$_POST['date']; $title=$_POST['news_title']; $article=$_POST['news_post']; mysql_select_db($dbname,$dbc) or die(mysql_error()); mysql_query("INSERT INTO news (date,title,article) VALUES ($date,$title,$article)"); echo <<<HTML

 

Date:
$date
Article Title:
$title
Main Article:
$article
HTML; ?>

[/php]
[hr]
My Config file

[hr]
[php]<?php

##database settings######
$dbhost = ‘localhost’;
$dbuser = ‘’;
$dbpass = '
’;
$dbname = ‘daycare2’;
#########################
#########################
####Datebase Connection##
#########################
$dbc=mysql_connect($dbhost,$dbuser,$dbpass);

?>
[/php]

You’re gonna kick yourself, but it looks like a simple error.

Change From:

[php]
mysql_query(“INSERT INTO news (date,title,article) VALUES ($date,$title,$article)”);
[/php]

To:

[php]
mysql_query(“INSERT INTO news (date,title,article) VALUES (’$date’,’$title’,’$article’)”);
[/php]

Well, that should do it!

Robert

Sponsor our Newsletter | Privacy Policy | Terms of Service