Jump to content

[SOLVED] please help me with this inserting problem! please


littlepeg

Recommended Posts

:) Hi everybody, please help me with this problem. I have been stuck on this problem for a whole day.  :'( :'( :'(Any help would be grately and appreciated. I am trying to realize a function that after a user logged in, he/she can send comments. But no matter how I try the user_id can not insert into my database. And when I used print_r($_SESSION); There is a message as follow:

 

"Array ( [user_id] => 27 [first_name] => ting [agent] => f7ab13aacb2a32637ef1dc12d1b4a76b )"

 

Here are my codes:

<?php //sendcomment.php

ob_start();

session_name ('YourVisitID');

session_start(); // Start the session.

 

// If no session value is present, redirect the user.

if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT'])) ) {

...

}

 

// Check if the form has been submitted.

if (isset($_POST['submitted'])) {

 

  require_once ('snypdb.php'); // Connect to the db.

     

      $query = "SELECT user_id FROM users WHERE user_id='{$_SESSION['user_id']}'";

      $result = mysql_query($query);

      if (mysql_num_rows($result) == 1) {

 

        // Make the query.

        $query = "INSERT INTO comments (user_id, topic,comment, comment_date) VALUES ('{$_SEESION['user_id']}', '$topic','$comment', NOW() )";     

              $result = mysql_query ($query); // Run the query.

        if ($result) { // If it ran OK.

                            ...}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.