littlepeg Posted May 6, 2007 Share Posted May 6, 2007 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. ...} Link to comment https://forums.phpfreaks.com/topic/50278-solved-please-help-me-with-this-inserting-problem-please/ Share on other sites More sharing options...
benjaminbeazy Posted May 6, 2007 Share Posted May 6, 2007 $query = "INSERT INTO comments (user_id, topic,comment, comment_date) VALUES ('{$_SEESION['user_id']}', '$topic','$comment', NOW() )"; $_SESSION is misspelled Link to comment https://forums.phpfreaks.com/topic/50278-solved-please-help-me-with-this-inserting-problem-please/#findComment-246798 Share on other sites More sharing options...
littlepeg Posted May 6, 2007 Author Share Posted May 6, 2007 benjaminbeazy, you are so great!!!!!! Thank you very much. :) Link to comment https://forums.phpfreaks.com/topic/50278-solved-please-help-me-with-this-inserting-problem-please/#findComment-246805 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.