I'm using the Eventbrite Jquery plugin to get a list of events and post them to a php file using AJAX. I then use PHP to insert the data into mySQL. The problem is, when I search for a 100 events, it gets me all of them back, but only about 80-85 of them show up in the Database. Could anyone please help me with it?
Here's my PHP code:
include_once('dbheader.php');
$event_id = $_POST['ID'];
$title= $_POST['TITLE'];
$category= $_POST['CATEGORY'];
$capacity= $_POST['CAPACITY'];
$date_created = $_POST['DATE_CREATED'];
$end_date = $_POST['END_DATE'];
$status = $_POST['STATUS'];
$event_url = $_POST['EVENT_URL'];
$organizer_name = $_POST['ORGANIZER_NAME'];
$organizer_url = $_POST['ORGANIZER_URL'];
$privacy = $_POST['PRIVACY'];
$repeats = $_POST['REPEATS'];
$venue_address = $_POST['VENUE_ADDRESS'];
$venue_city = $_POST['VENUE_CITY'];
$venue_country = $_POST['VENUE_COUNTRY'];
$venue_id = $_POST['VENUE_ID'];
$venue_postal = $_POST['VENUE_POSTAL'];
$venue_region = $_POST['VENUE_REGION'];
$venue_name = $_POST['VENUE_NAME'];
if(mysql_query("INSERT IGNORE INTO eventbrite (event_id,title,category,capacity,date_created,end_date,status,event_url,organizer_name,organizer_url,privacy,repeats,venue_address,venue_city,venue_country,venue_id,venue_postal_code,venue_region,venue_name)VALUES ('$event_id','$title','$category','$capacity','$date_created','$end_date','$status','$event_url','$organizer_name','$organizer_url','$privacy','$repeats','$venue_address','$venue_city','$venue_country','$venue_id','$venue_postal','$venue_region','$venue_name')")){
echo "Success";
}
else
{echo "Failed";}
EDIT:
Using real_escape_string fixed it. This is my first time with mySQL. Thanks a lot to everyone who helped.
P.S: I'll definitely read up on SQL injection and prepared statements
First, consider switching from mysql_query to PDO prepared statements. It's secure and performant for repeated insertions. It has a very intuitive syntax.
Second: try to store all your events in a larger JSON batch to send one big request to the backend and perform a multiple insertion instead of 100 small ones.
At this point, you're probably DOSing your own backend with 100 concurrent requests. Some request get dropped and ajax asynchronous nature silently times them out.