Переделать кусок кода под PHP7
300 руб. за проект
Есть старый код, элементарный, там что-то не так с получением массивов, надо сделать чтобы работало.
define ('DATABASE_HOST', 'localhost');
define ('DATABASE_LOGIN', 'host1688212_vam');
define ('DATABASE_PASSWORD', '1111111');
define ('DATABASE_NAME', 'host1688212_vam');
$db = new mysqli(DATABASE_HOST, DATABASE_LOGIN, DATABASE_PASSWORD, DATABASE_NAME);
if ($db->connect_error) { die("Невозможно подключиться к БД: {$db->connect_error}"); }
$lastorder = $_GET['lastorder'];
$M_id = "LN";
$from = array('"', '&', '<', '>', '&', "\r\n");
$to = array('"', '&', '<', '>', ' & ', ' ');
echo '<?xml version="1.0" encoding="utf-8" ?>'."\n"."<Order_File>";
$main_query = $db->query("SELECT * FROM orders o left join customers c on c.customers_id=o.customers_id left join orders_status_history osh on osh.orders_id=o.orders_id WHERE o.orders_id > $lastorder and o.orders_id < $lastorder+15");
while ($row = mysqli_fetch_assoc($main_query))
{
$order_id = $row['orders_id'];
$customers_id = $row['customers_id'];
$value = explode(" ", $row['date_purchased']);
//$date = str_replace("-", ".", $value[0]);
$date_purchased = $row['date_purchased'];
$Day = substr($date_purchased, 8,2);
$Month = substr($date_purchased, 5, 2);
$Year = substr($date_purchased, 0, 4);
$Time = substr($date_purchased, 11);
$payment = $row['payment_method'];
If ($payment == 'cod') {$payment = 'Оплата при получении';}
$delivery_company = $row['delivery_company'];
$delivery_company = substr($delivery_company, 0, 30);
$delivery_company = preg_replace('/&(?!\w{2,6};)/', '&', $delivery_company);
if ($delivery_company === '')
{
$delivery_company = 'n/a';
}
$delivery_name = $row['delivery_name'];
$delivery_street_address = $row['delivery_street_address'];
$delivery_street_address = str_replace($from, $to, $delivery_street_address);
$customers_street_address = $row['customers_street_address'];
$customers_street_address = str_replace($from, $to, $customers_street_address);
$comments = str_replace($from, $to, $row['comments']);
$customers_street2 = $row['customers_suburb'];
if ($customers_street2 == '')
{
$customers_street2 = 'n/a';
}
Вот эти закоменченые возвращают ошибки.
// $query_extra1 = "SELECT * FROM customers_to_extra_fields where customers_id=$customers_id and fields_id=1";
// $result_extra1 = $db->query($query_extra1);
// $extra_1 = mysqli_fetch_array($result_extra1);
// $extra_subway = $extra_1['value'];}
// $query_extra2 = "SELECT * FROM customers_to_extra_fields where customers_id=$customers_id and fields_id=2";
// $result_extra2 = $db->query($query_extra2);
// $extra_2 = mysqli_fetch_array($result_extra2);
// $extra_time1 = $extra_2['value'];
// $query_extra3 = "SELECT * FROM customers_to_extra_fields where customers_id=$customers_id and fields_id=3";
// $result_extra3 = $db->query($query_extra3);
// $extra_3 = mysqli_fetch_array($result_extra3);
// $extra_time2 = $extra_3['value'];
$customers_postcode = $row['customers_postcode'];
$customers_country = $row['customers_country'];
$customers_email_address = $row['customers_email_address'];
$delivery_company = $row['shipping_class'];
If ($delivery_company == 'flat_flat') {$delivery_company = 'САМОВЫВОЗ УТОЧНИТЬ АДРЕС';} else { $delivery_company = '';}
$products = $db->query("SELECT orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price FROM orders_products WHERE orders_id = $row['orders_id'] ");
while ($product = mysqli_fetch_assoc($products))
// и вот тут ошибка идет
{
$colorset = 0;
$attributes_query = $db->query("SELECT products_options, products_options_values, options_values_price, price_prefix FROM orders_products_attributes WHERE orders_id = $order_id and orders_products_id = '" . (int)$product['orders_products_id'] . "'");
$product_info = mysqli_fetch_assoc($db->query("SELECT products_image FROM products WHERE products_id = ".(int)$product['orders_products_id']." LIMIT 1"));
$product_category = mysqli_fetch_assoc($db->query("SELECT categories_id FROM products_to_categories WHERE products_id = ".(int)$product['orders_products_id']." LIMIT 1"));
$attributes = array();
while ($attribute = mysqli_fetch_assoc($attributes_query))
{
$attributes[] = $attribute;
}
$products_name = str_replace($from, $to, $product['products_name']);
$unit_price = $product['products_quantity'] * $product['products_price'];
define ('DATABASE_HOST', 'localhost');
define ('DATABASE_LOGIN', 'host1688212_vam');
define ('DATABASE_PASSWORD', '1111111');
define ('DATABASE_NAME', 'host1688212_vam');
$db = new mysqli(DATABASE_HOST, DATABASE_LOGIN, DATABASE_PASSWORD, DATABASE_NAME);
if ($db->connect_error) { die("Невозможно подключиться к БД: {$db->connect_error}"); }
$lastorder = $_GET['lastorder'];
$M_id = "LN";
$from = array('"', '&', '<', '>', '&', "\r\n");
$to = array('"', '&', '<', '>', ' & ', ' ');
echo '<?xml version="1.0" encoding="utf-8" ?>'."\n"."<Order_File>";
$main_query = $db->query("SELECT * FROM orders o left join customers c on c.customers_id=o.customers_id left join orders_status_history osh on osh.orders_id=o.orders_id WHERE o.orders_id > $lastorder and o.orders_id < $lastorder+15");
while ($row = mysqli_fetch_assoc($main_query))
{
$order_id = $row['orders_id'];
$customers_id = $row['customers_id'];
$value = explode(" ", $row['date_purchased']);
//$date = str_replace("-", ".", $value[0]);
$date_purchased = $row['date_purchased'];
$Day = substr($date_purchased, 8,2);
$Month = substr($date_purchased, 5, 2);
$Year = substr($date_purchased, 0, 4);
$Time = substr($date_purchased, 11);
$payment = $row['payment_method'];
If ($payment == 'cod') {$payment = 'Оплата при получении';}
$delivery_company = $row['delivery_company'];
$delivery_company = substr($delivery_company, 0, 30);
$delivery_company = preg_replace('/&(?!\w{2,6};)/', '&', $delivery_company);
if ($delivery_company === '')
{
$delivery_company = 'n/a';
}
$delivery_name = $row['delivery_name'];
$delivery_street_address = $row['delivery_street_address'];
$delivery_street_address = str_replace($from, $to, $delivery_street_address);
$customers_street_address = $row['customers_street_address'];
$customers_street_address = str_replace($from, $to, $customers_street_address);
$comments = str_replace($from, $to, $row['comments']);
$customers_street2 = $row['customers_suburb'];
if ($customers_street2 == '')
{
$customers_street2 = 'n/a';
}
Вот эти закоменченые возвращают ошибки.
// $query_extra1 = "SELECT * FROM customers_to_extra_fields where customers_id=$customers_id and fields_id=1";
// $result_extra1 = $db->query($query_extra1);
// $extra_1 = mysqli_fetch_array($result_extra1);
// $extra_subway = $extra_1['value'];}
// $query_extra2 = "SELECT * FROM customers_to_extra_fields where customers_id=$customers_id and fields_id=2";
// $result_extra2 = $db->query($query_extra2);
// $extra_2 = mysqli_fetch_array($result_extra2);
// $extra_time1 = $extra_2['value'];
// $query_extra3 = "SELECT * FROM customers_to_extra_fields where customers_id=$customers_id and fields_id=3";
// $result_extra3 = $db->query($query_extra3);
// $extra_3 = mysqli_fetch_array($result_extra3);
// $extra_time2 = $extra_3['value'];
$customers_postcode = $row['customers_postcode'];
$customers_country = $row['customers_country'];
$customers_email_address = $row['customers_email_address'];
$delivery_company = $row['shipping_class'];
If ($delivery_company == 'flat_flat') {$delivery_company = 'САМОВЫВОЗ УТОЧНИТЬ АДРЕС';} else { $delivery_company = '';}
$products = $db->query("SELECT orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price FROM orders_products WHERE orders_id = $row['orders_id'] ");
while ($product = mysqli_fetch_assoc($products))
// и вот тут ошибка идет
{
$colorset = 0;
$attributes_query = $db->query("SELECT products_options, products_options_values, options_values_price, price_prefix FROM orders_products_attributes WHERE orders_id = $order_id and orders_products_id = '" . (int)$product['orders_products_id'] . "'");
$product_info = mysqli_fetch_assoc($db->query("SELECT products_image FROM products WHERE products_id = ".(int)$product['orders_products_id']." LIMIT 1"));
$product_category = mysqli_fetch_assoc($db->query("SELECT categories_id FROM products_to_categories WHERE products_id = ".(int)$product['orders_products_id']." LIMIT 1"));
$attributes = array();
while ($attribute = mysqli_fetch_assoc($attributes_query))
{
$attributes[] = $attribute;
}
$products_name = str_replace($from, $to, $product['products_name']);
$unit_price = $product['products_quantity'] * $product['products_price'];
В заказе есть исполнитель
При переводе заказа из архивного в актуальный, текущий исполнитель будет снят с задачи.
Выберите тип сделки
С безопасной сделкой вы всегда сможете вернуть средства, если что-то пойдет не так. С простой сделкой вы самостоятельно договариваетесь с исполнителем об оплате и берете на себя решение конфликтов.