infinitesunrise / carsinbikelanes

A browsable geographic database for crowdsourced traffic violation reporting
GNU General Public License v3.0
64 stars 18 forks source link

Just hangs for submission. #52

Closed alexfrieden closed 7 years ago

alexfrieden commented 7 years ago

Got working but when I go to do a dummy submission but it seems to just hang. Nothing in apache error_log is coming up. Thoughts? screen shot 2016-11-02 at 4 28 34 pm

alexfrieden commented 7 years ago

Bump.

infinitesunrise commented 7 years ago

Anything in the javascript console? The site handles uploads and search queries through an api in /api, and I've got a feeling this has something to do with the site failing to make an ajax request to itself somewhere else besides the two environments I've tested it in.

What should be happening here is the api returning a no-image-attached (Because there's no image attached) error that pops up in a new panel, as any error returned just gets displayed that way. But I haven't added a way to handle 500 internal server errors, which is probably what it'd be returning on the console if ajax communication isn't working.

I can post a more verbose version of the root index.php file for you to replace yours with and we can figure out what's up.

infinitesunrise commented 7 years ago

Zip contains three files, replace them with their counterparts on the server (root index.php, submission.php, and /api/index.php) to get the javascript console and php error log talking when you try uploading a submission.

verbose_cibl.zip

infinitesunrise commented 7 years ago

...And you'll have to change the last character on line 1150 of the root index.php to ; instead of ' because I'm a dummy who didn't try it out before I gave it to you.

alexfrieden commented 7 years ago

Hmmm, I am not seeing that

1147 console.log('formData: ' + formData); 1148 1149 var url_string = document.location.origin + '/api/upload'; 1150 1151 console.log('url_string: ' + url_string);

alexfrieden commented 7 years ago

Oops, it was on 1162:

console.log('error')'

alexfrieden commented 7 years ago

Okay before submission, I am getting a couple of errors. Let me know your thoughts on how to address. Thanks! screen shot 2016-11-04 at 9 02 44 am

alexfrieden commented 7 years ago

And errors on upload submission

screen shot 2016-11-04 at 10 24 00 am
infinitesunrise commented 7 years ago

Ah hah, I think I know what's going on, via the second error line of the pre-submission screenshot. The API endpoints /api/search and /api/upload don't actually exist as files, instead there is a sort of catch-all .htaccess file at /api/.htaccess that intercepts any requests for non-existent directories and instead passes them as form variables to /api/index.php, which actually does the work of processing any and all API requests. The .htaccess file: https://github.com/infinitesunrise/carsinbikelanes/blob/master/api/.htaccess (Honestly I'm pretty bad at Apache configuration, this snippet was copied from an article that described how to re-write incoming requests to manage API endpoints).

Is carsinbikelanesboston.com (Freakin awesome, by the way) hosted on an Apache server? Because I don't think .htaccess will work otherwise. Apache also has to have the mod_rewrite extension installed and enabled. That was the case on my host (Dreamhost) and test environment (MAMP) but your mileage may vary.

Worst case scenario, if the above fails to help I can literally add /search and /upload as directories, containing index files that simply include() the workhorse index.php file one directory up.

infinitesunrise commented 7 years ago

Seriously though, having a CIBL in Boston would be pretty sweet. I'm going to have to improve the install process and probably come up with an update process in order to better support you guys :D

alexfrieden commented 7 years ago

@infinitesunrise hahahaha thanks. We need a database like this BAD in Boston/Cambridge. Currently I am running this on apache server (httpd). I am not sure on version but I can get that if that would help. The .htaccess file is there is the api folder but I have made no other changes. Let me know next steps. Thanks!

alexfrieden commented 7 years ago

Bump.

alexfrieden commented 7 years ago

Let me know what other info you need.

infinitesunrise commented 7 years ago

Sorry I've been off the grid for a few days :) So I did a bit of playing around with literally creating the /api/upload and /api/search directories and putting little index.php files inside them that just link back to the index.php one level up via a single "include('../index.php');" line, however it turns out that actually doesn't work for two reasons:

1) The main page sends search and upload requests to /api/upload and /api/search, NOT /api/upload/index.php and /api/search/index.php 2) The workhorse api file at /api/index.php takes the path that the .htaccess file intercepts and checks if it's literally /api/upload or /api/search, so even if step 1 was fixed this would have to be re-written as well.

If you have any experience at all with PHP I can walk you through making these changes (Let me know if you want to try that). But a more solid long-term solution would be to get Apache's mod_rewrite extension working on your hosting. I don't know a terrible amount of Apache configuration but I know this is a common - usually standard - extension, and if not enabled by your hosting provider or by your host then it might be trivial to enable it, which would get that .htaccess file working as it should.

If you've got a private server running Ubuntu this should get you started: http://www.jarrodoberto.com/articles/2011/11/enabling-mod-rewrite-on-ubuntu or for CentOS 7: https://devops.profitbricks.com/tutorials/install-and-configure-mod_rewrite-for-apache-on-centos-7/ found these via this search which also had a few helpful-looking stackexchange questions: https://www.google.com/search?q=apache+mod_rewrite+not+working&ie=utf-8&oe=utf-8.

So I'd suggest seeing if you can dig into why mod_rewrite isn't working on your host first, and then if that fails let me know and I'll write up how to edit the website to work around it's non-existence. Just know that future updates might break manual code edits!

alexfrieden commented 7 years ago

So I was able to change the AllowOverride setting and it did the initial query fine but failed on submission. Apache log has the following at the end: [Tue Nov 08 03:48:04.566911 2016] [:error] [pid 14923] [client 209.6.93.41:61133] Array\n(\n [plate] => 1MJA60\n [state] => MA\n [date] => 2016-10-26T8:00:00\n [gps_latitude] => 42.340322735536716\n [gps_longitude] => -71.10574722290039\n [street1] => \n [street2] => \n [council_district] => \n [precinct] => \n [community_board] => \n [description] => \n)\n, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.566916 2016] [:error] [pid 14923] [client 209.6.93.41:61133] Array\n(\n [request] => upload\n)\n, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.566925 2016] [:error] [pid 14923] [client 209.6.93.41:61133] Array\n(\n [image] => Array\n (\n [name] => aefrieden_2016-Oct-26.jpg\n [type] => image/jpeg\n [tmp_name] => /tmp/phpvIpuOJ\n [error] => 0\n [size] => 481360\n )\n\n)\n, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.566934 2016] [:error] [pid 14923] [client 209.6.93.41:61133] in /api/upload, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.568461 2016] [:error] [pid 14923] [client 209.6.93.41:61133] $upload:, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.568474 2016] [:error] [pid 14923] [client 209.6.93.41:61133] PHP Warning: error_log() expects parameter 1 to be string, object given in /var/www/html/api/index.php on line 363, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.568679 2016] [:error] [pid 14923] [client 209.6.93.41:61133] in submission.new_upload(), referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.568832 2016] [:error] [pid 14923] [client 209.6.93.41:61133] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/submission.php on line 163, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.568869 2016] [:error] [pid 14923] [client 209.6.93.41:61133] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/submission.php on line 164, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12 [Tue Nov 08 03:48:04.568906 2016] [:error] [pid 14923] [client 209.6.93.41:61133] PHP Fatal error: Class 'Imagick' not found in /var/www/html/submission.php on line 188, referer: http://carsinbikelanesboston.com/index.php?center=42.34,-71.08&zoom=12

infinitesunrise commented 7 years ago

OH hehe... I forgot to mention, those debug files I gave you the other day were accidentally from a branch I'm working on locally, and aren't compatible with the rest of the site... Looks like they're still in use, replace them with the originals and you may have more luck.

FYI now my local site is broken too, the .htaccess file stopped working correctly after I re-arranged things during that test because it must have cached something. Once I get back on my feet I should be able to help further :P

infinitesunrise commented 7 years ago

OK, was able to flush my dev server cache, back up and running. Anyway, based on the errors you're getting it looks like re-directing is working fine now! All you'll have to do from here is move the original files back into place. The ones I gave you assume several NYC-centric fields, like community board, council district, and police precinct.

Just a teaser, once I release these additions I'm then going to work to get them packaged into some plugin-like format so that they don't have to be used everywhere. Once I do that, similar plugins for other cities become an option.

alexfrieden commented 7 years ago

Hmmm, I seem to have fubared my install and it is in setup mode again. Similar problems now of create database are no longer working.

alexfrieden commented 7 years ago

Ya still getting the following error from the master branch:

MySQL connection successful but error setting up database: 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 'CHARACTER SET utf8 COLLATE utf8_general_ci' at line 1

Please advise as I can't get this working.

alexfrieden commented 7 years ago

Happy to give you access as well.

infinitesunrise commented 7 years ago

I've seen this error report from one other person, as well. Sorry but the setup process still really needs to be improved too. It doesn't do the best job of cleaning up after a failed setup attempt, which can botch further attempts. After a failed attempt make sure (Sometimes not all of these need to be done, depending on where setup failed):

1) Your cibl_config folder, wherever it got put, needs to be renamed to just 'config' and moved back into the root CIBL directory from whence it came. 2) Then config/config.php needs to be deleted, that gets generated by the setup process so it needs to go. 3) Delete /images and /thumbs, they get generated by setup 3) Delete /admin/config_pointer.php, same situation 5) Rename index.php to index_actual.php and index_old.php to index.php 6) Remove the previously attempted database from MySQL (I have it set up to try and USE a database if it already exists, but it doesn't seem to work well yet, best to just remove it completely and let the setup script do it for you again. This actually might be what's happening with your error here, trying to edit the database it set up last time).

Alternatively: 1) Do steps 1 and 6 from above 2) Delete the CIBL directory and clone down a new one.

Also my host (Dreamhost shared server) doesn't let me use 'localhost' in the mysql server field even though it's hosted on the same machine, so try a qualified domain name if you're using localhost in a live environment.

Yeesh, after typing all that out it's clear that the setup process REALLY sucks still. Might even make improving that a priority before the plugin system...

alexfrieden commented 7 years ago

Woot! Got it working, had to change system permissions on www folder.

So I am trying to submit and getting this same error as with the debug branch. I have deployed the master branch. Here is the apache error log:

[Tue Nov 08 14:10:12.412462 2016] [:error] [pid 17774] [client 170.223.207.83:17214] submission.php - $date_occurrence inbound: 2016-10-26T8:00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.341,-71.05&zoom=12 [Tue Nov 08 14:10:12.412481 2016] [:error] [pid 17774] [client 170.223.207.83:17214] submission.php - $date_added inbound: 2016-11-08T14:10:12+00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.341,-71.05&zoom=12 [Tue Nov 08 14:10:12.412625 2016] [:error] [pid 17774] [client 170.223.207.83:17214] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/submission.php on line 144, referer: http://carsinbikelanesboston.com/index.php?center=42.341,-71.05&zoom=12 [Tue Nov 08 14:10:12.412663 2016] [:error] [pid 17774] [client 170.223.207.83:17214] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/submission.php on line 145, referer: http://carsinbikelanesboston.com/index.php?center=42.341,-71.05&zoom=12 [Tue Nov 08 14:10:12.412700 2016] [:error] [pid 17774] [client 170.223.207.83:17214] PHP Fatal error: Class 'Imagick' not found in /var/www/html/submission.php on line 169, referer: http://carsinbikelanesboston.com/index.php?center=42.341,-71.05&zoom=12 [Tue Nov 08 14:10:20.858414 2016] [:error] [pid 17775] [client 170.223.207.83:19606] PHP Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/api/index.php on line 235, referer: http://carsinbikelanesboston.com/index.php?center=42.341,-71.05&zoom=12

infinitesunrise commented 7 years ago

PHP Fatal error: Class 'Imagick' not found in /var/www/html/submission.php on line 169

That means that the ImageMagick PHP extension isn't installed. The site uses it for resizing and rotating images quickly / with low memory footprint. This is a similar situation to the mod_rewrite problem. It's an extension that either needs to be installed or enabled on your host. Like mod_rewrite it's super-common and well supported so you should be able to get it enabled in your environment. I followed this guide to build and install it on my Dreamhost account: https://help.dreamhost.com/hc/en-us/articles/217253537-ImageMagick-and-imagick-PHP-module-on-Shared-hosting. Depending on your host it might be as simple as uncommenting the imagick line in your php.ini config file, or you might have to do the full download-build-install as that guide shows, or there might be a pre-built version that you just have to copy into the right spot.

As for the mysqli_fetch_array() errors, they're probably harmless as that function throws a boolean value of FALSE instead of a MySQL row if the main table or upload queue tables are empty. And the upload queue table is empty unless you have a recent upload so maybe I should write some code to handle the case of them throwing FALSE.

alexfrieden commented 7 years ago

Very nice, so made some progress. On submission it hangs and I am getting the following error:

[Tue Nov 08 19:03:32.458884 2016] [:error] [pid 3758] [client 170.223.207.83:34501] PHP Fatal error: Call to a member function bind_param() on boolean in /var/www/html/submission.php on line 104, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12

infinitesunrise commented 7 years ago

Making progress indeed! OK, this error is happening right as submission.php is trying to add the entry to the moderation queue table in the database. bind_param() is basically telling MySQL what data is going to get entered, but one of the variables being passed is probably null or otherwise unspecified for some reason and thus evaluating false (So, a boolean), despite the bind_param statement getting told that none of the data types getting passed to it are booleans. So it errors out.

Add this code to line 100 in submission.php and you should get a bunch of output on the PHP error log of all the data submission.php is trying to add to the database. The one that comes back false (or perhaps true?) is the culprit and I can trace back what went wrong from there:

error_log("increment: " . $increment); error_log("url: " . $url); error_log("plate: " . $plate); error_log("state: " . $state); error_log("date_occurrence: " . $date_occurrence); error_log("date_added: " . $date_added); error_log("gps_latitude: " . $gps_latitude); error_log("gps_longitude: " . $gps_longitude); error_log("street1: " . $street1); error_log("street2: " . $street2); error_log("description: " . $description);

infinitesunrise commented 7 years ago

By the way, this thread is A+ bug reporting. Once we get you up and running I'm going to go back through this thread and tackle all these issues one by one! Rather exciting getting someone else to set it up as a user.

alexfrieden commented 7 years ago

Thanks! Added lines of code and got the following in apache error log. FYI I am using AWS Amazon Linux for this.

[Tue Nov 08 21:17:19.007718 2016] [:error] [pid 4088] [client 170.223.207.83:4683] increment: 1, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007735 2016] [:error] [pid 4088] [client 170.223.207.83:4683] url: 2016/11/8/queue_1.jpg, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007738 2016] [:error] [pid 4088] [client 170.223.207.83:4683] plate: 1MJA60, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007743 2016] [:error] [pid 4088] [client 170.223.207.83:4683] state: MA, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007746 2016] [:error] [pid 4088] [client 170.223.207.83:4683] date_occurrence: 2016-9-26T8:00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007748 2016] [:error] [pid 4088] [client 170.223.207.83:4683] date_added: 2016-11-08T21:17:18+00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007751 2016] [:error] [pid 4088] [client 170.223.207.83:4683] gps_latitude: 42.340479358710716, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007753 2016] [:error] [pid 4088] [client 170.223.207.83:4683] gps_longitude: -71.10565602779388, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007755 2016] [:error] [pid 4088] [client 170.223.207.83:4683] street1: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007757 2016] [:error] [pid 4088] [client 170.223.207.83:4683] street2: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007759 2016] [:error] [pid 4088] [client 170.223.207.83:4683] description: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Tue Nov 08 21:17:19.007859 2016] [:error] [pid 4088] [client 170.223.207.83:4683] PHP Fatal error: Call to a member function bind_param() on boolean in /var/www/html/submission.php on line 114, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12

alexfrieden commented 7 years ago

bump

alexfrieden commented 7 years ago

bump

infinitesunrise commented 7 years ago

Saw the first bump! It's been a crazy week.

OK so it looks like all of your upload variables are getting through just fine. Street1, street2 and description can be blank, that's fine. So you can go ahead and get rid of those debug lines I had you add, as the $stmt = $connection->prepare statement must be failing and returning false for some other reason, and that's why $stmt->bind_param right after it fails. So let's see if we can capture the error and display it.

Change this whole block:

$stmt = $connection->prepare("INSERT INTO cibl_queue ( increment, url, plate, state, date_occurrence, date_added, gps_lat, gps_long, street1, street2, description) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); $stmt->bind_param('isssssddsss', $increment, $url, $plate, $state, $date_occurrence, $date_added, $gps_latitude, $gps_longitude, $street1, $street2, $description); $result = $stmt->execute(); $stmt->close();

To this:

if($stmt = $connection->prepare("INSERT INTO cibl_queue ( increment, url, plate, state, date_occurrence, date_added, gps_lat, gps_long, street1, street2, council_district, precinct, community_board, description) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)")){ $stmt->bind_param('isssssddssiiss', $increment, $url, $plate, $state, $date_occurrence, $date_added, $gps_latitude, $gps_longitude, $street1, $street2, $council_district, $precinct, $community_board, $description); $result = $stmt->execute(); } else { $error = $mysqli->errno . ' ' . $mysqli->error; error_log($error); } $stmt->close();

This should print the relevant MySQL error when $connection->prepare returns false. Let me know the error and we'll take it from there. Guessing it's an environmental database issue but not sure yet.

alexfrieden commented 7 years ago

Here is the output:

[Sun Nov 13 22:28:10.500160 2016] [:error] [pid 26627] [client 87.224.66.128:56358] increment: 1, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500173 2016] [:error] [pid 26627] [client 87.224.66.128:56358] url: 2016/11/13/queue_1.jpg, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500176 2016] [:error] [pid 26627] [client 87.224.66.128:56358] plate: 1MJA60, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500178 2016] [:error] [pid 26627] [client 87.224.66.128:56358] state: MA, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500181 2016] [:error] [pid 26627] [client 87.224.66.128:56358] date_occurrence: 2016-10-26T8:00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500184 2016] [:error] [pid 26627] [client 87.224.66.128:56358] date_added: 2016-11-13T22:28:10+00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500190 2016] [:error] [pid 26627] [client 87.224.66.128:56358] gps_latitude: 42.34048134128004, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500192 2016] [:error] [pid 26627] [client 87.224.66.128:56358] gps_longitude: -71.10568284988403, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500195 2016] [:error] [pid 26627] [client 87.224.66.128:56358] street1: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500197 2016] [:error] [pid 26627] [client 87.224.66.128:56358] street2: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500199 2016] [:error] [pid 26627] [client 87.224.66.128:56358] description: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500307 2016] [:error] [pid 26627] [client 87.224.66.128:56358] PHP Notice: Undefined variable: mysqli in /var/www/html/submission.php on line 118, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500313 2016] [:error] [pid 26627] [client 87.224.66.128:56358] PHP Notice: Trying to get property of non-object in /var/www/html/submission.php on line 118, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500316 2016] [:error] [pid 26627] [client 87.224.66.128:56358] PHP Notice: Undefined variable: mysqli in /var/www/html/submission.php on line 118, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500319 2016] [:error] [pid 26627] [client 87.224.66.128:56358] PHP Notice: Trying to get property of non-object in /var/www/html/submission.php on line 118, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500322 2016] [:error] [pid 26627] [client 87.224.66.128:56358] , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Sun Nov 13 22:28:10.500325 2016] [:error] [pid 26627] [client 87.224.66.128:56358] PHP Fatal error: Call to a member function close() on boolean in /var/www/html/submission.php on line 121, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12

alexfrieden commented 7 years ago

@infinitesunrise any idea what this might be?

alexfrieden commented 7 years ago

Hey, still stuck on this. Any ideas?

infinitesunrise commented 7 years ago

OHHHH DARN IT. The error-catching code is throwing errors! And I see why. The line:

$error = $mysqli->errno . ' ' . $mysqli->error;

Needs to be:

$error = $connection->errno . ' ' . $connection->error;

Sorry for the long silence, I've had my head buried in all kinds of stuff. If I had given your logs a few seconds more attention last week I would have seen this. Once you update that line you're still going to get errors, but at least they'll be descriptive, likely helpful errors and not useless meta-errors. So let's see what that spits out.

alexfrieden commented 7 years ago

Okay, so it appears no database is selected. What is the best way to select the database in php?

[Mon Nov 28 16:43:24.704175 2016] [:error] [pid 15128] [client 170.223.207.86:31740] PHP Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /var/www/html/submission.php on line 159, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840202 2016] [:error] [pid 15128] [client 170.223.207.86:31740] increment: 1, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840215 2016] [:error] [pid 15128] [client 170.223.207.86:31740] url: 2016/11/28/queue_1.jpg, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840218 2016] [:error] [pid 15128] [client 170.223.207.86:31740] plate: 1MJA60, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840221 2016] [:error] [pid 15128] [client 170.223.207.86:31740] state: MA, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840223 2016] [:error] [pid 15128] [client 170.223.207.86:31740] date_occurrence: 2016-10-26T8:00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840226 2016] [:error] [pid 15128] [client 170.223.207.86:31740] date_added: 2016-11-28T16:43:24+00:00, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840228 2016] [:error] [pid 15128] [client 170.223.207.86:31740] gps_latitude: 42.3404020384584, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840231 2016] [:error] [pid 15128] [client 170.223.207.86:31740] gps_longitude: -71.10600471496582, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840233 2016] [:error] [pid 15128] [client 170.223.207.86:31740] street1: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840236 2016] [:error] [pid 15128] [client 170.223.207.86:31740] street2: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840238 2016] [:error] [pid 15128] [client 170.223.207.86:31740] description: , referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840336 2016] [:error] [pid 15128] [client 170.223.207.86:31740] 1046 No database selected, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12 [Mon Nov 28 16:43:24.840350 2016] [:error] [pid 15128] [client 170.223.207.86:31740] PHP Fatal error: Call to a member function close() on boolean in /var/www/html/submission.php on line 121, referer: http://carsinbikelanesboston.com/index.php?center=42.35,-71&zoom=12

infinitesunrise commented 7 years ago

Strange. I don't know why that would be broken. But OK, you probably just need to trace the path back to the MySQL connection itself to make sure everything is set up correctly. First, in submission.php line 14 should have this:

require 'admin/config_pointer.php';

That loads the pointer to the config file. Config_pointer.php isn't in the repo, it gets generated on install, and within it the FULL (local) path to the config file should be stated three different ways (I have it do that because I'm still a noob and can't pick t he best way to do it). Make sure those paths actually exist. The most important one is the 'include' line. Make sure that one is accurate.

Next, open the config file itself (Should be sitting in the location that the pointer file specified) and make sure that the 'sqlhost', 'sqluser', 'sqlpass', and 'database' variables are accurate, and make sure that the bottom of the file has the line starting with '$connection = mysqli_connect', getting passed those four variables. That last line is THE mysql connection.

alexfrieden commented 7 years ago

Ahhh in admin/config.php the database and host were blank and didn't get written correct. I have editted it and it works! I also had to delete some of the lines for fields that are not in the database. New lines in submission.php should be:

if($stmt = $connection->prepare("INSERT INTO cibl_queue ( increment, url, plate, state, date_occurrence, date_added, gps_lat, gps_long, street1, street2, description) VALUES (?,?,?,?,?,?,?,?,?,?,?)")){ $stmt->bind_param('isssssddsss', $increment, $url, $plate, $state, $date_occurrence, $date_added, $gps_latitude, $gps_longitude, $street1, $street2, $description);

alexfrieden commented 7 years ago

Also needed to update php.ini to have:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = America/New_York

http://stackoverflow.com/questions/16765158/date-it-is-not-safe-to-rely-on-the-systems-timezone-settings

Now it works! Thanks for the help!