"The website declined to show this webpage" error

thanks for taking the time to help with this, yes that is the script we’re discussing.

config and close_connect copied below:

config:


<?php

$con = mysql_connect("localhost","****","****");
mysql_select_db("****", $con);

?>

close_connect:


<?php // close connection

mysql_close();

?>

Ok then, lets take this back to basics.

Edit second_homes_edit.php, add the following code only, upload it and browse to it in your browser.

<?php echo phpversion(); ?>

Don’t use a form, just the via a url.

What do you get?

same error - I can check php version on plesk as have been given access details - could this be linked to php version?

No, no.

We were just testing to see if your server is parsing simple PHP files, and it appears it is not.

So yeah, it’s a server config issue. :slight_smile:

my mistake - didn’t upload file properly.

returns:

5.2.13

Ah ah, good. :slight_smile:

So, next step then.

Place the following in the script, edit the $database settings (hostname, username, password, schema) at the top accordingly and upload.


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

/*
  Edit these
*/
$database = array(
  'hostname'  => 'localhost',
  'username'  => 'anthony',
  'password'  => 'super-secret',
  'schema'    => 'my_cms'
);

$conn = mysql_connect(
  $database['hostname'],
  $database['username'],
  $database['password']
);

if(false === is_resource($conn)){
  echo 'Cannot connect to database: ' . mysql_error() ;
  exit;
}

if(false === mysql_select_db($database['schema'], $conn)){
  echo 'Cannot select schema: ' . mysql_error() ;
  exit;
}
?>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>
      Connected successfully!
    </h1>
    <p>
      <?php printf("MySQL server version: &#37;s", mysql_get_server_info($conn)); ?>
    </p>
  </body>
</html>

What do we get now?

it doesn’t seem to be returning anything

Are you using ‘localhost’ as the hostname? If so, try changing it to ‘127.0.0.1’ and give that a go.

Very strange.

afraid i’m still not getting anything…

You’re still getting a denied message?

If it hasn’t beaten you into submission yet, can you post the output of this script please?


<?php
error_reporting(-1);
ini_set('display_errors', true);
?>
<h3>
  Available extensions
</h3>
<ul>
  <?php foreach(get_loaded_extensions() as $extension): ?>
    <li>
      <?php echo $extension; ?>
    </li>
  <?php endforeach; ?>
</ul>

ha , I probably would have been but I need to try and work out if the issue lays at our door or if it’s the IT company who need to fix something.

Like I say - very grateful for your help on this.

This is what the script outputs:

Available extensions

* date
* libxml
* openssl
* pcre
* zlib
* bz2
* calendar
* ctype
* hash
* filter
* ftp
* gettext
* gmp
* session
* iconv
* pcntl
* readline
* Reflection
* standard
* shmop
* SimpleXML
* SPL
* sockets
* exif
* tokenizer
* xml
* cgi-fcgi
* imagick
* bcmath
* curl
* dbase
* dom
* gd
* imap
* json
* mbstring
* mcrypt
* mysql
* mysqli
* PDO
* pdo_mysql
* pdo_sqlite
* soap
* SQLite
* wddx
* xmlreader
* xmlwriter
* xsl
* zip
* ionCube Loader
* Zend Optimizer

Ok, let’s try using MySQLi then instead as a last ditch attempt. :smiley:


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

/*
  Edit these
*/
$database = array(
  'hostname'  => 'localhost',
  'username'  => 'anthony',
  'password'  => 'super-secret',
  'schema'    => 'my_cms'
);

$conn = mysqli_connect(
  $database['hostname'],
  $database['username'],
  $database['password'],
  $database['schema']
);

if(false === ($conn instanceof MySQLi)){
  echo 'Cannot connect to database: ' . mysqli_connect_error() ;
  exit;
}
?>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <h1>
      Connected successfully!
    </h1>
    <p>
      <?php printf('MySQL server version: &#37;s', mysqli_get_server_info($conn)); ?>
    </p>
  </body>
</html>

urgh - getting :

Warning: mysqli_connect() [function.mysqli-connect]: (28000/1045): Access denied for user ''@‘localhost’ (using password: YES) in /data/www/vhosts////second_homes_edit.php on line 20
Cannot connect to database: Access denied for user ‘***’@‘localhost’ (using password: YES)

same password etc as else where, I don’t use the schema in the other config file though

Yay, this is good - progress… Kinda. :stuck_out_tongue:

So, you’re saying the host, username, password and schema that you’re using are definitely correct? The error message suggests otherwise.

Anthony.

everything apart from the schema is definitely ok.

The schema I assume is essentially the db name, which if it is - should be correct…

Sorry to ask for clarification on this but wanting to be certain

Are you saying you can connect successfully, with the same credentials, using a different script? Yeah, the schema is database name.

well… yes. The front end still works fine and the content of the front end is all
content generated from the database.

All the files essentially start with this include:


<?php

$con = mysql_connect("localhost","***","***");
mysql_select_db("***", $con);

?>

What’s even stranger is that I can still edit certain other things through the cms

Then I have no idea, I’m out. :wink:

Maybe another member can help and/or offer some more advice?

great no problem - your help and advice was much appreciated.

I think the problem here is with coniguration of the database. I will let you know once concluded - hopefully soon ; )

cali make a new file, have it only have as its contents.


<?php

$link = mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');

if (!$link) {
    die('Connect Error: ' . mysqli_connect_error());
}
?>