Page 1 of 1

Sphider-2.0.0a-PDO - parse error when indexing

Posted: Tue Feb 20, 2018 1:58 pm
by Webbo

Please excuse my preamble before I pose my question; but I'm keen to stress how much I want to get this working! :)

I've been a long time (happy) user of the original Sphider and it ran fine on my previous shared hosting package (which was using an older version of PHP}. I recently moved to VPS which uses a current PHP version. The original Sphider (as you're fully aware - hence your fabulous work to upgrade it) won't install because of deprecated/removed MySQL.

I bought Sphider-plus (as encouraged by its author) but was put off my the complex adjustments needed on the server - which I also thought may compromise security.

Having discounted Sphider-plus, I looked for alternatives. Google Custom Search does a great job, but I don't want competitor products advertised. SiteLevel seems to provide a weak alternative; but I can't get it to NOT index every page of the site (including the navigation menu) whatever I try (including robots.txt and noindex solutions). Every search then returns every single page. Not good!

While searching for yet another alternative, I was overjoyed yesterday to stumble across your site and was excited to see your updates/modifications to the project. I'm not that conversant with WHM and am not sure exactly what software is running on my VPS. I installed Sphider 2.0.0 but it didn't work, so I assume my configuartion doesn't support MySQLi WITH MySQLnd. I then installed Sphider 2.0.0a-PDO and it installed fine, so I presume the prerequisites have been met.

After updating the settings, I ran 'Start Indexing' and get:

Parse error: syntax error, unexpected '[', expecting ',' or ';' in /home/foo/public_html/sphider-2.0.0a-PDO/admin/spider.php on line 235

I'm no wizard on PHP. I've attached a snippet from my spider.php file just in case there's a syntax error there.

Also attached is a screen dump of my settings; perhaps I've configured something wrong?

I SO want this to work - any advice would be greatly appreciated. :)

Thank you in advance.


Re: Sphider-2.0.0a-PDO - parse error when indexing

Posted: Wed Feb 21, 2018 3:55 am
by captquirk
There is indeed a syntax error in spider.php.

Edit line 235 to read:
echo "Statement failed : ".$error[2];

I will be making the change to the download files asap. This particular section of code should execute ONLY if an SQL statement failed. I would like to see your corresponding log file.

Thank you for catching and reporting this problem.

Change lines 229 and 270 to read:
$stmt->bindParam(1, $site_id, PDO::PARAM_INT);

The ", PDO::PARAM_INT" is missing from both lines. These both concern a table update when the usesitemap is set but there is no valid map. The missing code was causing the statements to fail. If the usesitemap switch was already off, or if it was on but the map is valid and usable, the code would not try to execute, so this is an unusual situation. Still, a problem which needed fixing.

The SQLite and PostgreSQL versions were also affected. Revised code has already been uploaded.

Re: Sphider-2.0.0a-PDO - parse error when indexing

Posted: Thu Feb 22, 2018 12:37 am
by Webbo
Hi captquirk

Thank you for your response and the revised code update uploaded to worldspaceflight's site.

I downloaded the revised version from the site and did a complete new install, rather than editing spider.php; so unfortunately don't have the log file from my initial failed install. (I presume this was the log file you're referring to, as opposed to the the (now) successful one?)

Sphider-2.0.0b-PDO installed perfectly and indexed without a glitch. Thank you greatly for your help.

Could I kindly ask a further favour? The original (sparse) Sphider documentation didn't expand on customising templates. Can you please advise which file(s) (and where) I should edit to change templates? "Illustration 31: Image Search results" - page 42 - in your user guide shows exactly what I'm looking to achieve, although I fear I may have to rename all my images/get my finger out and "alt-tag" them all, as I get zero results when I do an image search! When I hover over a link - I get a 'pop-up' preview of the webpage (rather than just the image). :-(

Thank you again for the sterling updating work you've done on Sphider. If I can't get any further than this, I'll still be one happy bunny!

Kind regards


Re: Sphider-2.0.0a-PDO - parse error when indexing

Posted: Thu Feb 22, 2018 3:23 am
by captquirk
Some personal stuff going on right now, but I will address the customization of templates probably this weekend.

Glad the parse issue is resolved and thank you for reporting it. I TRY to test all scenarios, but there are just so many variations. When someone catches something I didn't, it just makes Sphider better.

Re: Sphider-2.0.0a-PDO - parse error when indexing

Posted: Sun Feb 25, 2018 3:58 am
by captquirk
There actually seems to be two separate issues here. One is how to create a new template. The other issue is being unable to get any results when searching images.
When I hover over a link - I get a 'pop-up' preview of the webpage (rather than just the image).
If you are getting a page preview, that indicates to me you have done a normal "Search" (first tab) and not an "Image Search" (third tab). The normal "Search" only looks for text content and will show a preview of the relevant page, provided you have selected "preview" in the settings.

When using the "Image Search", a thumbnail of any images found will be displayed, if possible. The code will automatically make the determination as to whether or not thumbnails can be displayed. Your host must have the "imagick" module installed to display the thumbnails. If that module is missing, the search results will be displayed without thumbnails. If an "Image Search" returns results WITHOUT thumnail previews, then the imagick module is either not installed or not functioning. If that is the case, check with your hosting company.

To verify that images are indeed present in the database, from the admin panel to to the "Database" tab. The row count for "(database prefix)images" should be non-zero. It the row count is zero, images have not been indexed. This can be due to having the option to index images unset in settings. Or, if the option is checked, but the sites robots.txt prohibits index imaging, images will be bypassed unless you choose to ignore the robots.txt file at the time of indexing. Looking at the log file for the latest index will report if image indexing is on, and whether or not an image actually is indexed. If any image is found but not indexed, there should be a notation saying forbidden by robots.txt.

Doing an "Image Search" with a empty search box will return ALL images in the database. Image names and image urls will always populate. Alt tags will populate ONLY if the html tags for the image contains the "alt=" option. If the imagick module is installed, all returned images will have a size notated. If imagick is not installed, size will be notated IF the image html tags contain height and width options.

Creating new templates will be addressed in a new topic.