Note that there are some explanatory texts on larger screens.

plurals
  1. POHide code errors in php but still execute the rest of the page
    primarykey
    data
    text
    <p>I am hoping that someone can help me: I have this scripts that if a file does not exists on my server, it goes to a remote server to check for the file. If the file exists it copies it to my local server, and does not check it again. So the Imagick part only works when the image does not exists on my local server.</p> <p>The problem that I have is that if the file does not exists on the remote server - then the application throughs a error - Here is the code of my script:</p> <pre><code> &lt;?php if (file_exists($filename)) { echo '&lt;img src="'.$imageurl1.'" width="'.$g_sites_img1.'" alt="'.$imageurlmeta.'" class="image1" align="left" /&gt;'; } else { $imageurlfolder = dirname($filename); @mkdir($imageurlfolder, 0755, true); @copy($imgremoteurl, $filename); $thumb = new Imagick($filename); $thumb-&gt;scaleImage($g_sites_img1, 0); $thumb-&gt;writeImage($filename); $thumb-&gt;destroy(); }?&gt; </code></pre> <p>Here is the error code: </p> <pre><code>&gt; Fatal error: Uncaught exception &gt; 'ImagickException' with message &gt; 'Unable to read the file: &gt; /home/game1/public_html/images/small///.jpg' &gt; in &gt; /home/game1/public_html/includes/standard__1.php:15 &gt; Stack trace: #0 &gt; /home/game1/public_html/includes/standard__1.php(15): &gt; Imagick-&gt;__construct('/home/game1/pub...') &gt; #1 /home/game1/public_html/includes/news.php(127): &gt; require('/home/game1/pub...') #2 &gt; /home/game1/public_html/index1.php(126): &gt; include('/home/game1/pub...') #3 &gt; {main} thrown in &gt; /home/game1/public_html/includes/standard__1.php &gt; on line 15 </code></pre> <p>How can I avoid this error but still make the page load normally?</p> <p>I have tried error_reporting(0); &lt;--- This stops the page from completely loading once the error has occured.</p> <p>Any ideas would be appreciated.</p> <p>I have found the solution with all the answers posted! thanks a million</p> <pre><code>&lt;?php if(file_exists($filename)) </code></pre> <p>{ echo ''; } else { try {$imageurlfolder = dirname($filename); @mkdir($imageurlfolder, 0755, true); @copy($imgremoteurl, $filename); $thumb = new Imagick($filename); $thumb->scaleImage($g_sites_img1, 0); $thumb->writeImage($filename); $thumb->destroy();} catch (ImagickException $e) { echo "Exception caught!\n"; } } ?></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload