• Resolved robertkay

    (@robertkay)


    Hi,
    When I can call save on the EM_Event below I get the following message. Is it just that I haven’t filled in a bunch of fields yet or something more sinister? I have filed in all the fields related to location I think so am a bit puzzled… Any thoughts greatly appreciated, I know you must get a lot of these with such a complex plugin!

    Many thanks,
    Rob

    <div id=’error’>
    <p class=’wpdberror’>WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1]
    SELECT location_status FROM wp_em_locations WHERE location_id=</p>
    </div>

    EM_Event Object
    (
    [event_id] =>
    [post_id] =>
    [event_slug] =>
    [event_owner] =>
    [event_name] => The Hot Caribbean New Year’s Eve
    [event_start_time] => 21:00
    [event_end_time] => 04:00
    [event_all_day] =>
    [event_start_date] => 2010-12-31
    [event_end_date] =>
    [post_content] =>
    [event_rsvp] =>
    [event_rsvp_date] =>
    [event_rsvp_time] => 00:00:00
    [event_rsvp_spaces] =>
    [event_spaces] =>
    [event_private] =>
    [location_id] => 2
    [recurrence_id] =>
    [event_status] =>
    [event_date_created] =>
    [event_date_modified] =>
    [blog_id] =>
    [group_id] =>
    [event_attributes] => Array
    (
    [fburl] =>
    [ticketurla] =>
    [ticketurlb] =>
    [ticketurlc] =>
    )

    [recurrence] => 0
    [recurrence_interval] =>
    [recurrence_freq] =>
    [recurrence_byday] =>
    [recurrence_days] => 0
    [recurrence_byweekno] =>
    [recurrence_rsvp_days] =>
    [event_owner_anonymous] =>
    [event_owner_name] =>
    [event_owner_email] =>
    [fields] => Array
    (
    [event_id] => Array
    (
    [name] => id
    [type] => %d
    )

    [post_id] => Array
    (
    [name] => post_id
    [type] => %d
    )

    [event_slug] => Array
    (
    [name] => slug
    [type] => %s
    [null] => 1
    )

    [event_owner] => Array
    (
    [name] => owner
    [type] => %d
    [null] => 1
    )

    [event_name] => Array
    (
    [name] => name
    [type] => %s
    [null] => 1
    )

    [event_start_time] => Array
    (
    [name] => start_time
    [type] => %s
    [null] => 1
    )

    [event_end_time] => Array
    (
    [name] => end_time
    [type] => %s
    [null] => 1
    )

    [event_all_day] => Array
    (
    [name] => all_day
    [type] => %d
    [null] => 1
    )

    [event_start_date] => Array
    (
    [name] => start_date
    [type] => %s
    [null] => 1
    )

    [event_end_date] => Array
    (
    [name] => end_date
    [type] => %s
    [null] => 1
    )

    [post_content] => Array
    (
    [name] => notes
    [type] => %s
    [null] => 1
    )

    [event_rsvp] => Array
    (
    [name] => rsvp
    [type] => %d
    [null] => 1
    )

    [event_rsvp_date] => Array
    (
    [name] => rsvp_date
    [type] => %s
    [null] => 1
    )

    [event_rsvp_time] => Array
    (
    [name] => rsvp_time
    [type] => %s
    [null] => 1
    )

    [event_rsvp_spaces] => Array
    (
    [name] => rsvp_spaces
    [type] => %d
    [null] => 1
    )

    [event_spaces] => Array
    (
    [name] => spaces
    [type] => %d
    [null] => 1
    )

    [location_id] => Array
    (
    [name] => location_id
    [type] => %d
    [null] => 1
    )

    [recurrence_id] => Array
    (
    [name] => recurrence_id
    [type] => %d
    [null] => 1
    )

    [event_status] => Array
    (
    [name] => status
    [type] => %d
    [null] => 1
    )

    [event_private] => Array
    (
    [name] => status
    [type] => %d
    [null] => 1
    )

    [event_date_created] => Array
    (
    [name] => date_created
    [type] => %s
    [null] => 1
    )

    [event_date_modified] => Array
    (
    [name] => date_modified
    [type] => %s
    [null] => 1
    )

    [event_attributes] => Array
    (
    [name] => attributes
    [type] => %s
    [null] => 1
    )

    [blog_id] => Array
    (
    [name] => blog_id
    [type] => %d
    [null] => 1
    )

    [group_id] => Array
    (
    [name] => group_id
    [type] => %d
    [null] => 1
    )

    [recurrence] => Array
    (
    [name] => recurrence
    [type] => %d
    [null] => 1
    )

    [recurrence_interval] => Array
    (
    [name] => interval
    [type] => %d
    [null] => 1
    )

    [recurrence_freq] => Array
    (
    [name] => freq
    [type] => %s
    [null] => 1
    )

    [recurrence_days] => Array
    (
    [name] => days
    [type] => %d
    [null] => 1
    )

    [recurrence_byday] => Array
    (
    [name] => byday
    [type] => %s
    [null] => 1
    )

    [recurrence_byweekno] => Array
    (
    [name] => byweekno
    [type] => %d
    [null] => 1
    )

    [recurrence_rsvp_days] => Array
    (
    [name] => recurrence_rsvp_days
    [type] => %d
    [null] => 1
    )

    )

    [post_fields] => Array
    (
    [0] => event_slug
    [1] => event_owner
    [2] => event_name
    [3] => event_attributes
    [4] => post_id
    [5] => post_content
    )

    [recurrence_fields] => Array
    (
    [0] => recurrence_interval
    [1] => recurrence_freq
    [2] => recurrence_days
    [3] => recurrence_byday
    [4] => recurrence_byweekno
    )

    [image_url] => images/usr_event/
    [start] =>
    [end] =>
    [rsvp_end] =>
    [created] =>
    [modified] =>
    [location] =>
    [bookings] =>
    [contact] =>
    [category] =>
    [errors] => Array
    (
    )

    [feedback_message] =>
    [warnings] =>
    [required_fields] => Array
    (
    [0] => event_name
    [1] => event_start_date
    )

    [mime_types] => Array
    (
    [1] => gif
    [2] => jpg
    [3] => png
    )

    [previous_status] =>
    [ID] =>
    [post_author] =>
    [post_date] =>
    [post_date_gmt] =>
    [post_title] =>
    [post_excerpt] =>
    [post_status] =>
    [comment_status] =>
    [ping_status] =>
    [post_password] =>
    [post_name] =>
    [to_ping] =>
    [pinged] =>
    [post_modified] =>
    [post_modified_gmt] =>
    [post_content_filtered] =>
    [post_parent] =>
    [guid] =>
    [menu_order] =>
    [post_type] =>
    [post_mime_type] =>
    [comment_count] =>
    [ancestors] =>
    [filter] =>
    [status_array] => Array
    (
    [0] => Pending
    [1] => Approved
    )

    [entry_price] => Array
    (
    [low] =>
    [high] =>
    )

    [location_latitude] => 51.521089
    [location_longitude] => -0.0917319
    [location_name] => Parker Mcmillan
    [location_address] => 47 Chiswell Street
    [location_town] => London
    [location_state] => London
    [location_postcode] => EC1Y4SB
    [location_region] => London
    [location_country] => Jamaica
    [content] => The Hot Caribbean New Year’s Eve Party – Friday 31st December You are invited to the Hot Caribbean New Year’s Eve Friday 31st December. This explosive fete will kick start 2011 Caribbean style in Sun Bailante’s tropical furnace. We have lined up the best Dj’s originated from this part of the world with DTee the Soca master at BBC 1Xtra, DJ Djahman, Guadeloupe’s most versatile Dj jetting off to London, Sun Bailante with its infectious Latin and global sounds, plus special Grenadian guest on the night DJ QT 2 Hype the rising star from Bang radio. Don’t miss the sexy Caribbean Carnival parade and expect hip-shaking Soca, Dancehall, Zouk and Reggae alongside R&B, Hip Hop, Funky House plus Salsa, Reggaeton and Latin vibes. A surprise Live PA will get you in the party mood as you arrive to Parker McMillan one of the most mysterious yet sublime venues of London. Tasty Caribbean food will be served in the restaurant. The dress code is ‘Exotic Blue’ on that night! Finally, 10% of the profit will go to the National Committee for St Lucia Hurricane relief registered Charity no# 281188. This Sun Bailante event is sponsored by: – Poison UK, the biggest Caribbean events company in Europe – Soca News, the number one Soca Magazine in the UK.
    [artist] => Sun Bailante, Dj Qt 2 Hype, Dj Dtee, Dj Djahman
    [genre] => Zouk, Soca, Salsa, Reggaeton, Reggae, R&B, Dancehall
    [event_price_low] => 20
    [event_price_high] => 25
    [fbEventId] =>
    )

    https://www.ads-software.com/plugins/events-manager/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hmm, would it be possible to share your code on how do you call the event save for us to check?

    Thread Starter robertkay

    (@robertkay)

    OK, here it is. It’s an importer from another db – only a one off so not the tidiest… DB/url details have been removed. I’m looking at it now and wondering if it’s because of how I’ve included wordpress with wp-blog-header.php. Thankyou for your time.

    ————

    require_once(‘../wp-blog-header.php’);

    define(“MDB_HOST”, “localhost”);

    define(“MDB_NAME”, “”);
    define(“MDB_USER”, “”);
    define(“MDB_PASS”, “”);

    $cmskit_DB=”;
    $cmskit_BasePath=”;

    function cmskit_initDB()
    {
    global $cmskit_DB;
    $cmskit_DB=mysql_connect(‘localhost’,MDB_USER,MDB_PASS);
    cmskit_query(“USE “.MDB_NAME.”;”);
    }

    function cmskit_query($sql)
    {
    global $cmskit_DB;
    // echo ‘
    1 ‘.$sql.’
    ‘;
    $q = mysql_query($sql,$cmskit_DB) or die(‘Error: ‘.mysql_error().’ when executing ‘.$sql.’ today.’);
    return $q;
    }

    function migrate_events()
    {
    global $cmskit_DB, $cmskit_BasePath;
    $url = $cmskit_BasePath.’submit-event’;

    global $cmskit_DB;
    $sql=’SELECT event_id FROM event’;
    $events=cmskit_query($sql);

    $row = mysql_fetch_assoc($events);

    $data = getanevent($row[‘event_id’]);
    print_r($data);

    }

    function decode_sanitise($string) {
    $string = html_entity_decode($string, ENT_QUOTES, ‘UTF-8’);
    $string = htmlspecialchars_decode($string, ENT_QUOTES);
    $string = strip_tags($string);
    $string = convert_smart_quotes($string);
    return $string;
    }

    function convert_smart_quotes($string)
    {
    $search = array(‘”’,
    ‘“’,
    ‘’’,
    ‘ ‘);

    $replace = array(‘”‘,
    ‘”‘,
    “‘”,
    ” “
    );

    return str_replace($search, $replace, $string);
    }

    function one_to_many($table, $field, $db_row, $event_id) {
    $qry = “SELECT “.$field.”.”.$field.”_lable FROM “.$field.”, “.$table.” WHERE “.$table.”.event_id='”. $event_id .”‘ AND “.$table.”.”.$field.”_id = “.$field.”.”.$field.”_id”;
    $result = mysql_query($qry) or die(mysql_error() . ” 3″);
    $rows_count = mysql_num_rows($result);
    $result_count = 1;
    $result_concat = “”;
    while($row = mysql_fetch_array($result)) {
    if ($result_count < $rows_count) {
    $result_concat .= decode_sanitise($row[$db_row]) . “, “;
    }
    else {
    $result_concat .= decode_sanitise($row[$db_row]);
    }
    $result_count++;
    }
    return $result_concat;
    }

    function getanevent($event_id)
    {
    $con = mysql_connect(MDB_HOST, MDB_USER, MDB_PASS);
    if (!$con)
    {
    die(‘Could not connect: ‘ . mysql_error());
    }

    mysql_select_db(‘MDB_NAME’, $con);

    // Query for event info
    $qry = “SELECT event_id, event_title, venue_id, date, st_time, end_time, price_min, price_max, description, event_url, youtube_url, approved, canceled, published, deleted, created_by FROM event WHERE event_id=’$event_id’ AND approved =’1′”;
    $result = mysql_query($qry) or die(mysql_error() . ” 1″);

    while($row = mysql_fetch_array($result)){
    $event_id = $row[‘event_id’];
    $event_title = decode_sanitise($row[‘event_title’]);
    $venue_id = $row[‘venue_id’];
    $date = $row[‘date’];
    $st_time = $row[‘st_time’];
    $end_time = $row[‘end_time’];
    $price_min = $row[‘price_min’];
    $price_max = $row[‘price_max’];
    $description = decode_sanitise($row[‘description’]);
    $event_url = $row[‘event_url’];
    $youtube_url = $row[‘youtube_url’];
    $approved = $row[‘approved’];
    $canceled = $row[‘canceled’];
    $created_by = $row[‘created_by’];
    }

    //Query for event image
    $qry = “SELECT images.img_name, images.img_url, images.approved, images.tag
    FROM images, event_image
    WHERE event_image.event_id=’$event_id’
    AND event_image.img_id = images.img_id
    AND images.img_url = ‘images/usr_event/'”;
    $result = mysql_query($qry) or die(mysql_error() . ” 4″);

    while($row = mysql_fetch_array($result)){
    $img_event_name = $row[‘img_name’];
    $img_event_url = $row[‘img_url’];
    $img_event_tag = decode_sanitise($row[‘tag’]);
    $img_event_approved = $row[‘approved’];
    }

    //Query for Venue info
    $qry = “SELECT venue.venue_lable, venue.street, venue.postcode, venue.venue_url, venue.venue_lat, venue.venue_lng, venue.approved,
    region.region_lable, town.town_lable
    FROM venue

    LEFT JOIN region
    ON venue.region_id = region.region_id

    LEFT JOIN town
    ON venue.town_id = town.town_id

    LEFT JOIN area
    ON venue.area_id = area.area_id

    WHERE venue.venue_id=’$venue_id'”;
    $result = mysql_query($qry) or die(mysql_error() . ” 2″);

    while($row = mysql_fetch_array($result)){
    $venue_lable = decode_sanitise($row[‘venue_lable’]);
    $street = decode_sanitise($row[‘street’]);
    $region_lable = $row[‘region_lable’];
    $town_lable = decode_sanitise($row[‘town_lable’]);
    $postcode = $row[‘postcode’];
    $venue_url = $row[‘venue_url’];
    $venue_approved = $row[‘approved’];
    $venue_lat = $row[‘venue_lat’];
    $venue_lng = $row[‘venue_lng’];
    }

    $genre = “”;
    $artist = “”;
    $continent = “”;
    $country = “”;

    $genre = one_to_many(“event_genre”, “genre”, “genre_lable”, $event_id);
    $artist = one_to_many(“event_artist”, “artist”, “artist_lable”, $event_id);
    $continent = one_to_many(“event_continent”, “continent”, “continent_lable”, $event_id);
    $country = one_to_many(“event_country”, “country”, “country_lable”, $event_id);

    $EM_Event = new EM_Event();
    $EM_Event->event_name = ‘your event’;
    $EM_Event->event_name=$event_title;
    $EM_Event->location_latitude=$venue_lat;
    $EM_Event->location_longitude=$venue_lng;
    $EM_Event->location_id=$venue_id;
    $EM_Event->location_name=$venue_lable;
    $EM_Event->location_address=$street;
    $EM_Event->location_town=$town_lable;
    $EM_Event->location_state=$region_lable;
    $EM_Event->location_postcode=$postcode;
    $EM_Event->location_region=$region_lable;
    $EM_Event->location_country=$country;
    $EM_Event->content=$description;
    $EM_Event->image_url=$img_event_url;
    $EM_Event->event_start_date=$date;
    $EM_Event->event_end_date=nextdaycalc($date, $st_time, $end_time);
    $EM_Event->event_start_time=$st_time;
    $EM_Event->event_end_time=$end_time;
    $EM_Event->event_attributes=array(‘fburl’ => fburlcalc($event_url), ‘ticketurla’ => ”, ‘ticketurlb’ => ”, ‘ticketurlc’ => ”);
    $EM_Event->artist=$artist;
    $EM_Event->genre=$genre;
    $EM_Event->event_price_low=$price_min;
    $EM_Event->event_price_high=$price_max;
    $EM_Event->fbEventId=fbidcalc($event_url);

    print_r($EM_Event);

    $EM_Event->save();

    return $postarray;
    }

    function nextdaycalc($date, $st_time, $end_time)
    {

    }
    function fburlcalc($event_url)
    {

    }
    function fbidcalc($event_url)
    {

    }

    cmskit_initDB();
    migrate_events();

    Plugin Support angelo_nwl

    (@angelo_nwl)

    hmm, maybe you can check this line $EM_Event->location_id=$venue_id; and make sure that only numbers are allowed.

    Thread Starter robertkay

    (@robertkay)

    Thanks for your response. You’re right, it was a string not an int – of the number 2. However I used intval to make it an int (and also tried an integer value) and it still generates exactly the same result.

    If you have any other ideas please shoot. Otherwise I’ll make a separate test without all the db import stuff and start trying to track it down. I’ll share the results here if I get anywhere.

    Thread Starter robertkay

    (@robertkay)

    Interesting… It created the event just fine and even inputted the correct location_id (2) from the string I originally sent it (didn’t need it converted to int).

    But EM_location object is totally blank…

    OK, I think it’s a problem my end, that location_id is duff. Sorry to waste your time and thank you for your help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wpdberror on event save’ is closed to new replies.