MySQL Server





MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi there,
I'm new to MySQL and PHP and I'm stuck in setting and html email in answer to a booking form.

Current status:
1)  The customer on my client platform has to complete a form and then there are 2 options for payment:
1)  ask to send an invoice;
2)  pay via card;

What I want to achieve:
At the moment for the first option my client 's receiving an email via phpMailer(set to: no html with 2 attattachment as 2 plain/text files with booking details).
The client has to go through those emails and fill up manually an invoice with this data and send all to the customer.

1)  I need to get/fetch this data from the booking form or 'db' and fill up a plain html template invoice. I can actually send this template but I don't know how to pass data to the html form. This way the client can receive the invoice already completed as they ask.

2)  For the option pay via card the person that is booking 's already receiving an email from the 'Card Payment Company' of confirmation but my client want me to send them/the customer also a receipt from us.
This receipt is a template receipt similar to the invoice template.

I need suggestions or if someone cano help me in achieve that.
Hello i am facing the same problem
"The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information."

I am attaching the php.ini file with some corrections made. Can you please rectify and tell why mysqli extension is still not getting connected.
I have two mysql tables, one logs in and out time for each employee when they come to work and leave. A very simple table.

    CREATE TABLE `EmployeeTime` (
      `id` int(6) NOT NULL AUTO_INCREMENT,
      `employeename` varchar(100) NOT NULL DEFAULT '',
      `logged_in` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
      `logged_out` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
      PRIMARY KEY (`id`)

    INSERT INTO `EmployeeTime` VALUES ('1', 'john', '2017-12-01 08:00:00', '2017-12-01 20:00:00');
    INSERT INTO `EmployeeTime` VALUES ('2', 'wendy', '2017-12-01 21:00:00', '2017-12-02 02:00:00');
    INSERT INTO `EmployeeTime` VALUES ('3', 'bruce', '2017-12-01 06:00:00', '2017-12-01 16:00:00');

Open in new window

Then I have another table that lets you configure "normal" working hours for each weekday, all hours before and after that time are concidered "overtime"

   CREATE TABLE `EmployeeTimeWorkingHours` (
      `id` int(6) NOT NULL DEFAULT '0',
      `DayOfTheWeekInNumber` int(6) DEFAULT NULL,
      `DayOfTheWeekInText` varchar(50) DEFAULT NULL,
      `StartTime` time DEFAULT NULL,
      `EndTime` time DEFAULT NULL,
      PRIMARY KEY (`id`)

    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('0', '1', 'Sunday', '00:00:00', '23:59:59');
    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('1', '2', 'Monday', '08:00:00', '17:00:00');
    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('2', '3', 'Tuesday', '08:00:00', '17:00:00');
    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('3', '4', 'Wednesday', '08:00:00', '17:00:00');
    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('4', '5', 'Thursay', '08:00:00', '17:00:00');
    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('5', '6', 'Friday', '08:00:00', '17:00:00');
    INSERT INTO `EmployeeTimeWorkingHours` VALUES ('6', '7', 'Saturday', '00:00:00', '23:59:59');

Open in new window

So I was wondering how I would create a single query that can provide me with the following for each row in EmployeeTime table :

Employeename, logged_in, logged_out, total worktime, Normaltime, Overtime.

I have been trying to solve it with stored procedures, temporary tables and all kinds of solution, but I guess this solution requires expert level of SQL knowledge. I tend to run into problems with the calculations when logged_in and logged_out span over more then two days. But this is no problem when the rows in the former table are within the range of one single day.

I have the following XML in a column named "product_date" in my MySQL database:

            <value>Intel Core i7</value>
            <value>Intel Core i5</value>
            <value>AMD FX</value>
<value>AMD Ryzen</value>
            <value>AMD A-Series</value>
            <value>Phenon II X4 965</value>
            <value>Nvidia Tegra 4</value>

How can I query this column using SQL and return just the raw values with 1 value per row within the "value" node?

Final output would multiple rows with 1 value per row
Intel Core i7
Intel Core i5

<section class="news">
            <div class="container">
                  <h2>Berita Terkini</h2>

                  $query = mysqli_query("SELECT * FROM db_news ORDER BY judul DESC LIMIT 2 ");
                  while ($berita = mysqli_fetch_array($query)) {


                        <div class="pic"><img src="images/<?php echo $berita['foto']; ?>" width="100" alt=""></div>
                        <div class="info">
                              <h4><?php echo $berita['judul'];?></h4>
                              <p class="date"><?php echo $berita['waktu'];?> <?php echo $berita['tempat'];?></p>
                              <p><?php echo $berita['rangkuman'];?> (...)</p>
                              <a class="more" href="single_berita.php?cari=single_berita&id_news=<?php echo $berita['id_news'];?>">Read more</a>



class database{
      private $dbhost = "localhost";
      private $dbuser = "root";
      private $dbpass = "";
      private $dbname = "ikbe";

function koneksi(){

function tambahAdmin($nm,$user,$pass){
      $query = mysqli_query("INSERT INTO admin set nama='$nm', user='$user', pass='$pass'");
      if ($query) {
            echo "<meta http-equiv='refresh' content='0; url=setting.php'>";
            echo "Data gagal diinput !!";

function hapusAdmin($id){
      mysqli_query("DELETE FROM admin where id_admin='$id'");

function …
I'm using a form building script, using Ajax Autocomplete, the include file looks like this
$array = ['Mildred', 'Louise', 'Frances'];

Search 20 results
$max_results = 20;
$found = 0;
$results = [];
for ($i=0; $i < count($array); $i++) {
    if (preg_match('`' . addslashes($_GET['term']) . '`i', $array[$i])) {
        array_push($results, $array[$i]);
        $found += 1;
        if ($found == $max_results) {
            $i = count($array); // end loop if we reached max_results

if (count($results) > 0) {
    $out = '[';
    for ($i=0; $i < $found; $i++) { // returns only firs 20 results
        $out .= '"' . $results[$i] . '"';
        if ($i + 1 < $found) {
            $out .= ',';
    $out .= ']';
    echo $out;

Open in new window

Problem is I want the array data from a MySQL query, I have tried using an include to an external page that returns the results but fails:

 $db = mysqli_connect('******','****','*****','*********s')
 or die('Error connecting to MySQL server.');


$query = "SELECT * FROM templates_client_search";
mysqli_query($db, $query) or die('Error querying database.');

$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);

while ($row = mysqli_fetch_array($result)) {
 echo "'" . $row['ContName'] . " - " . $row['ContAddress'] . "', ";

Open in new window

Any ideas or pointers please?
I have in table column named user_date, and I have jquery on frontend to get user status ADULT or YOUNG. When user pick the date, script automaticaly write ADULT or YOUNG, depending on his picked date and current date, = >18 or <18. Now I would, to get number of young users which for one month will be ADULT, and get that number like some alert.
Why I'm always getting warning: Natalie_query() expects parameter 1 to be mysqli, null given in c:\xampp\htdocs\view\dokumen.php on line 57
I need help with my ASP.NET MVC application hosted on iis. The application loses connection to MYSQL database after sometime and requires me to restart mysql service then it continues to connect.
I have one table that contains 2 million rows. at every second there are 6000-row inserting and every second latest row fetching by every group means 6000 new row fetch. so when I try to fetch a particular range of data then the table will be a lock . its show me lock wait timeout. so, what can I do for that? please help me.
For my site, I am having trouble make the user redirect to the proper page using header("location: ... ");. Instead, on the log in, it redirects to the form's action: login.php. How do I make it so that the user is redirected to the correct page and not the php file that the login form uses?

Below is the HTML code (the form):
<h2>Log In</h2>
      <form method="POST" action="login.php">
            <input type="number" placeholder="student id" required name="studentid"><br>
            <input type="password" placeholder="password" required name="password"><br>
            <button type="submit" name="submit">Go</button>

Below is the relevant sections of the PHP:
$uid = mysqli_real_escape_string($conn, $_POST['studentid']);
$pwd = mysqli_real_escape_string($conn, $_POST['password']);

$sql = "SELECT * FROM users WHERE studentid='$uid'";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);

//username check
if ($resultCheck < 1) {
      //redirect and exit
      } else {
            if ($row = mysqli_fetch_assoc($result)) {
                  //De-hashing the password
                  $hashedPwdCheck = password_verify($pwd,  $row['password']);
                        if ($hashedPwdCheck == false) {
                              //redirect and exit
                        } elseif ($hashedPwdCheck == true) {
                              //Log in the user here and get session variables
                              header("location: index.php?login=success");
I'm working in MySQL after update trigger. when row is updated i need to make a query of changed values so that if that query is run table goes in previous state, for this i need to process each field of the table under some conditions. for this i was thinking to make a procedure to build query and pass that procedure all field's values and names . my tables contains upto 5o columns. therefore i want to know if it is possible to get these values in array form
$check_email="select * form users where user email='$email'";
            $run_email = mysqli_query($con,$check_email);
            $check = mysqli_num_rows($run_email);
             echo "<script>alert('Email phone already exit,please try another!')</script>";
I have a MySQL table with more than a 3 billion rows hosted on Google Cloud SQL.

I wish to understand how the total size on disk can be explained from the column data-types, number of rows and the indexes.

I was hoping that it would be something like

size_of_table_in_bytes = num_rows * [ Sum over i {bytes_for_datatype_of_column(i))}
                                    + Sum over j  {Bytes_for_index(j)} ]
But I end up with incorrect disk-size than how much my database size shows.

Using bytes per datatype on

and additional bytes in InnoDB header and indexes from

Here is my understanding of bytes occupied by header, each column and each index

TABLE `depth` (
Bytes| Column/Header/Index
    2| variable length header Ceil(num columns/8) = Ceil (10/8)
    5| Fixed Length Header
    3|`date` date DEFAULT NULL,
    7|`receive_time` datetime(3) DEFAULT NULL,
    8|`instrument_token` bigint(20) unsigned DEFAULT NULL,
    1|`level `tinyint(3) unsigned DEFAULT NULL,
    2|`bid_count` smallint(5) unsigned DEFAULT NULL,
    8|`bid_size` bigint(20) unsigned DEFAULT NULL,
    4|`bid_price` float DEFAULT NULL,
    4|`ask_price` float DEFAULT NULL,
    8|`ask_size` bigint(20) unsigned DEFAULT NULL,
    2|`ask_count` smallint(5) unsigned DEFAULT NULL,
    6|KEY `date_time_sym …
s.survey_id AS 'Inspection ID',
s.license_number As 'License Number',
s.name_pos AS 'Name of POS',
s.address_pos AS 'Address of POS',
s.updated_at As 'Inspection Date',
s.updated_at As 'Inspection Date', As 'Town Name', As 'Districts Name',
s.gps_location As 'Location',
sum(a.option_value) As 'Final Scoring',
a.option_value As 'Remarks'
FROM  ".DB_PREFIX . "survey s
on t.town_id=s.town_id
on c.city_id=s.city_id
on a.survey_id=s.survey_id WHERE a.question_id=371";

i want sum of option_value WHERE option_id!=0  in join query and  a.option_value As 'Remarks' WHERE a.question_id=371";

from same table
i have logged the changes recorded in table "A" using triggers in a table log_tbl with the type UPDATE,DELETE,INSERT . how can i transfer these changes to another table (having same structure as changed table "A") on different server with the help of mysql scheduler OR other technique automatically without REPLICATION.
This login form does not open the intended page.  In only opens the error message in the retry.php page.

 Here is part of the code where the problem might be found.  Unfortunately, I do not see it.

// *** Validate request to login to this site.

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $_SESSION['PrevUrl'] = $accesscheck;
//  session_register('PrevUrl');

if (isset($_POST['user'])) {
  $MM_fldUserAuthorization = "access";
  $MM_redirectLoginSuccess = "index.php";
  $MM_redirectLoginFailed = "tryagain.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_ibtib_dbc, $ibtib_dbc);
  $LoginRS__query=sprintf("SELECT user, pw, access FROM users WHERE user='%s' AND pw='%s'",
  get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
  $LoginRS = mysql_query($LoginRS__query, $ibtib_dbc) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    $loginStrGroup  = mysql_result($LoginRS,0,'access');
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;           

    //register the session variables
//    session_register("MM_Username");
//    session_register("MM_UserGroup");

    if …
 $db = mysqli_connect('localhost','username','','db_name')
 or die('Error connecting to MySQL server.');

 <h1>PHP connect to MySQL</h1>
$query = "SELECT * FROM imabangalore";
mysqli_query($db, $query) or die('Error querying database.');
$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);

while ($row = mysqli_fetch_array($result)) {
 echo $row['Name'] . ' ' . $row['IMA Memb No'] . ' ' . $row['Spouse Name'] . ' ' . '<br />';



Open in new window

Results shows all the data, but I want only the searched Name and their details
Hi Experts;
I've had success at migrating a complex stored procedure from MS SQL to MYSQL but am stumped at a line using PARTITION OVER.

I can't figure out how to convert the following code:
MS SQL code:
                  SELECT *,
                        RowNumber = ROW_NUMBER()
                        OVER(PARTITION BY t.GId, t.PId, t.GABNum ORDER BY t.GABNum, t.PTABNum)

                        mydb.dbo.myTable t

The above is a derived table within a larger query and eventually I want MIN(t.paeid) and MAX(t.paeid)

I've commented out the partition line and am able to get matching results except for the MAX(t.paeid) which makes sense.

I've been trying several methods found on the internet, and so far I've gotten this far (to get the MIN value). However it returns 0 rows so I'm doing it wrong.
MYSQL code:

use mydb;
set @r = 0;
@r AS Firstpaeid
      FROM (SELECT *
                  FROM (SELECT @_gid = NULL, @_pid = NULL, @_gabnum = NULL) vars,
                  ORDER BY GId, PId, GABNum)
        WHERE (CASE WHEN @_gid <> GId AND @_pid <> PId AND GABNum <> @_gabnum THEN
                  @r := paeid END)
                            AND (@_gid = GId)
                            AND (@_pid = PId)
                            AND (@_gabnum := GABNum)

Perhaps I should be using a different method entirely? I've read about CONCAT(GROUP BY...) and am trying that method now.
I also haven't worked with Partitions in SQL (or MYSQL) so …
I have a pagination that load more when I click on the load more button, which I got from the below URL

Whenever I add RAND() it always duplicates the value.



$rowperpage = 10;

$allcount_query = "SELECT count(*) as allcount FROM users order by id";
$allcount_result = mysql_query($allcount_query);
$allcount_fetch = mysql_fetch_array($allcount_result);
 $allcount = $allcount_fetch['allcount'];

$query = "select * from users order by RAND(" . date("Ymd") . ") asc limit 0,$rowperpage ";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)){

<div><h1><?php echo $row['id']; ?></div>


<h1 class="load-more">Load More</h1>
<input type="hidden" id="row" value="0">
<input type="hidden" id="all" value="<?php echo $allcount; ?>">

Open in new window


$row = $_POST['row'];
$rowperpage = 10;

$query = 'SELECT * FROM users ORDER BY id limit '.$row.','.$rowperpage;
$result = mysql_query($query);

$html = '';
while($row = mysql_fetch_array($result)){

$html .= '<div><h1>'.$id.'</h1></div>';


Open in new window

I've read a few tutorials online for sending a blank image in an html email in order to log when the email is opened, but none of them seem to work in my system.  I don't need anymore information than the date/time an email was opened to log in my MySQL database.  Any help would be appreciated!
HI All, trying to figure out how to use data from two tables in Domo.

This is what I'm trying and it is not working.

SELECT id, jobsite, status FROM application UNION SELECT client, id, nickname FROM jobsites

Open in new window

It's only showing the first part, however I do not get any errors.

Any help is greatly appreciated.
I have the following query on table fila

FROM fila f
JOIN meta m
ON = f.idlinks
WHERE m.meta2 < m.meta

Open in new window

It works, but I need something more ...
I need the query to get into the FILA table values that are no longer in the activity table, for example:
If the activity table already exists in the URL column and in the ACAO column, that data is disregarded and I get the next item in the row table

Table Fila
Table fila
Table Atividade

atividade2.pngAs already exists in the activity table at URL 976 and USER 92, that record has to be disregarded and the query move to the next record in the FILA table
We are looking at deploying SuiteCRM Company wide.  We have a development environment which we are testing all the required features and modules that we will required, and at the same time demoing to the management teams what the system will eventually look like.

We have a problem in that at current we have around 6 different websites/microsites that are hosted and designed by 6 different companies (all sadly managed by our marketing department, hence 6 companies!)

At current the contact form comes in to an email address (webenquires@) and then gets routed via our ancient mailserver.

We will be migrating to office 365 the same time as we roll out the new CRM.

I am looking for a solution to automatically create a lead from an inbound email in SuiteCRM.
Yes I am aware of doing it via campaigns and forms, however trying to get all 6 companies to make the correct changes at go live the same time will fail.  

Also we need to demo this system for a few weeks to various management teams, and would like to implement the form changes 1 site and company at a time allowing for problems.

What I need is a temporary solution to do this via:

Either MySQL or inner Join
PHP coding
Or some kind of workflow

The correct inbound email address (webenquiries) is already configured and working in SuiteCRM.

I tried the following inner join from the example above which is based on Sugar CE6.5 failed.  I modified it to work with SuiteCRM and it now generates a Lead, …
I am using jxDatePicker to accept date data in my java project but MySql is not recognizing it as Date despite setting the Table Data as DATE and formatting the jxDatePicker value to "yyyy-mm-dd" format in the code.
I will appreciate your help to fix this problem.

MySQL Server





MySQL is an open source, relational database management system that runs as a server providing multi-user access to a number of databases. Acquired by Oracle in 2009, it is frequently used in combination with PHP installations, powering most of the WordPress installations.