//Update for previous request for help.
//This is the original dbck.php mysql code.
<?php
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = 'mypasswd';
$database = 'clients';
$table = 'client';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");// sending query
$result = mysql_query("SELECT * FROM client");
if (!$result) {
die("Query to show fields from table failed");
}$fields_num = mysql_num_fields($result);
echo "<h2>records</h2>";
echo "<table border='1' cellpadding='3'><tr>";// printing table headers
for($i=0; $i<$fields_num; $i++)
{$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}echo "</tr>
";// printing table rows
while($row = mysql_fetch_row($result))
{echo "<tr>"; // $row is array...//foreach( .. ) //puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>
";}
echo "</table>
";
mysql_free_result($result);
?>
//After doing more research.
// I edited this block of code and it renders without error but doesn't print //to the database.
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($conn,"SELECT * FROM client") or die(mysqli_error);
$fields_num = mysqli_num_fields($result);
echo "<h2>Records</h2>";
echo "<table border='1' cellpadding='3'><tr>";// printing table headers
for($i=0; $i<$fields_num; $i++)
{$field = mysqli_fetch_field($result);
echo "<td>{$field->name}</td>";}
echo "</tr>
";// printing table rows
while($row = mysqli_fetch_array($result))
{
echo "<tr>"; // $row is array...//foreach( .. ) //puts every element
// of $row to $cell variable
if ($result->num_rows > 11) {
echo "<td>$cell</td>";
echo "</tr>
";
}
echo "</table>
";
}
mysqli_close($conn);
?>
//Client dump:
//CREATE TABLE client (
//id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
//Client varchar(40) NOT NULL,
// Details varchar(75) NOT NULL, //Invoice varchar(10) NOT NULL, //Signer varchar (20) NOT NULL, //Billing_Total varchar(20) NOT NULL, //Month_To_Date varchar(20) NOT NULL, //Year_To_Date varchar(20) NOT NULL, //Parts varchar (20) NOT NULL, //Parts_Year_To_Date varchar (20) NOT NULL //tstimestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE //
CURRENT_TIMESTAMP, // )ENGINE = MyISAM DEFAULT CHARSET=latin1;
First of all, right from the PHP.net:
Depending on the version of PHP, there are either two or three PHP APIs for accessing the MySQL database. PHP 5 users can choose between the deprecated mysql extension, mysqli, or PDO_MySQL. PHP 7 removes the mysql extension, leaving only the latter two options.
Don't just upgrade to the next version (whether that is PHP or another language) if you haven't checked what is being removed or deprecated.
From the PHP.net again:
mysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] )
in your code, you call mysqli_query the procedural way with a missing argument (CONNECTION LINK):
mysqli_query("INSERT INTO client VALUES('$id','$client','$ts','$details', '$invoice', '$signer', '$billing_total',
'$month_to_date', '$year_to_date', '$parts','$parts_year_to_date')");
Adding an "i" after every "mysql" isn't gonna fix your code. Reading the relevant documentation is! Fix every basic thing that stands out like what i pointed out, and then, if the problem persists, post a question not just with your code, but with warnings/errors that show on the page.