Further to checking the content of the table I have found that my page has entered some data into the table. The full script I am using is below:
<?php
//define array of colours
$table_colour = array('red', 'orange', 'yellow', 'green', 'blue', 'purple', 'brown', 'grey', 'pink');
//loop through array of colours
foreach($table_colour as $colour) {
//define array of row letters
$rows = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
//define starting pixels from top of screen
$y_px = 0;
//loop through array of rows
foreach($rows as $letters) {
//define starting pixels from left of screen
$x_px = 0;
//loop through 50 columns
for($c = 1; $c <= 50; $c++) {
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "password";
$db = "tpd";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "INSERT INTO tblGrids (colour, row, col, x, y) VALUES ('$colour', '$letters', $c, $x_px, $y_px)";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// free result set memory
mysql_free_result($result);
// close connection
mysql_close($connection);
//echo "colour - $colour, row - $letters, col - $c, x - $x_px, y - $y_px <br>";
//increment value for x pixels
$x_px = $x_px + 18;
}
//increment value for y pixels
$y_px = $y_px + 22;
}
}
?>
Checking the table content has shown that the above script has successfuly entered 3962 of the records but then it fails to connect, is there a maximum number of connections or entries at one time?