Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Misunderestimated PHP

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Misunderestimated PHP

Postby NewCode31 » Wed Jan 01, 2014 11:06 am

Hello all I am trying to get a comments area for my website. I am using Bluehost. I have my php.ini file within my public_html directory. I can not connect to my database to load the data collected by my php script? Here is my code:

Code: Select all
<?
if( $_POST )
{
  $dbh = mysql_connect("localhost","user_Name", "password");

  if (!$dbh)
  {
    die('Could not connect: ' . mysql_error());
  }

  mysql_select_db("newcodet_Comments", $dbh);

  $users_name = $_POST['name'];
  $users_email = $_POST['email'];
  $users_comment = $_POST['comment'];

  $users_name = mysql_real_escape_string($users_name);
  $users_email = mysql_real_escape_string($users_email);
  $users_comment = mysql_real_escape_string($users_comment);

  $articleid = $_GET['id'];
  if( ! is_numeric($articleid) )
    die('invalid article id');

  $query = "INSERT INTO `newcodet_Comments`.`Comments` (`ID`, `name:`, `email`, `Comment`, `timestamp`, `articleid`) VALUES (NULL, '$users_name', '$users_email', '$users_comment', CURRENT_TIMESTAMP, '1');";

  mysql_query($query);

  echo "<h2>Thank you for your Comment!</h2>";

  mysql_close($dbh);
}
?>


So this is what I am working with any help would be awesome! Thanks..
NewCode31
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Jan 01, 2014 10:46 am

Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.