"The website declined to show this webpage" error

Hi,

I would be really grateful for any help anyone can give me with a error I am getting.

I have built a fairly simple cms using php, I say this as I am fairly new to php so may be causing an error through the coding of the cms.

However the site has been functioning fine for several months but the IT company who host the website have recently transferred their servers and since then, when using the cms the site has been throwing up a “The website declined to show this webpage” error.

This also seems to have the knock on effect of stopping the rest of the website functioning for several minutes, then the rest of the site comes back online.

I don’t know if this is relevant but this error is only caused by loading the php script in the cms on pc it doesn’t happen on a mac.

If anyone has any idea of what could be causing this error i’d be very grateful for any advice?

Did you ask your host?

well, they’ve said they’re not sure.

Apparently database, php version and permissions are the same.

I will double check permissions remain same as this is the only thing I can think would be causing the issue.

Otherwise I guess it would be something within the code that’s causing this?

Thanks for your response

Doing a quick search, this thread is the top hit. The next few hits simply say that the extention was missing or wrong. Double check that all files have the correct extension, and where applicable, a DOCTYPE.

as far as I can see - yes

Check your access and error logs, your answer with be there. :slight_smile:

Thanks very much for your reply - I am on to the host to give me access to those files.

Would i be able to post the code of the file that is throwing up this error message here to get an opinon if anything in it may be causing this issue?

Of course :slight_smile:
If you use ‘Go advanced’ instead of ‘Post quick reply’, you’ll be able to put the correct code tags around your code, which will make it easier to read.

thanks - have copied below: i’ve omitted the header url - the includes are just opening and closing the database connections and are definitely working fine as on all other areas of the site.



<?php // include db connect

ob_start();
header("Location:");
ob_flush();

?>

<?php // include db connect

include("../includes/config.php"); 

?>

<?php

// assign news to variables

$name=$_POST['name'];
$location=$_POST['location'];
$property_type=$_POST['property_type'];
$prices_from=$_POST['prices_from'];
$prices_to=$_POST['prices_to'];
$information=$_POST['information'];
$information_plus=$_POST['information_plus'];
$information_plus_string = str_replace("&#160;","",$information_plus);
$info_list=$_POST['info_list'];
$info_table=$_POST['info_table'];
$facilities=$_POST['facilities'];
$display=$_POST['display'];
$primary_key=$_POST['primary_key'];
$highlight=$_POST['highlight'];

$bar=$_POST['bar'];
$beach=$_POST['beach'];
$golf=$_POST['golf'];
$shopping=$_POST['shopping'];
$restaurant=$_POST['restaurant'];
$spa=$_POST['spa'];
$sports=$_POST['sports'];
$gardens=$_POST['gardens'];
$watersports=$_POST['watersports'];
$gym=$_POST['gym'];
$swimming=$_POST['swimming'];

$inftab_prop1=$_POST['inftab_prop1'];
$inftab_prop2=$_POST['inftab_prop2'];
$inftab_prop3=$_POST['inftab_prop3'];
$inftab_prop4=$_POST['inftab_prop4'];
$inftab_prop5=$_POST['inftab_prop5'];
$inftab_prop6=$_POST['inftab_prop6'];

$inftab_price1=$_POST['inftab_price1'];
$inftab_price2=$_POST['inftab_price2'];
$inftab_price3=$_POST['inftab_price3'];
$inftab_price4=$_POST['inftab_price4'];
$inftab_price5=$_POST['inftab_price5'];
$inftab_price6=$_POST['inftab_price6'];

// insert news from form

mysql_query("UPDATE investment_property SET name = '$name'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET location = '$location'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET prices_from = '$prices_from'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET prices_to = '$prices_to'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET information = '$information'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET information_plus = '$information_plus_string'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET info_list = '$info_list'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET info_table = '$info_table'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET facilities = '$facilities'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET display = '$display'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET bar = '$bar'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET beach = '$beach'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET golf = '$golf'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET shopping = '$shopping'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET restaurant = '$restaurant'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET spa = '$spa'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET sports = '$sports'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET gardens = '$gardens'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET watersports = '$watersports'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET gym = '$gym'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET swimming = '$swimming'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET highlight = '$highlight'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property SET property_type = '$property_type'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property 
SET inftab_prop1 = '$inftab_prop1'
, inftab_prop2 = '$inftab_prop2'
, inftab_prop3 = '$inftab_prop3'
, inftab_prop4 = '$inftab_prop4'
, inftab_prop5 = '$inftab_prop5'
, inftab_prop6 = '$inftab_prop6'
WHERE primary_key = '$primary_key'");

mysql_query("UPDATE investment_property 
SET inftab_price1 = '$inftab_price1' 
, inftab_price2 = '$inftab_price2'
, inftab_price3 = '$inftab_price3'
, inftab_price4 = '$inftab_price4'
, inftab_price5 = '$inftab_price5'
, inftab_price6 = '$inftab_price6'
WHERE primary_key = '$primary_key'");

?>

<?php // close db connection

include("close_connect.php"); 

?>


I would suspect the ~25 MySQL queries will have something to do with it. :stuck_out_tongue:

Thanks for your reply Anthony, I’m sure this code is fairly ineloquent, i’ll try and combine these queries and post back - is this the likely cause then do you think?

It certainly won’t be helping. :slight_smile:

For reference, you can update many columns with a single query like so…


UPDATE
  table
SET
    foo = 1
  , bar = 2
  , anthony = 'tired'
  , coffee = 'empty'
WHERE
  id = 45

thanks for that have revised script below:

<?php // include db connect

ob_start();
header("Location: *** ");
ob_flush();

?>

<?php // include db connect

include("../includes/config.php"); 

?>

<?php

// assign news to variables

$name=$_POST['name'];
$location=$_POST['location'];
$property_type=$_POST['property_type'];
$prices_from=$_POST['prices_from'];
$prices_to=$_POST['prices_to'];
$information=$_POST['information'];
$information_plus=$_POST['information_plus'];
$information_plus_string = str_replace("&#160;","",$information_plus);
$info_list=$_POST['info_list'];
$info_table=$_POST['info_table'];
$facilities=$_POST['facilities'];
$display=$_POST['display'];
$primary_key=$_POST['primary_key'];
$highlight=$_POST['highlight'];

$bar=$_POST['bar'];
$beach=$_POST['beach'];
$golf=$_POST['golf'];
$shopping=$_POST['shopping'];
$restaurant=$_POST['restaurant'];
$spa=$_POST['spa'];
$sports=$_POST['sports'];
$gardens=$_POST['gardens'];
$watersports=$_POST['watersports'];
$gym=$_POST['gym'];
$swimming=$_POST['swimming'];

$inftab_prop1=$_POST['inftab_prop1'];
$inftab_prop2=$_POST['inftab_prop2'];
$inftab_prop3=$_POST['inftab_prop3'];
$inftab_prop4=$_POST['inftab_prop4'];
$inftab_prop5=$_POST['inftab_prop5'];
$inftab_prop6=$_POST['inftab_prop6'];

$inftab_price1=$_POST['inftab_price1'];
$inftab_price2=$_POST['inftab_price2'];
$inftab_price3=$_POST['inftab_price3'];
$inftab_price4=$_POST['inftab_price4'];
$inftab_price5=$_POST['inftab_price5'];
$inftab_price6=$_POST['inftab_price6'];

// insert news from form

mysql_query("UPDATE second_homes 
SET inftab_prop1 = '$inftab_prop1'
, inftab_prop2 = '$inftab_prop2'
, inftab_prop3 = '$inftab_prop3'
, inftab_prop4 = '$inftab_prop4'
, inftab_prop5 = '$inftab_prop5'
, inftab_prop6 = '$inftab_prop6'
, inftab_price1 = '$inftab_price1' 
, inftab_price2 = '$inftab_price2'
, inftab_price3 = '$inftab_price3'
, inftab_price4 = '$inftab_price4'
, inftab_price5 = '$inftab_price5'
, inftab_price6 = '$inftab_price6'
, property_type = '$property_type'
, highlight = '$highlight'
, swimming = '$swimming'
, gym = '$gym'
, watersports = '$watersports'
, gardens = '$gardens'
, sports = '$sports'
, spa = '$spa'
, restaurant = '$restaurant'
, shopping = '$shopping'
, golf = '$golf'
, beach = '$beach'
, bar = '$bar'
, display = '$display'
, facilities = '$facilities'
, info_table = '$info_table'
, info_list = '$info_list'
, information_plus = '$information_plus_string'
, information = '$information'
, prices_to = '$prices_to'
, prices_from = '$prices_from'
, location = '$location'
, name = '$name'
WHERE primary_key = '$primary_key'");


?>

<?php // close db connection

include("close_connect.php"); 

?>

So, does it work? :slight_smile:

nope still no joy - the IT company dealing with it are saying it may be an issue with their servers/setup and to leave it with them.

I’m just trying to make sure it’s not an issue i’ve caused though, as long as there’s nothing in that script that’s unusual i’ll wait for them I guess - will update when I know more

Well, if that code is actually your code (as opposed to a *******ised version), I’m a little confused as to why the header call is there…

Can you elaborate?

I’m going to guess you want to update the database then forward the user onto another page?

Yes it is mine. But as I say i’m still learning.

That’s right though, the idea is to update the database, then return you to a list of editable properties.

Is there a more appropriate way of doing this?

thanks

Try this…


<?php
error_reporting(-1);
ini_set('display_errors', true);

require_once '../includes/config.php';

$_POST = array_map(
  'mysql_real_escape_string',
  $_POST
);


$name=$_POST['name'];
$location=$_POST['location'];
$property_type=$_POST['property_type'];
$prices_from=$_POST['prices_from'];
$prices_to=$_POST['prices_to'];
$information=$_POST['information'];
$information_plus=$_POST['information_plus'];
$information_plus_string = str_replace(" ","",$information_plus);
$info_list=$_POST['info_list'];
$info_table=$_POST['info_table'];
$facilities=$_POST['facilities'];
$display=$_POST['display'];
$primary_key=$_POST['primary_key'];
$highlight=$_POST['highlight'];

$bar=$_POST['bar'];
$beach=$_POST['beach'];
$golf=$_POST['golf'];
$shopping=$_POST['shopping'];
$restaurant=$_POST['restaurant'];
$spa=$_POST['spa'];
$sports=$_POST['sports'];
$gardens=$_POST['gardens'];
$watersports=$_POST['watersports'];
$gym=$_POST['gym'];
$swimming=$_POST['swimming'];

$inftab_prop1=$_POST['inftab_prop1'];
$inftab_prop2=$_POST['inftab_prop2'];
$inftab_prop3=$_POST['inftab_prop3'];
$inftab_prop4=$_POST['inftab_prop4'];
$inftab_prop5=$_POST['inftab_prop5'];
$inftab_prop6=$_POST['inftab_prop6'];

$inftab_price1=$_POST['inftab_price1'];
$inftab_price2=$_POST['inftab_price2'];
$inftab_price3=$_POST['inftab_price3'];
$inftab_price4=$_POST['inftab_price4'];
$inftab_price5=$_POST['inftab_price5'];
$inftab_price6=$_POST['inftab_price6'];

// insert news from form

$res = mysql_query("UPDATE second_homes 
SET inftab_prop1 = '$inftab_prop1'
, inftab_prop2 = '$inftab_prop2'
, inftab_prop3 = '$inftab_prop3'
, inftab_prop4 = '$inftab_prop4'
, inftab_prop5 = '$inftab_prop5'
, inftab_prop6 = '$inftab_prop6'
, inftab_price1 = '$inftab_price1' 
, inftab_price2 = '$inftab_price2'
, inftab_price3 = '$inftab_price3'
, inftab_price4 = '$inftab_price4'
, inftab_price5 = '$inftab_price5'
, inftab_price6 = '$inftab_price6'
, property_type = '$property_type'
, highlight = '$highlight'
, swimming = '$swimming'
, gym = '$gym'
, watersports = '$watersports'
, gardens = '$gardens'
, sports = '$sports'
, spa = '$spa'
, restaurant = '$restaurant'
, shopping = '$shopping'
, golf = '$golf'
, beach = '$beach'
, bar = '$bar'
, display = '$display'
, facilities = '$facilities'
, info_table = '$info_table'
, info_list = '$info_list'
, information_plus = '$information_plus_string'
, information = '$information'
, prices_to = '$prices_to'
, prices_from = '$prices_from'
, location = '$location'
, name = '$name'
WHERE primary_key = '$primary_key'");

if(false === $res){
  echo 'Update query failed: ' . mysql_error();
  exit;
}

require_once 'close_connect.php';

header('Location: http://www.yahoo.co.uk/');
exit;

What do you get?

Does that only perform the query if it contains no errors?

I have run it, I get the same error:

Forbidden

You don’t have permission to access /cms/second_homes_edit.php on this server.

followed by a period of 2-3 minutes where the server will not show any of the site pages or let me connect via ftp.

Can you post the content of config.php please? Feel free to obscure any credentials, but do try to keep it ‘as-is’.

:slight_smile:

Also, is second_homes_edit.php the script we’ve been discussing?