Php errors

Status
Not open for further replies.

Wizet

New Member
Messages
644
Reaction score
0
Points
0
I am still getting php errors when I filled out the forum correctly added my db name, db username, and password as well. There is nothing else to put but I still am getting these php error codes.

PHP:
<?php
mysql_connect("localhost", "cpuser_dbuser", "password"); //practice placing your db information in a non web-accessible directory
mysql_select_db("cpuser_dbname"); // such as the parent directory of public_html (your home directory) 
if ($_POST['add_comment']) {
    if (!empty($_POST['comments']) && !empty($_POST['email']) && !empty($_POST['name'])) {
        $comments = mysql_real_escape_string($_POST['comments']);
        $email = mysql_real_escape_string($_POST['email']);
        $name = mysql_real_escape_string($_POST['name']);
        $time = time();
        $result = mysql_query("INSERT INTO comments (id, comments, email, name, time) VALUES(NULL, $comments, $email, $name, $time)");
        if ($result) {
            echo 'Comment Posted<br /><br />
            Click <a href="http://forums.x10hosting.com/marketplace/?">here</a> to return';
        }
    } else {
        echo 'You Forgot a Field<br /><br />
        Click <a href="javascript:history.go(-1)">here</a> to return';
    }
} else {
    $result = mysql_query("SELECT comments, name, time FROM comments ORDER BY id DESC LIMIT 20");
    while ($result = mysql_fetch_assoc($result)) {
    $comment = str_replace("\n", '<br />', $result['comments']);
        $name = $result['name'];
        $time_offset = (-5*3600); // If your target base is located in the east-coast (EST -5), then leave alone.  If it's different, then modify -5 to the proper offset
        $date = date('M j, Y g:i a', ($result['time']+$time_offset)); // For date format information, see http://www.php.net/date
        echo '<p>'.$comment.'<br /><strong>By: '.$name.' on '.$date.'</strong></p>';
    }
?>
<form action="?submit" method="post">
  Comments:<br />
  <textarea name="comments">
  Hey... say something!
  </textarea><br />
  Name: <input name="name" type="text" /><br />
  Email (hidden): <input name="email" type="text" /><br /><br />
  <input type="submit" value="Submit" name="add_comment" />
</form>
<?php
}
?>
 
Last edited:
Status
Not open for further replies.
Top