Lately I have been working on a set of functions that will insert, display, delete, etc... things in my sites database.
Although I have ran into a problem of passing variables from a form to a function in an include file.
Currently the relevant part of the include file looks like this...
if($action == "insert_news")
{
insert_news("$news_poster", "$news_poster_email", "$news_date", "$news_title", "$news_body", "$news_source", "$news_source_url");
}
function insert_news($news_poster, $news_poster_email, $news_date, $news_title, $news_body, $news_source, $news_source_url)
{
global $dbcon, $db;
$query = "INSERT INTO news (news_poster, news_poster_email, news_date, news_title, news_body, news_source, news_url)
VALUES (\"$news_poster\",\"$news_poster_email\",\"$news_date\",\"$news_title\",\"$news_body\",\"$news_source\",\"$news_source_url\")";
$result = @($query,$dbcon) or die("Couldn't execute query");
header("Location: addnews.php");
}
relevant piece of the form is...
<form action="shared.inc.php?action=insert_news" method="post">
I have tried various things but I always get "Couldn't execute query" when trying to submit a new news article.