Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Sql Adding New Articles
    text
    copied!<p>Need help with some PHP and MySQL I cant find were I went wrong.. </p> <p>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?</p> <p>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...</p> <pre><code>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=&gt;$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("\"","&amp;quot;",$_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'])&gt;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&lt;form action=\"admin.php?id=newarticle\" method=\"post\"&gt;\r\n"; $output.="\t\t\t&lt;p&gt;&lt;b&gt;".ucwords($lang['title'])."&lt;/b&gt;&lt;br /&gt;&lt;input class=\"inputtext\" type=\"text\" name=\"title\" /&gt;&lt;/p&gt;\r\n"; $output.="\t\t\t&lt;textarea id=\"text\" name=\"text\"&gt;&lt;/textarea&gt;\r\n"; $output.="\t\t\t&lt;p&gt;&lt;b&gt;".ucwords($lang['tags'])."&lt;/b&gt;&lt;br /&gt;".$lang['tag_seperate']."&lt;br /&gt;&lt;input type=\"text\" class=\"inputtext\" name=\"tags\" /&gt;&lt;/p&gt;\r\n"; $output.="\t\t\t&lt;p&gt;&lt;b&gt;".ucwords($lang['sticky'])."&lt;/b&gt;&lt;br /&gt;&lt;input type=\"radio\" name=\"sticky\" value=\"1\" checked=\"checked\" /&gt; ".ucwords($lang['no'])."&lt;br /&gt;&lt;input type=\"radio\" name=\"sticky\" value=\"2\" /&gt; ".ucwords($lang['yes'])."&lt;/p&gt;\r\n"; $output.="\t\t\t&lt;p&gt;&lt;b&gt;".ucwords($lang['comments'])."&lt;/b&gt;&lt;br /&gt;&lt;input type=\"radio\" name=\"comments\" value=\"0\" /&gt; ".ucwords($lang['no'])."&lt;br /&gt;&lt;input type=\"radio\" name=\"comments\" value=\"1\" checked=\"checked\" /&gt; ".ucwords($lang['yes'])."&lt;/p&gt;\r\n"; $output.="\t\t\t&lt;p&gt;&lt;input type=\"submit\" name=\"submit\" value=\"".ucwords($lang['save'])."\" /&gt;&lt;/p&gt;\r\n"; $output.="\t\t&lt;/form&gt;\r\n"; return $output; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload