0
I’m getting this message over and over again :
Error when establishing a connection to the Database
I read some articles about this problem and always the solution that indicate is to check the WP-config file and check if the Mysql username and password are correct, and are correct.
Is there any other way to check what might be overloading Mysql?
In my theme in the index.php file, I added the code below:
<?php echo catch_that_image(25, 14) ?>
and in the Function.php file this other:
function catch_that_image($w, $h) {
global $post, $posts;
$first_img = '';
$new_img_tag = "";
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image with 0 width
$new_img_tag = "<img src='/images/noimage.jpg' width='0px' class='' />";
}
else{
$new_img_tag = '<img alt=" - ' . $post->post_title . ' - " title="' . $post->post_title . '" src="' . $first_img . '" width="' . $w . '" height="' . $h . '" class="" />';
}
return $new_img_tag;
}
This code is to call images hosted outside wordpress and shows them in the theme.
This code may be related to Mysql error?
Make sure the mysql user and password are correct.
– rray
I’ve checked and they’re correct
– Endou
You could paste the error and the connection code into the post?
– StillBuggin
I edited the question look there
– Endou
I attached an image with error
– Endou
Check that the Mysql server is active and connected, for example using
service mysqld status
, if you have access to the SSH of the Mysql server or usemysql -h 111.222.333.444 -p -u Usuario DB
– Inkeliz
are staying in the same accommodation?
– Michel Simões