CartoDB SQL 'Insert Into' vanishes with no error in Safari

المشرف العام

Administrator
طاقم الإدارة
I have a little application that allows users to search for locations on a mac submit comments to a CartoDB database using an HMTL form, JavaScript and SQL (and a little PHP to make the API connection to CartoDB). It works great for vast majority of users, but some submissions are not coming through (I have a separate mailform script as a backup which is showing everything that is submitted).

I have no idea why the SQL submissions are working sometimes and not others, works perfectly every time for me. Although I have tracked one issue down to Safari 5.1, but I think it must be happening in other browsers too. The main problem is I can't see any errors ANYWHERE, so it's impossible to track down.

So here are my questions:

1. Is there any way of catching SQL errors and preventing the form from being submitted?

2. Is there any way of seeing SQL errors so I can track down the problem?

Below is a snippet of the code I am using to submit the comments:

var tblName = "comment_collection" var usrName = "***dney" // FORM $("#allSubmitBtn").click(function(e){ //CHECK IF has a comment if (!notEmpty(document.getElementById('description1'))){ alert('Please enter a comment.'); return false; } if (!notEmpty(document.getElementById('latlongit1'))){ alert('Sorry, there has been an error, please search for a location again.'); return false; } else{ currentNeighborhood = $('#neighborhoodName1').val(); parcel = $('#parcel_id1').val(); address = $('#pre_address1').val(); userAddress = $('#UserAddress1').val(); phoneNum = $('#phone1').val(); emailAdd = $('#emailAddress1').val(); userType = $('#userType1').val(); otherUser = $('#otherUserType1').val(); currentDescription = $('#description1').val(); latlongy = $("input[name='latlongit1']").val(); explainType = $('#explainType').val(); currentProject = selectedCity.name; commentType = new Array(); $("input:checkbox[name=commentType]:checked").each(function() { commentType.push($(this).val()); }); var sql = "INSERT INTO "+tblName+" (the_geom, project, description, name,comment_address,parcel_id,phone_number,email_address,comment_type,comment_type_other,user_type,user_type_other,profile_address,flag,loved) VALUES (ST_SetSRID(ST_GeomFromGeoJSON('"; // var a = layer.getLatLng(); // console.log(a); var sql2 ='{"type":"Point","coordinates":[' +latlongy+ "]}'),4326),'"+currentProject+"','"+(currentDescription.replace(/'/g,"''")).replace(/"/g,"''")+"','"+(currentNeighborhood.replace(/'/g,"''")).replace(/"/g,"''")+"','"+address+"','"+parcel+"','"+phoneNum+"','"+emailAdd+"','"+commentType+"','"+explainType+"','"+userType+"','"+otherUser+"','"+userAddress+"','false','0')"; var pURL = sql+sql2; console.log(pURL); submitToProxy(pURL); alert("Your Comments have been submitted"); return true; } });

أكثر...
 
أعلى