News system bug

Hey guys im having a problem with my news system, it cant connect too the mySQL database, heres the code:
[php]

Add

Add News

Posted By:


Type your Username in the 'Posted by' box


Subject:


Next type what your news article is about; e.g:Updates' in the 'subject' box


News/Article:


Next type the main body of the text into the 'news/article' area, then just press 'Enter news' and you are done!


<?php function clear($message) { if(!get_magic_quotes_gpc()) $message = addslashes($message); $message = strip_tags($message); $message = htmlentities($message); return trim($message); } if ($_POST['submit']) { if (empty($_POST['postedby'])) die('Enter a name.'); else if (empty($_POST['subject'])) die('Enter a subject.'); else if (empty($_POST['news'])) die('Enter an article.'); $postedby = clear($_POST['postedby']); $subject = clear($_POST['subject']); $news = clear($_POST['news']); $date = mktime(); mysql_connect('localhost','rsserver_ISAI','Log1stics'); mysql_select_db('rsserver_news'); if(mysql_query("INSERT INTO news (id , postedby , news , subject , date) VALUES ('', '$postedby', '$news', '$subject', '$date')")) echo 'News Entered.'; mysql_close(); } ?> [/php]

Anyone going to help?

What make you think you cannot connect to a database? What error message you get (if any)?

For debugging purpose, try to add this:
[php]echo mysql_error();[/php]

after the line where you connect to MySQL database.

Sponsor our Newsletter | Privacy Policy | Terms of Service