Warning: strpos(): Empty needle
Permalink
Hi fellows,
I am moving a site to a new server and all worked well but for the images: on the front end
I get Image Not Found errors, and also in some places I get an additional php error:
Warning: strpos(): Empty needle in /home/room66/public_html/room66.at/packages/image_blank_target/blocks/image/templates/blank_target.php on line 6
When I am logged in the file thumbnails show alright in the fila manager, but when I view some files the image is not there. When I copy the image url directly into my browser I get a page not found error.
I can access and view my file on ftp though, it is in the right place.
Not sure what i can do about this? All help appreciated
I am moving a site to a new server and all worked well but for the images: on the front end
I get Image Not Found errors, and also in some places I get an additional php error:
Warning: strpos(): Empty needle in /home/room66/public_html/room66.at/packages/image_blank_target/blocks/image/templates/blank_target.php on line 6
When I am logged in the file thumbnails show alright in the fila manager, but when I view some files the image is not there. When I copy the image url directly into my browser I get a page not found error.
I can access and view my file on ftp though, it is in the right place.
Not sure what i can do about this? All help appreciated
Hi MrKDilkington,
thxs for replying!
I am no good at php, but the file looks like this:
line 6 being the one if(strpos ... ) etc
It looks exactly the same as the file on the old server, where I do not get any error messages.
thxs for replying!
I am no good at php, but the file looks like this:
<?php defined('C5_EXECUTE') or die("Access Denied."); $image = $controller->getContentAndGenerate(); if(strpos("<a href=", $image) !== -1){ $image = str_replace('<a href=', '<a target="_blank" href=', $image); } echo($image); ?>
line 6 being the one if(strpos ... ) etc
It looks exactly the same as the file on the old server, where I do not get any error messages.
@rritz
It could be that $image doesn't have a value.
Here is the PHP documentation for the strpos() function.
http://php.net/strpos
"Returns the position of where the needle exists relative to the beginning of the haystack string (independent of offset). Also note that string positions start at 0, and not 1.
Returns FALSE if the needle was not found."
I am not sure why "!== -1" is used. I don't believe strpos() will ever return -1, only false, 0, or 1 or greater.
It could be that $image doesn't have a value.
Here is the PHP documentation for the strpos() function.
http://php.net/strpos
"Returns the position of where the needle exists relative to the beginning of the haystack string (independent of offset). Also note that string positions start at 0, and not 1.
Returns FALSE if the needle was not found."
I am not sure why "!== -1" is used. I don't believe strpos() will ever return -1, only false, 0, or 1 or greater.
Hi, I think that was the cause of the error. I thought that if the $image varable is empty or not set this must mean the file cannot be found where it's supposed to be.
I re-uploaded my files several times over and now they get found and no php error. Maybe the uploaded files were corrupted at first. Then the blank target block tried to set or read $image but since the file wasn't there on the server it rendered an error.
Thxs so much for your help!!
I re-uploaded my files several times over and now they get found and no php error. Maybe the uploaded files were corrupted at first. Then the blank target block tried to set or read $image but since the file wasn't there on the server it rendered an error.
Thxs so much for your help!!
Did you inspect line 6 of blank_target.php for the incomplete strpos() function?