Проблемы с вставкой в ​​базу данных после обновления сервера PHP и SQL - PullRequest
0 голосов
/ 04 сентября 2018

Если я не объясню эту проблему должным образом, скажите, и я отредактирую ее в соответствии с требованиями.

У меня есть программа под названием «LiveAgent», которая в значительной степени зависит от вставки и извлечения SQL - которая работала до тех пор, пока мой сервер не обновил PHP с 7.0 до 7.2, а SQL - с 10.1 до 10.2.17_MariaDB. Мне сказали, что .htaccess нужно изменить, чтобы программное обеспечение могло взаимодействовать с сервером. Я очень смущен. Программное обеспечение показывает все записи до 22-го, когда сервер был обновлен (UK2). С тех пор вы ничего не можете отправить в него.

Файл htaccess находится ниже. Как и код для добавления «назначения».


HTAccess

# Mod Rewrite
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

#Fix Rewrite
Options -Multiviews

#http://forum.codecall.net/topic/74170-clean-urls-with-php/

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
  </IfModule>

  ## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php70” package as the default “PHP” programming language.
<IfModule mime_module>
  AddType application/x-httpd-ea-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

AJAX:

    if($ajax['1'] == 'add_new_appointment'){
        include 'files/add_new_appointment.php'; 
    }

ДОБАВИТЬ НОВУЮ НАЗНАЧЕНИЕ

<form action="" method="post" class="form-horizontal" >
    <div class="modal-body">

    <?php // ------------- ERROR -----------------
        foreach ($notification_msg as &$notification) { ?>
        <div class="alert <?php echo $notification['type'] ?>"><button type="button" class="close" data-dismiss="alert">&times;</button><strong><?php echo $notification['h4'] ?> </strong> <?php echo $notification['msg'] ?></div>
    <?php } // ------------- ERROR ----------------- ?>


                <input type="hidden" name="session_id" value="<?php echo $ajax['0'] ?>">
                <input type="hidden" name="create_appointment" value="true">

                <div class="form-group">
                    <label class="col-sm-3 control-label">Find Customer *</label>
                    <div class="col-sm-9">
                        <select name="customer" id="customer-single" style="width:100%" required> 
                            <option value="">Select a customer</option>
                            <?php  foreach(customer_array($ajax['0']) as $customer){ ?>
                            <option value="<?php echo $customer['id'] ?>"><?php echo $customer['business_name'] ?> - <?php echo $customer['first_name'] ?> <?php echo $customer['last_name'] ?></option>
                            <?php } ?>
                        </select>
                    If your customer is not listed you can add them <a href="https://[domain]/customer/new/">here</a>.
                    </div>
                </div>
                <hr>
                <div class="form-group">
                    <label class="col-sm-2 control-label">Category *</label>
                    <div class="col-sm-10">
                        <select name="category" id="category-single" style="width:100%" required> 
                            <option value="">Select a category</option>
                            <?php  foreach(category_array($ajax['0']) as $category){ ?>
                            <option value="<?php echo $category['id'] ?>"><?php echo $category['name'] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">Date *</label>
                    <div class="col-sm-4">
                        <input class="form-control datepicker" type="text" name="date" required>
                    </div>
                    <div class="col-sm-1">
                        <label class="control-label">Time *</label>
                    </div>
                    <div class="col-sm-2">
                        <input class="form-control timepicker" type="text" name="start_time" required>
                    </div>
                    <div class="col-sm-1">
                        <label class="control-label">To *</label>
                    </div>
                    <div class="col-sm-2">
                        <input class="form-control timepicker" type="text" name="end_time" required>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">Booked By *</label>
                    <div class="col-sm-9">
                        <select name="booked_by" id="agent-single"  style="width:100%" required> 
                            <?php  foreach (agent_array($ajax['0']) as $agent){ ?>
                            <option <?php if($agent['id'] == get_agent_from_session($ajax['0'], 'id')){echo 'selected';} ?> value="<?php echo $agent['id'] ?>"><?php echo $agent['first_name'] ?></option>
                            <?php } ?>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">Booked for *</label>
                    <div class="col-sm-9">
                        <select name="booked_for[]" id="agent-multi"  multiple="multiple" style="width:100%" required> 
                            <?php foreach (agent_array($ajax['0']) as $agent){ ?>
                            <option value="<?php echo $agent['id'] ?>"><?php echo $agent['first_name'] ?></option>
                            <?php } ?>
                        </select>
                     </div>
                </div>

                <div class="form-group">
                     <label class="col-sm-2 control-label">Notes</label>
                    <div class="col-sm-10">
                        <textarea class="form-control" name="notes"> </textarea>
                    </div>
                </div>

    </div>
    <div class="modal-footer">
        <a href="#"  class="btn btn-default" data-dismiss="modal">Close</a>
        <button type="submit" class="btn btn-success">Save</button>
    </div>
</form>

ПОДКЛЮЧЕНИЕ БАЗЫ ДАННЫХ

// arrays 
$notification_msg = array();
$bank_holidays = array();

// connect to db
try {
    $dbh = new PDO("mysql:host=$dbhostname;dbname=db", $dbusername, $dbpassword);
    /*** echo a message saying we have connected ***/
    //$notification_msg[] = array(type=>'alert-success', h4=>'Success', msg=>'Connected to database');
    }
catch(PDOException $e)
    {
    $notification_msg[] = array(type=>'alert-success', h4=>'', msg=>$e->getMessage());
    }

Код PHP / SQL:

if($_POST['create_appointment']){ 
        $customer_id   = htmlspecialchars($_POST['customer'], ENT_QUOTES);
        $category_id   = htmlspecialchars($_POST['category'], ENT_QUOTES);
        $date       = htmlspecialchars($_POST['date'], ENT_QUOTES);
        $start_time = htmlspecialchars($_POST['start_time'], ENT_QUOTES);
        $end_time   = htmlspecialchars($_POST['end_time'], ENT_QUOTES);
        $booked_by  = htmlspecialchars($_POST['booked_by'], ENT_QUOTES);
        $booked_for =  post_array_to_explode($_POST['booked_for']);
        $notes      = htmlspecialchars($_POST['notes'], ENT_QUOTES);
        $session_id = htmlspecialchars($_POST['session_id'], ENT_QUOTES);
        $time       = date("Y-m-d H:i:s");
        $agent_id   = get_agent_from_session($session_id, 'id');

        $start_date = $date.' '.$start_time;
        $end_date = $date.' '.$end_time;

        $start_date = format_datetime_mysql($start_date);
        $end_date = format_datetime_mysql($end_date);

        $insert = $dbh->exec("INSERT INTO calendar(start_date, end_date, notes, category_id, customer_id, added_by, booked_by, booked_for, date_added) VALUES ('$start_date', '$end_date', '$notes', '$category_id', '$customer_id', '$agent_id', '$booked_by', '$booked_for', '$time')");
            if($insert){
                $notification_msg[] = array(type=>'alert-success', h4=>'Success!', msg=>'Appointment Created');
                push_browser_notify('New appointment booked', format_date($start_date).' - '.get_customer_json('business_name', $customer_id).' ('.get_customer_json('first_name', $customer_id).' '.get_customer_json('last_name', $customer_id).') ', '');     

                header('Location: ' . $_SERVER['HTTP_REFERER']);

        }else{
            $notification_msg[] = array(type=>'alert-warning', h4=>'Warning!', msg=>'Appointment NOT Created');
        }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...