hi im struggling with this error see section below if anyone can help be much appreciated ty jan x

<?php 
include("config/db_connect.php");
include("config/ckh_session.php");

// Inserting user Details code
if(isset($_POST['submitmeet']))
{
    $event_title    = addslashes($_POST['event_title']);
    $description    = addslashes($_POST['description']);

    $insert = mysqli_query($conn,"update meets set event_type = '".$_POST['event_type']."' , 
        event_date  = '".$_POST['event_date']."' , 
        stateid     = '".$_POST['stateid']."' , 
        area        = '".$_POST['area']."' , 
        event_title = '".$event_title."' , 
        description     = '".$description."' , 
        ltm         = '".$_POST['ltm']."' where user_id = '".$_SESSION['last_id']."' ") or die(mysqli_error($conn));

    if($insert)
    {
        header("location:  searchmeets.php");
    }
}

// Fetch user details
$query      = mysqli_query($conn,"select * from user where user_id = '".$_SESSION['last_id']."' "); //THIS LINE IS THE ERROR
$fetch_user = mysqli_fetch_array($query);

?>

And heres table its trying to fetch from

CREATE TABLE IF NOT EXISTS `user` (
  `user_id` int(11) NOT NULL AUTO_INCREMENT,
  `age` int(5) NOT NULL,
  `partnerage` int(5) NOT NULL,
  `user_name` varchar(100) NOT NULL,
  `user_email` varchar(50) NOT NULL,
  `user_password` varchar(50) NOT NULL,
  `user_birthdate` varchar(50) NOT NULL,
  `partneruser_birthdate` varchar(50) NOT NULL,
  `user_gender` varchar(50) NOT NULL,
  `user_country` varchar(100) NOT NULL,
  `user_image` varchar(150) NOT NULL,
  `reg_date` varchar(50) NOT NULL,
  `mod_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `last_logout` varchar(255) NOT NULL,
  `memtype` int(1) NOT NULL,
  `location` varchar(10) NOT NULL,
  `status` int(11) NOT NULL,
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

Hi Janice,

the error is given by this $_SESSION['last_id'], because is not set. Before running the query you can make sure the index is set by running:

if(TRUE === array_key_exists('last_id', $_SESSION))
{
    # execute query
}
commented: Thanks, I was a dumb +7

Using my magical powers I've tried to telepathically deduce the error message you forgot to post and I think if you remove the ' around '".$_SESSION['last_id']."' it might solve your issue. Since your user_id column is defined as integer and those single quotes make it a string.

Also, although I think we've had that discussion before, I'd pray that Bobby Tables never signs up. You really shouldn't put $_POST variables directly into the query, but if you're set on using mysqli at least use prepared statements.

Edit: also do what cereal is saying.

Edit2: I should also learn to read titles, because you did post the error, sorry.

commented: hip hip for bobby tables! ;D +14
commented: I mentioned ps to her many many times - never listens - heh heh - she's working on swingers' site - you'd think she'd take member security seriously. +15

thankyou thats solved it much appreciated

commented: I saw it was you and I assumed it would be about the PHP of your site and didn't even read the title. Sorry about that, and good luck! +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.