Receiving this upon run:

Warning: mysql_connect(): Host 'srv26.main-hosting.com' is blocked because of many 
connection errors; unblock with 'mysqladmin flush-hosts' in 
/home/u871385583/public_html/ob_re4.php on line 32 NEIN! Host 
'srv26.main-hosting.com' is blocked because of many connection errors; 
unblock with 'mysqladmin flush-hosts'

I am not sure about how to go about flushing the host, as the host is remote (Not my own server).

I am using MySQLAdmin - Am I to do this from within MySQLAdmin? How?

Any advice would be greatly appreciated.

Thank you in advance,
Matthew

I can't find anything in the code to help you flush. I think you better contact your host and find out what's causing the issue. Perhaps you have an error log with some more information.

From what I've read it can be caused when you are not closing your connections properly.

You would have to log in to the server via ssh and issue the command as the mysql root user. I would contact the hosting company and tell them you are getting the error and have them look into it.

This is the current code on the new server that is throwing the connection error:

<?php
ob_start();
?>

<html>
<body>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Employee Name</td>
<td><input name="emp_name" type="text" id="emp_name"></td>
</tr>
<tr>
<td width="100">Employee Address</td>
<td><input name="emp_address" type="text" id="emp_address"></td>
</tr>
<tr>

<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="add" type="submit" id="add" value="Add Employee">
</td>
</tr>
</table>
</form>

<?php
$con = mysql_connect("server26.grendelhosting.com","u871385583_*", "*********");
if (!$con)
  {
  die('NEIN! ' . mysql_error());
  }
//Connect to DB

$res = mysql_query("SHOW DATABASES");

while ($row = mysql_fetch_assoc($res)) {
    echo $row['Database'] . "\n";
}
mysql_select_db(u871385583_*, $con)
or die("Lost");
//Detect DB

$sql="INSERT INTO tab3(emp_name, emp_address)
VALUES
('$_POST[emp_name]','$_POST[emp_address]')";

if (!mysql_query($sql,$con))
  {
  die('Error:' . mysql_error());
  }
//Add entry to DB
?>

<?php
$redirect_page = 'www.bridlepath2.grn.cc/index1.php';
$redirect = true;

if ($redirect == true AND !empty($_POST)) {
    header("Location:$redirect_page");
}

ob_end_flush();
?>

It's good practice to close mysql result sets and close the connection when you no longer need it. Example here.

Have you tried one of the other php mysql libraries, such as the mysqli class? I have had good results with that connecting to remote servers. Here is some code, the class I use to connect with mysql servers from my php applications:

<?php

// php_flag register_globals on
// Some includes here.

/**
 * Encapsulates the mysql connection to the application database.
 * @author zippy
 * @version 1.0
 * @updated 23-Sep-2013 3:56:25 PM
 */

class MyAppDbConnection
{

    private $m_DbHost = NULL;
    private $m_DbPort = NULL;
    private $m_DbName = NULL;
    private $m_DbUser = NULL;
    private $m_DbPassword = NULL;
    private $m_DbConn = NULL;


    /**
     * 
     * @param host
     * @param port
     * @param dbname
     * @param dbuser
     * @param dbpass
     */
    public function __construct($host = "localhost", $port = 3306, $dbname = "whatever", $dbuser = "zippy", $dbpass = "")
    {
        if (is_null($this->m_DbHost))
        {
            $this->m_DbHost = new String('p:'.$host);
            $this->m_DbPort = (int)$port;
            $this->m_DbName = new String($dbname);
            $this->m_DbUser = new String($dbuser);
            $this->m_DbPassword = new String($dbpass);
        }
    }

    public function __destruct()
    {
    }

    public function connect()
    {
        if (is_null($this->m_DbConn))
        {
//            print 'Connecting to MySql<br/>';
            $this->m_DbConn = new mysqli($this->m_DbHost . ':' . $this->m_DbPort,
                                        $this->m_DbUser,
                                        $this->m_DbPassword,
                                        $this->m_DbName);
            if ($this->m_DbConn->connect_errno)
            {
                print 'Unable to connect to MySql: ' . $this->m_DbConn->connect_error . '<br/>';
            }
            else
            {
                print 'Connected to MySql<br/>';
            }
        }
    }

    public function disconnect()
    {
        $this->m_DbConn = NULL;
    }

    public function fetch(String $stmt)
    {
        return $this->m_DbConn->query($stmt);
    }

    public function prepare(String $stmt)
    {
        return $this->m_DbConn->prepare($stmt);
    }
}
?>

Note that I do build my php from source and include the --with-mysqli option with the configure command. Depending upon the version of php you are using (I am using 5.5.4), mysqli may not be built into the normal distribution, so it may have to be specified in one of the php configuration files (such as /etc/php.ini or /etc/php.d/mysqli.ini) to dynamically link it into the code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.