Need help with some PHP and MySQL I cant find were I went wrong..
Trying to add new blog article using a function call. I know all other code is correct because if I manually add entry into database sql it shows on blog. When adding a new entry to database sql it never adds into the database.. Any one notice anything wrong?
I have functions for time and date of post and they all work. If I can figure out this part I can fix the tags too. If any one would like to see in a txt file just let me know its hard to post straight code to here...
function eb_admin_newarticle()
{
global $lang;
$output="\t\t".ucwords($lang['new_article'])."\r\n";;
//To add new article post
if(!empty($_POST['text']))
{
foreach($_POST as $key=>$value)
$_POST[$key]=str_replace("Acirc;","",$value);
$sql="INSERT INTO eb_articles SET article_flag=".$_POST['sticky'].",article_date=\"".time()."\",author_id=\"".$_SESSION['user_id-'.$_SERVER['SERVER_NAME']]."\", article_title=\"".str_replace("\"",""",$_POST['title'])."\",article_body=\"".$_POST['text']."\",article_comments=".$_POST['comments'];
mysql_query($sql);
$article_id=mysql_insert_id();
//input tags on article
if(strlen($_POST['tags'])>1) {
$tags=explode(",",$_POST['tags']);
foreach($tags as $tag) {
$sql="INSERT INTO eb_tags SET tag_name=\"".$tag."\"";
mysql_query($sql);
if(mysql_affected_rows()==1)
$tag_ids[]=mysql_insert_id();
else
$tag_ids[]=mysql_result(mysql_query("SELECT tag_id FROM eb_tags WHERE tag_name=\"".$tag."\""),0);
}
foreach($tag_ids as $tag_id)
mysql_query("INSERT INTO eb_tags_links SET tag_id=".$tag_id.",article_id=".$article_id);
}
header('Location: news.php?id='.$article_id);
}
else {
$output.="\t\t<form action=\"admin.php?id=newarticle\" method=\"post\">\r\n";
$output.="\t\t\t<p><b>".ucwords($lang['title'])."</b><br /><input class=\"inputtext\" type=\"text\" name=\"title\" /></p>\r\n";
$output.="\t\t\t<textarea id=\"text\" name=\"text\"></textarea>\r\n";
$output.="\t\t\t<p><b>".ucwords($lang['tags'])."</b><br />".$lang['tag_seperate']."<br /><input type=\"text\" class=\"inputtext\" name=\"tags\" /></p>\r\n";
$output.="\t\t\t<p><b>".ucwords($lang['sticky'])."</b><br /><input type=\"radio\" name=\"sticky\" value=\"1\" checked=\"checked\" /> ".ucwords($lang['no'])."<br /><input type=\"radio\" name=\"sticky\" value=\"2\" /> ".ucwords($lang['yes'])."</p>\r\n";
$output.="\t\t\t<p><b>".ucwords($lang['comments'])."</b><br /><input type=\"radio\" name=\"comments\" value=\"0\" /> ".ucwords($lang['no'])."<br /><input type=\"radio\" name=\"comments\" value=\"1\" checked=\"checked\" /> ".ucwords($lang['yes'])."</p>\r\n";
$output.="\t\t\t<p><input type=\"submit\" name=\"submit\" value=\"".ucwords($lang['save'])."\" /></p>\r\n";
$output.="\t\t</form>\r\n";
return $output;
}
}