I began hosting my website through a service that uses cpanel... I found creating a database, tables etc a headache, and all the worse using phpAdmin.
Coding I used when hosting my site on my own machine (Apache2.4, MySQL5.7, PHP7) that worked fine will not work now and I have spent MANY hours trying to figure this out... 2 scripts:
someform.html:
<html>
<form action="someform.php" method="post">
<p>A: <input type="text" name="A" autofocus /></p>
<p>B: <input type="text" name="B" autofocus /></p>
<p>C: <input type="text" name="C" autofocus /></p>
<p>D: <input type="text" name="D" autofocus /></p>
<p>E: <input type="text" name="E" autofocus /></p>
<p>F: <input type="text" name="F" autofocus /></p>
<p>G: <input type="text" name="G" autofocus /></p>
<p><input type="submit"></p>
</form>
</html>
someform.php:
<html>
<style>
table {
border-collapse: collapse;
width: 13.5%;
color: #588c7e;
font-family: monospace;
font-size: 25px;
text-align: center;
}
th {
background-color: #588c7e;
color: white;
}
tr:nth-child(even) {background-color: #f0f0e0}
</style>
</head>
<body>
<table>
<tr>
<th>A</th>
</tr>
</style></html>
<?php
$mysqli = new mysqli("localhost:3306","usrname","somepword","dbname");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
}
else {
echo "<tr align=center><font size=5 color=blue>Here are the results for:<br></tr>";
}
echo $_POST['A'] . ", ", $_POST['B'] . ", ", $_POST['C'] . ", ", $_POST['D'] . ", ", $_POST['E'] . ", ", $_POST['F'] . ", ", $_POST['G'] . ".";
$A = $_POST['A'];
$B = $_POST['B'];
$C = $_POST['C'];
$D = $_POST['D'];
$E = $_POST['E'];
$F = $_POST['F'];
$G = $_POST['G'];
/*This is important because... what if there is no combination of AB pairs that exists,
your loop will execute infinite*/
$limitNumber = 800;
$notFound = true;
for($i = 0; ($i < $limitNumber && $notFound); $i++){
for($j = 0; ($j < $limitNumber && $notFound); $j++){
for($k = 0; ($k < $limitNumber && $notFound); $k++){
$sql = "SELECT * FROM numbers where (A=$A AND B=$B AND C=$C) OR (
A=$A AND B=$B AND D=$D) OR (
A=$A AND B=$B AND E=$E) OR (
A=$A AND B=$B AND F=$F) OR (
A=$A AND B=$B AND G=$G) OR (
A=$A AND C=$C AND D=$D) OR (
A=$A AND C=$C AND E=$E) OR (
A=$A AND C=$C AND F=$F) OR (
A=$A AND C=$C AND G=$G) OR (
A=$A AND D=$D AND E=$E) OR (
A=$A AND D=$D AND F=$F) OR (
A=$A AND D=$D AND G=$G) OR (
A=$A AND E=$E AND F=$F) OR (
A=$A AND E=$E AND G=$G) OR (
A=$A AND F=$F AND G=$G) OR (
B=$B AND C=$C AND D=$D) OR (
B=$B AND C=$C AND E=$E) OR (
B=$B AND C=$C AND F=$F) OR (
B=$B AND C=$C AND G=$G) OR (
B=$B AND D=$D AND E=$E) OR (
B=$B AND D=$D AND F=$F) OR (
B=$B AND D=$D AND G=$G) OR (
B=$B AND E=$E AND F=$F) OR (
B=$B AND E=$E AND G=$G) OR (
B=$B AND F=$F AND G=$G) OR (
C=$C AND D=$D AND E=$E) OR (
C=$C AND D=$D AND F=$F) OR (
C=$C AND D=$D AND G=$G) OR (
C=$C AND E=$E AND F=$F) OR (
C=$C AND E=$E AND G=$G) OR (
C=$C AND F=$F AND G=$G) OR (
D=$D AND E=$E AND F=$F) OR (
D=$D AND E=$E AND G=$G) OR (
D=$D AND F=$F AND G=$G) OR (
E=$E AND F=$F AND G=$G)";
if ($result = $mysqli -> query($sql)) {
while ($row = $result -> fetch_row()) {
echo "<td align=centre><b>($row[0])</td>";
$notFound = false;
break;
}
}
$C++;
}
$B++;
}
$A++;
}
$mysqli -> close();
?>
</body>
</html>
Would appreciate some help while some hair remains...
Coding I used when hosting my site on my own machine (Apache2.4, MySQL5.7, PHP7) that worked fine will not work now and I have spent MANY hours trying to figure this out... 2 scripts:
someform.html:
<html>
<form action="someform.php" method="post">
<p>A: <input type="text" name="A" autofocus /></p>
<p>B: <input type="text" name="B" autofocus /></p>
<p>C: <input type="text" name="C" autofocus /></p>
<p>D: <input type="text" name="D" autofocus /></p>
<p>E: <input type="text" name="E" autofocus /></p>
<p>F: <input type="text" name="F" autofocus /></p>
<p>G: <input type="text" name="G" autofocus /></p>
<p><input type="submit"></p>
</form>
</html>
someform.php:
<html>
<style>
table {
border-collapse: collapse;
width: 13.5%;
color: #588c7e;
font-family: monospace;
font-size: 25px;
text-align: center;
}
th {
background-color: #588c7e;
color: white;
}
tr:nth-child(even) {background-color: #f0f0e0}
</style>
</head>
<body>
<table>
<tr>
<th>A</th>
</tr>
</style></html>
<?php
$mysqli = new mysqli("localhost:3306","usrname","somepword","dbname");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
}
else {
echo "<tr align=center><font size=5 color=blue>Here are the results for:<br></tr>";
}
echo $_POST['A'] . ", ", $_POST['B'] . ", ", $_POST['C'] . ", ", $_POST['D'] . ", ", $_POST['E'] . ", ", $_POST['F'] . ", ", $_POST['G'] . ".";
$A = $_POST['A'];
$B = $_POST['B'];
$C = $_POST['C'];
$D = $_POST['D'];
$E = $_POST['E'];
$F = $_POST['F'];
$G = $_POST['G'];
/*This is important because... what if there is no combination of AB pairs that exists,
your loop will execute infinite*/
$limitNumber = 800;
$notFound = true;
for($i = 0; ($i < $limitNumber && $notFound); $i++){
for($j = 0; ($j < $limitNumber && $notFound); $j++){
for($k = 0; ($k < $limitNumber && $notFound); $k++){
$sql = "SELECT * FROM numbers where (A=$A AND B=$B AND C=$C) OR (
A=$A AND B=$B AND D=$D) OR (
A=$A AND B=$B AND E=$E) OR (
A=$A AND B=$B AND F=$F) OR (
A=$A AND B=$B AND G=$G) OR (
A=$A AND C=$C AND D=$D) OR (
A=$A AND C=$C AND E=$E) OR (
A=$A AND C=$C AND F=$F) OR (
A=$A AND C=$C AND G=$G) OR (
A=$A AND D=$D AND E=$E) OR (
A=$A AND D=$D AND F=$F) OR (
A=$A AND D=$D AND G=$G) OR (
A=$A AND E=$E AND F=$F) OR (
A=$A AND E=$E AND G=$G) OR (
A=$A AND F=$F AND G=$G) OR (
B=$B AND C=$C AND D=$D) OR (
B=$B AND C=$C AND E=$E) OR (
B=$B AND C=$C AND F=$F) OR (
B=$B AND C=$C AND G=$G) OR (
B=$B AND D=$D AND E=$E) OR (
B=$B AND D=$D AND F=$F) OR (
B=$B AND D=$D AND G=$G) OR (
B=$B AND E=$E AND F=$F) OR (
B=$B AND E=$E AND G=$G) OR (
B=$B AND F=$F AND G=$G) OR (
C=$C AND D=$D AND E=$E) OR (
C=$C AND D=$D AND F=$F) OR (
C=$C AND D=$D AND G=$G) OR (
C=$C AND E=$E AND F=$F) OR (
C=$C AND E=$E AND G=$G) OR (
C=$C AND F=$F AND G=$G) OR (
D=$D AND E=$E AND F=$F) OR (
D=$D AND E=$E AND G=$G) OR (
D=$D AND F=$F AND G=$G) OR (
E=$E AND F=$F AND G=$G)";
if ($result = $mysqli -> query($sql)) {
while ($row = $result -> fetch_row()) {
echo "<td align=centre><b>($row[0])</td>";
$notFound = false;
break;
}
}
$C++;
}
$B++;
}
$A++;
}
$mysqli -> close();
?>
</body>
</html>
Would appreciate some help while some hair remains...
Last edited by a moderator: