I have an Apache server, that connects to a MySQL database server. I get a lot of error messages saying:
PHP Warning: mysqli::mysqli(): (HY000/2003): Can't connect to MySQL server on '10.0.0.13'
But most of the time, there's no problem connecting, and I am able to telnet 10.0.0.13 3306
without problems. How do I figure out what the problem is?
The source is php scripts, and most of the time it runs without any problem. Here is how I connect:
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors','On');
date_default_timezone_set ('Europe/Copenhagen');
Header('Content-type: text/xml');
$conn = new mysqli('10.0.0.13','webuser', 'xxxxxx', "np_indexes");
Any suggestions?
Is this connection closed correct?
$sql = "call spGetOrderDepthBySymbol('$stock', 0)";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) { ?>
<row>
<type static="true"></type>
<shares flash="true"><?= $row['shares']<>"" ? number_format($row['shares'], 0, ',', '.') : '-' ?></shares>
<price flash="true"><?= $row['price']<>"" ? number_format($row['price'], 2, ',', '.') : '-' ?></price>
</row>
<? }
?>
<spacer static="true"></spacer>
<?
$conn->next_result();
$sql = "call spGetOrderDepthBySymbol('$stock', 1)";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) { ?>
<row>
<type static="true"></type>
<shares flash="true"><?= $row['shares']<>"" ? number_format($row['shares'], 0, ',', '.') : '-' ?></shares>
<price flash="true"><?= $row['price']<>"" ? number_format($row['price'], 2, ',', '.') : '-' ?></price>
</row>
<? }
mysql_close($result);
?>