Ignore Error

Hi how I can add an ignore error to part of a script without effecting the remainder of script:

section of code (search function) I want to ignore the error (this is located in a single php file without any other code):

[php]<?php
require (“pmx-includes/inc-connection-common.php” );
?>
Property Search





<?php if ($pm_display_search_types == "Y") { ?>
Property

Any Property
<?php

$rows = $sql->execute (“SELECT * FROM “.$pmx_type_table.” ORDER BY property_type_name ASC”, SQL_RETURN_ASSOC );
for ( $i = 0; $i < sizeof ( $rows ); ++$i )

{
  $row = $rows [ $i ];
  ?>
            <option value="<?php echo $cgi->htmlEncode ( $row [ "id" ] ); ?>"><?php echo $cgi->htmlEncode ( $row [ "property_type_name" ] ); ?></option>
            <?php  } ?>
        </select>
        </strong></strong></label>
        <?php } ?>
        <?php if ($pm_display_search_max_price == "Y") { ?>
        <label> <span>Max Price</span> <strong class="select1">
          <select name="pmax" style="padding:5px;width:165px;">
            <option value="">Any Price</option>
            <?php  include ("pmx-includes/inc-price-rentals-max.txt"); ?>
          </select>
      </strong> </label>
        
        <?php } ?>
        <?php if ($pm_display_search_locations == "Y") { ?>
        <label> <span>Location</span><strong class="select1">
          <select name="pl" style="padding:5px;width:165px;">
            <option value="">Any Location</option>
            <?php 

$rows = $sql->execute ( "SELECT * FROM ".$pmx_location_table." ORDER BY property_location_name ASC", SQL_RETURN_ASSOC );
for ( $i = 0; $i < sizeof ( $rows ); ++$i )

{
  $row = $rows [ $i ];

  ?>
            <option value="<?php echo $cgi->htmlEncode ( $row [ "id" ] ); ?>"><?php echo $cgi->htmlEncode ( $row [ "property_location_name" ] ); ?></option>
            <?php } ?>
          </select>
        </strong></label>
        <?php } ?>
      <label><span>Postcode</span>
          <input type="text" name="pc" placeholder="Full or part off postcode" />
      </label>
      <p align="right">
        <input type="submit" value="Property Search" class="button-1" />
      </p>
    </form>[/php]

The error code I wish to ignore which is included inside the config file for the script:

[php]$DatabaseError = “

We are currently experiencing an issue on our website property search. Please try again later.



”;[/php]

I need to ignore the error on this (search function) only as it is located on the index page of website causing the page not to load when there is a database issue, I don’t want to loose the functionality of the error code on the back-end of the script as it is doing what it is supposed to and displays the message as required.

Thank you in advance for your help :smiley:

It is extremely bad coding practice to ignore errors, you should handle errors, not ignore them.

That beeing said you can use the @ operator to suppress errors
http://php.net/manual/en/language.operators.errorcontrol.php

I only wish to stop the error for the search function which is added to website front page as <?php include 'property_search.php'; ?> it has the detrimental effect of stopping the website loading upon database error, the error function works fine in the main script causing no issues and just displays the error message.

using the @ suppress error, how would I control the error for the specific property search php include file?

Many thanks

Sponsor our Newsletter | Privacy Policy | Terms of Service