Jump to content

PHP Warning: file_exists() expects parameter 1 to be string, array given


damion

Recommended Posts

PHP Warning:  file_exists() expects parameter 1 to be string, array given in /home/mysite/public_html/display.mysite.com/wp-content/themes/mytheme/form.php on line 9

PHP Warning:  file_exists() expects parameter 1 to be string, array given in /home/mysite/public_html/display.mysite.com/wp-content/themes/mytheme/form.php on line 13

I have a form that is having some issues and in the error log I see a bunch of these warnings. What is wrong with this??

 

I numbered the offending lines below (lines 9 & 13)

 

Thanks for any help on this.

function CheckExistance($VUrl)

{

/*9*/    if ( file_exists($VUrl) )

        echo $VUrl;

/*13*/    elseif ( file_exists(str_replace('www.display.mysite.com','www.display.com', $VUrl)) )

        echo str_replace('www.display.mysite.com','www.mysite.com', $VUrl);

    else

        echo str_replace('www.mysite.com','www.display.mysite.com', $VUrl);

}

What's wrong is that $VUrl is an array and not the string you're expecting it to be. Start looking at whatever calls the CheckExistance function to see why that is and what you should do to fix it.

It seems that CheckExistaisance is a thumbnail and the larger version image. It is an array, correct?

<td><a href="<?php CheckExistance(get_field('image')); ?>" rel="lightbox" title="<?php echo the_title(); ?>"><img src="<?php CheckExistance(get_field('thumbnail')); ?>"></a></td>

The million dollar question is, how do you fix that?

 

 

Thanks.

get_field('thumbnail') returned an array. Apparently that's because the thumbnail is some sort of array "type".

 

So that's the next place for you to start looking. Why is it an array? Have you considered outputting that value to see what it contains? Maybe it's supposed to be an array and you're supposed to get a specific value from it.

Try assigning the return value of the function to a variable, then dump that.

$thumb  = get_field('thumbnail');
print("<pre>".print_r($thumb,true)."</pre>");
die();

That should show you what you're dealing with, assuming get_field() is returning anything.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.