0

hi i have a events script for users if the user submits a event then the event shows up fine but if they add another event it over rights the previous event how can i stop that where they can add more than one but maximum 4 as one time

my php process page is as follows:

$query = 'insert into events set etype = "'.$etype.'", edate = "'.$edate.'", region = "' .$region.'", pcode = "'.$pcode.'", town = "'.$town.'", title = "'.$title.'", advert ="' .$advert.'", ltm ="' .$ltm. '", user_id =' . $userid  ;

//echo $query ;

$insert = mysqli_query ( $conn,$query ) or die(mysqli_error($conn)) ;

if($insert)
{
    //echo "added" ;
    header("location: addedmeets.php");
    exit;   
}

and the database table is as follows:

CREATE TABLE IF NOT EXISTS events (
id int(11) NOT NULL AUTO_INCREMENT,
user_id int(11) NOT NULL,
etype varchar(50) NOT NULL,
edate varchar(50) NOT NULL,
region varchar(50) NOT NULL,
pcode varchar(50) NOT NULL,
town varchar(50) NOT NULL,
title varchar(255) NOT NULL,
advert text NOT NULL,
ltm varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

any help would be much appreciated ty x

3
Contributors
2
Replies
17
Views
1 Year
Discussion Span
Last Post by gabrielcastillo
0

Huh, I'd completely forgotten about INSERT INTO ... SET :)
The code segment you've shown us should work fine (I can't see any errors anyway) so if you mean that the first INSERTION is completely replaced by the second in the database there must be something else going on. In particular there must be an UPDATE somewhere, or the first INSERT isn't getting called or is failing.
You mention a maximum of 4 records. What happens at reaching four? Are no more possible or is a previous one removed? You could have a logic error in that code.

0

How are you tracking the number of events being listed? @hericles mentioned update statment, you should show the full code for this script so we can see what is going on.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.