Query not inserting and not showign errors - php
I've been trying to figure this out, and was not able to make it work. I was trying to see the response of my PHP but it doesn't show any errors. Last time this inserted into my table. below this is query of my PHP.
$selectCharacter = $con->query('SELECT * FROM users_characters WHERE UserId = "'. $UserID .'" AND CharacterID = "'. $CharacterID .'"');
$user_data = $selectCharacter->fetch_assoc();
$CharacterID = $user_data['CharacterID'];
$UserID = $user_data['UserId'];
$Name = $user_data['Name'];
$Hash = $user_data['Hash'];
$HairID = $user_data['HairID'];
$Access = $user_data['Access'];
$SkillPoints = $user_data['SkillPoints'];
$RaceID = $user_data['RaceID'];
$RaceXP = $user_data['RaceXP'];
$ActivationFlag = $user_data['ActivationFlag'];
$PermamuteFlag = $user_data['PermamuteFlag'];
$Country = $user_data['Country'];
$Age = $user_data['Age'];
$Gender = $user_data['Gender'];
$Email = $user_data['Email'];
$Level = $user_data['Level'];
$Copper = $user_data['Copper'];
$Silver = $user_data['Silver'];
$Gold = $user_data['Gold'];
$Coins = $user_data['Coins'];
$Exp = $user_data['Exp'];
$ColorHair = $user_data['ColorHair'];
$ColorSkin = $user_data['ColorSkin'];
$ColorEye = $user_data['ColorEye'];
$ColorBase = $user_data['ColorBase'];
$ColorTrim = $user_data['ColorTrim'];
$ColorAccessory = $user_data['ColorAccessory'];
$SlotsBag = $user_data['SlotsBag'];
$SlotsBank = $user_data['SlotsBank'];
$SlotsHouse = $user_data['SlotsHouse'];
$DateCreated = $user_data['DateCreated'];
$LastLogin = $user_data['LastLogin'];
$CpBoostExpire = $user_data['CpBoostExpire'];
$RepBoostExpire = $user_data['RepBoostExpire'];
$GoldBoostExpire = $user_data['GoldBoostExpire'];
$ExpBoostExpire = $user_data['ExpBoostExpire'];
$UpgradeExpire = $user_data['UpgradeExpire'];
$UpgradeDays = $user_data['UpgradeDays'];
$Upgraded = $user_data['Upgraded'];
$Achievement = $user_data['Achievement'];
$Settings = $user_data['Settings'];
$Quests = $user_data['Quests'];
$Quests2 = $user_data['Quests2'];
$DailyQuests0 = $user_data['DailyQuests0'];
$DailyQuests1 = $user_data['DailyQuests1'];
$DailyQuests2 = $user_data['DailyQuests2'];
$MonthlyQuests0 = $user_data['MonthlyQuests0'];
$LastArea = $user_data['LastArea'];
$SpawnPoint = $user_data['SpawnPoint'];
$CurrentServer = $user_data['CurrentServer'];
$HouseInfo = $user_data['HouseInfo'];
$KillCount = $user_data['KillCount'];
$DeathCount = $user_data['DeathCount'];
$Address = $user_data['Address'];
$Language = $user_data['Language'];
$Rebirth = $user_data['Rebirth'];
$Bounty = $user_data['Bounty'];
$backupCharacter = $con->query("INSERT INTO `users_characters_history`
(`CharacterID`, `UserId`, `Name`, `Hash`, `HairID`,
`Access`, `SkillPoints`, `RaceID`, `RaceXP`,
`ActivationFlag`, `PermamuteFlag`, `Country`,
`Age`, `Gender`, `Email`, `Level`, `Copper`, `Silver`,
`Gold`, `Coins`, `Exp`, `ColorHair`, `ColorSkin`,
`ColorEye`, `ColorBase`, `ColorTrim`, `ColorAccessory`,
`SlotsBag`, `SlotsBank`, `SlotsHouse`, `DateCreated`,
`LastLogin`, `CpBoostExpire`, `RepBoostExpire`,
`GoldBoostExpire`, `ExpBoostExpire`, `UpgradeExpire`,
`UpgradeDays`, `Upgraded`, `Achievement`, `Settings`,
`Quests`, `Quests2`, `DailyQuests0`, `DailyQuests1`,
`DailyQuests2`, `MonthlyQuests0`, `LastArea`, `SpawnPoint`,
`CurrentServer`, `HouseInfo`, `KillCount`, `DeathCount`,
`Address`, `Language`, `Rebirth`, `Bounty`)
VALUES ('" . $CharacterID . "', '" . $UserID . "', '" . $Name ."', '"
. $Hash . "', '" . $HairID . "', '" . $Access . "', '"
. $SkillPoints . "', '" . $RaceID . "', '" . $RaceXP
. "', '" . $ActivationFlag . "', '" . $PermamuteFlag . "', '"
. $Country . "', '" . $Age . "', '" . $Gender ."', '" .
$Email . "', '" . $Level . "', '" . $Copper . "', '" .
$Silver . "', '" . $Gold . "', '" . $Coins . "', '" . $Exp .
"', '" . $ColorHair . "', '" . $ColorSkin . "', '" .
$ColorEye . "', '" . $ColorBase . "', '" . $ColorTrim . "',
'" . $ColorAccessory . "', '" . $SlotsBag . "', '" .
$SlotsBank . "','" . $SlotsHouse . "', '" . $DateCreated .
"', '" . $LastLogin . "', '" . $CpBoostExpire . "', '" .
$RepBoostExpire . "', '" . $GoldBoostExpire . "', '" .
$ExpBoostExpire . "', '" . $UpgradeExpire . "', '" .
$UpgradeDays . "', '" . $Upgraded ."', '" . $Achievement .
"', '" . $Settings . "', '" . $Quests . "', '" . $Quests2 .
"', '" . $DailyQuests0 . "', '" . $DailyQuests1 . "', '" .
$DailyQuests2 . "', '" . $MonthlyQuests0 . "', '" . $LastArea
. "', '" . $SpawnPoint . "', '" . $CurrentServer . "', '" .
$HouseInfo . "', '" . $KillCount . "', '" . $DeathCount . "',
'" . $Address . "', '" . $Language . "', '" . $Rebirth . "',
'" . $Bounty ."')");
This is the query that should insert but won't insert, the network logs in chrome doesn't show the error of my query.
$backupCharacter = $con->query("INSERT INTO `users_characters_history` (`CharacterID`, `UserId`, `Name`, `Hash`, `HairID`, `Access`, `SkillPoints`, `RaceID`, `RaceXP`, `ActivationFlag`, `PermamuteFlag`, `Country`, `Age`, `Gender`, `Email`, `Level`, `Copper`, `Silver`, `Gold`, `Coins`, `Exp`, `ColorHair`, `ColorSkin`, `ColorEye`, `ColorBase`, `ColorTrim`, `ColorAccessory`, `SlotsBag`, `SlotsBank`, `SlotsHouse`, `DateCreated`, `LastLogin`, `CpBoostExpire`, `RepBoostExpire`, `GoldBoostExpire`, `ExpBoostExpire`, `UpgradeExpire`, `UpgradeDays`, `Upgraded`, `Achievement`, `Settings`, `Quests`, `Quests2`, `DailyQuests0`, `DailyQuests1`, `DailyQuests2`, `MonthlyQuests0`, `LastArea`, `SpawnPoint`, `CurrentServer`, `HouseInfo`, `KillCount`, `DeathCount`, `Address`, `Language`, `Rebirth`, `Bounty`)
VALUES ('" . $CharacterID . "', '" . $UserID . "', '" . $Name ."', '" . $Hash . "', '" . $HairID . "', '" . $Access . "', '" . $SkillPoints . "', '" . $RaceID . "', '" . $RaceXP . "', '" . $ActivationFlag . "', '" . $PermamuteFlag . "', '" . $Country . "', '" . $Age . "', '" . $Gender ."', '" . $Email . "', '" . $Level . "', '" . $Copper . "', '" . $Silver . "', '" . $Gold . "', '" . $Coins . "', '" . $Exp . "', '" . $ColorHair . "', '" . $ColorSkin . "', '" . $ColorEye . "', '" . $ColorBase . "', '" . $ColorTrim . "', '" . $ColorAccessory . "', '" . $SlotsBag . "', '" . $SlotsBank . "','" . $SlotsHouse . "', '" . $DateCreated . "', '" . $LastLogin . "', '" . $CpBoostExpire . "', '" . $RepBoostExpire . "', '" . $GoldBoostExpire . "', '" . $ExpBoostExpire . "', '" . $UpgradeExpire . "', '" . $UpgradeDays . "', '" . $Upgraded ."', '" . $Achievement . "', '" . $Settings . "', '" . $Quests . "', '" . $Quests2 . "', '" . $DailyQuests0 . "', '" . $DailyQuests1 . "', '" . $DailyQuests2 . "', '" . $MonthlyQuests0 . "', '" . $LastArea . "', '" . $SpawnPoint . "', '" . $CurrentServer . "', '" . $HouseInfo . "', '" . $KillCount . "', '" . $DeathCount . "', '" . $Address . "', '" . $Language . "', '" . $Rebirth . "', '" . $Bounty ."')");
Thanks to everyone, $con->error showed the error and I was able to solve the problem, the column only accepts 6 characters and the one i'm inserting which is ColorHair has 9 characters, I changed its Length and was able to insert the item.
Related
error Column count doesn't match value count at row 1
$query = "Insert Into dbo_dailyline (Entry_date, Work_Center, Shift_Length, Number_Sewers, Deduct_Hours, Garment_Type, Other, Quantity, Notes) values ('" .$Entry_Date. "', '" . $Shift_Length . "', '" .$Coats . "', '" . $Number_Sewers . "', '" . $Deduct_Hours . "', '" . $Garment_Type . "' , '" . $Garment_Type . "', '" . $Other . "', '" . $Quantity . "', '" . $Notes . "')"; error Column count doesn't match value count at row 1
You have two time $Garment_Type remove one $query = "Insert Into dbo_dailyline ( Entry_date , Work_Center , Shift_Length , Number_Sewers , Deduct_Hours , Garment_Type , Other , Quantity , Notes) values ('" . $Entry_Date. "', '" . $Shift_Length . "', '" . $Coats . "', '" . $Number_Sewers . "', '" . $Deduct_Hours . "', '" . $Garment_Type . "' , '" . $Other . "', '" . $Quantity . "', '" . $Notes . "')";
500 internal server error when adding many product options in opencart 2.0.3.1
Please help me guys, I am just an opencart newbie, i have this error 1 week now. When I am saving many options in my opencart 2.0.3.1 admin panel's product page i get 500 internal server error. when i view the error logs, i got this lines. 2016-03-16 19:03:34 - PHP Notice: Undefined index: points in W:\vhosts\contax4u.com.au\httpdocs\admin\model\catalog\product.php on line 131 2016-03-16 19:03:34 - PHP Notice: Undefined index: points in W:\vhosts\contax4u.com.au\httpdocs\admin\model\catalog\product.php on line 175 2016-03-16 19:03:34 - PHP Notice: Undefined index: weight in W:\vhosts\contax4u.com.au\httpdocs\admin\model\catalog\product.php on line 175 2016-03-16 19:03:34 - PHP Notice: Undefined index: weight_prefix in W:\vhosts\contax4u.com.au\httpdocs\admin\model\catalog\product.php on line 175 the error is indicating these lines line 131: $this->db->query("UPDATE " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "',product_type = '" . (int)$data['product_type'] . "', date_modified = NOW() WHERE product_id = '" . (int)$product_id . "'"); line 175: foreach ($product_option['product_option_value'] as $product_option_value) { $this->db->query("INSERT INTO " . DB_PREFIX . "product_option_value SET product_option_value_id = '" . (int)$product_option_value['product_option_value_id'] . "', product_option_id = '" . (int)$product_option_id . "', product_id = '" . (int)$product_id . "', option_id = '" . (int)$product_option['option_id'] . "', option_value_id = '" . (int)$product_option_value['option_value_id'] . "', quantity = '" . (int)$product_option_value['quantity'] . "', subtract = '" . (int)$product_option_value['subtract'] . "', price = '" . (float)$product_option_value['price'] . "', price_prefix = '" . $this->db->escape($product_option_value['price_prefix']) . "', points = '" . (int)$product_option_value['points'] . "', points_prefix = '" . $this->db->escape($product_option_value['points_prefix']) . "', weight = '" . (float)$product_option_value['weight'] . "', weight_prefix = '" . $this->db->escape($product_option_value['weight_prefix']) . "'"); } how can fix this, please help me guys.
How to manipulate posted product price data before insert to database in opencart v2?
I am a beginner, I am trying to manipulate posted product price data before saving in opencart v2 but i couldn't do it. I tried that in controller and see my manipulation changes data in View (product_form.tpl). How works recording data on opencart? View (product_form.tpl) posts data to Controller (admin/controller/catalog/product.php) then Model (admin/model/catalog/product.php) takes data from controller, right? if (isset($this->request->post['price'])) { $data['price'] = $this->currency->convert($data['currency_price'], $data['product_currency'], $this->config->get('config_currency')); } elseif (!empty($product_info)) { $data['price'] = $product_info['price']; } else { $data['price'] = ''; }
I found that, maybe helps to someone.. If you want to manipulate data when you add product data, you can change variable before query in Model (admin/model/catalog/product.php); Original Code public function addProduct($data) { $this->event->trigger('pre.admin.product.add', $data); $this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()"); After Manipulation public function addProduct($data) { $this->event->trigger('pre.admin.product.add', $data); $data['price'] = $this->currency->convert($data['currency_price'], $data['currency_product'], $this->config->get('config_currency')); $this->db->query("INSERT INTO " . DB_PREFIX . "product SET model = '" . $this->db->escape($data['model']) . "', sku = '" . $this->db->escape($data['sku']) . "', upc = '" . $this->db->escape($data['upc']) . "', ean = '" . $this->db->escape($data['ean']) . "', jan = '" . $this->db->escape($data['jan']) . "', isbn = '" . $this->db->escape($data['isbn']) . "', mpn = '" . $this->db->escape($data['mpn']) . "', location = '" . $this->db->escape($data['location']) . "', quantity = '" . (int)$data['quantity'] . "', minimum = '" . (int)$data['minimum'] . "', subtract = '" . (int)$data['subtract'] . "', stock_status_id = '" . (int)$data['stock_status_id'] . "', date_available = '" . $this->db->escape($data['date_available']) . "', manufacturer_id = '" . (int)$data['manufacturer_id'] . "', shipping = '" . (int)$data['shipping'] . "', price = '" . (float)$data['price'] . "', points = '" . (int)$data['points'] . "', weight = '" . (float)$data['weight'] . "', weight_class_id = '" . (int)$data['weight_class_id'] . "', length = '" . (float)$data['length'] . "', width = '" . (float)$data['width'] . "', height = '" . (float)$data['height'] . "', length_class_id = '" . (int)$data['length_class_id'] . "', status = '" . (int)$data['status'] . "', tax_class_id = '" . (int)$data['tax_class_id'] . "', sort_order = '" . (int)$data['sort_order'] . "', date_added = NOW()");
Order Id is jumped up in opencart
I have a website in opencart the order id is jumping up. means if a person has order something on website and his order id is 49 the order id of the next order should be 50 but it is shown as 51 or 52. When I check in the database table oc_order it shown the same order for the missing order no. class ModelCheckoutOrder extends Model { public function addOrder($data) { $this->db->query("INSERT INTO `" . DB_PREFIX . "order` SET invoice_prefix = '" . $this->db->escape($data['invoice_prefix']) . "', store_id = '" . (int)$data['store_id'] . "', store_name = '" . $this->db->escape($data['store_name']) . "', store_url = '" . $this->db->escape($data['store_url']) . "', customer_id = '" . (int)$data['customer_id'] . "', customer_group_id = '" . (int)$data['customer_group_id'] . "', emp_name = '" . $this->db->escape($data['emp_name']) . "', emp_ID = '" . $this->db->escape($data['emp_ID']) . "', email = '" . $this->db->escape($data['email']) . "', mobile_no = '" . $this->db->escape($data['mobile_no']) . "', fax = '" . $this->db->escape($data['fax']) . "', payment_emp_name = '" . $this->db->escape($data['payment_emp_name']) . "', payment_emp_ID = '" . $this->db->escape($data['payment_emp_ID']) . "', payment_company = '" . $this->db->escape($data['payment_company']) . "', payment_company_id = '" . $this->db->escape($data['payment_company_id']) . "', payment_tax_id = '" . $this->db->escape($data['payment_tax_id']) . "', payment_address_1 = '" . $this->db->escape($data['payment_address_1']) . "', payment_address_2 = '" . $this->db->escape($data['payment_address_2']) . "', payment_city = '" . $this->db->escape($data['payment_city']) . "', payment_postcode = '" . $this->db->escape($data['payment_postcode']) . "', payment_country = '" . $this->db->escape($data['payment_country']) . "', payment_country_id = '" . (int)$data['payment_country_id'] . "', payment_zone = '" . $this->db->escape($data['payment_zone']) . "', payment_zone_id = '" . (int)$data['payment_zone_id'] . "', payment_address_format = '" . $this->db->escape($data['payment_address_format']) . "', payment_method = '" . $this->db->escape($data['payment_method']) . "', payment_code = '" . $this->db->escape($data['payment_code']) . "', shipping_emp_name = '" . $this->db->escape($data['shipping_emp_name']) . "', shipping_emp_ID = '" . $this->db->escape($data['shipping_emp_ID']) . "', shipping_company = '" . $this->db->escape($data['shipping_company']) . "', shipping_address_1 = '" . $this->db->escape($data['shipping_address_1']) . "', shipping_address_2 = '" . $this->db->escape($data['shipping_address_2']) . "', shipping_city = '" . $this->db->escape($data['shipping_city']) . "', shipping_postcode = '" . $this->db->escape($data['shipping_postcode']) . "', shipping_country = '" . $this->db->escape($data['shipping_country']) . "', shipping_country_id = '" . (int)$data['shipping_country_id'] . "', shipping_zone = '" . $this->db->escape($data['shipping_zone']) . "', shipping_zone_id = '" . (int)$data['shipping_zone_id'] . "', shipping_address_format = '" . $this->db->escape($data['shipping_address_format']) . "', shipping_method = '" . $this->db->escape($data['shipping_method']) . "', shipping_code = '" . $this->db->escape($data['shipping_code']) . "', comment = '" . $this->db->escape($data['comment']) . "', total = '" . (float)$data['total'] . "', affiliate_id = '" . (int)$data['affiliate_id'] . "', commission = '" . (float)$data['commission'] . "', language_id = '" . (int)$data['language_id'] . "', currency_id = '" . (int)$data['currency_id'] . "', currency_code = '" . $this->db->escape($data['currency_code']) . "', currency_value = '" . (float)$data['currency_value'] . "', ip = '" . $this->db->escape($data['ip']) . "', forwarded_ip = '" . $this->db->escape($data['forwarded_ip']) . "', user_agent = '" . $this->db->escape($data['user_agent']) . "', accept_language = '" . $this->db->escape($data['accept_language']) . "', date_added = NOW(), date_modified = NOW()"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '1', comment = '" . $this->db->escape(($comment && $notify) ? $comment : '') . "', date_added = NOW()"); $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'"); foreach ($order_product_query->rows as $order_product) { $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_id = '" . (int)$order_product['product_id'] . "' AND subtract = '1'"); $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$order_product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$order_product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'"); } }
this is because there is a difference between what you see in the database itself and what you see in the orders admin page. and this difference is due to the fact that opencart stores something called a missing order id, and that happens for example one someone fills all the details and then by mistake he just reloads the checkout page and then he just press the "confirm" button. at this case for example in the orders admin page he booked two orders number and you will only see the second number - ofc the number of order ids skipped is the same as the number of missing orders stored by opencart itself. if you want to test this go to checkout page and fill all orders and then confirm it, at this case you wont see any difference, however if you go to checkout page fill all info and then reload the page and then just press confirm you will see that the order id will skip one number. in opencart database you wont see missing order ids, because opencart insert an order in the database only if it was confirmed.
Why does this keep give syntax error or $_end error?
<?php if(isset($_POST['update'])) $dbhost = 'localhost'; $dbuser = 'XXXXX'; $dbpass = 'XXXXX'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } if(! get_magic_quotes_gpc() ) { $OrderID=addslashes ($_POST['OrderID']); $trackingnumber= addslashes ($_POST['trackingnumber']); $trackingURL=addslashes ($_POST['trackingURL']); $CustomerName=addslashes ($_POST['CustomerName']); $LocationShipped=addslashes ($_POST['LocationShipped']); $user_email=addslashes ($_POST['user_email']); $ShipmentDate=addslashes ($_POST['ShipmentDate']); $ShipmentMode=addslashes ($_POST['ShipmentMode']); $CurrentStatus=addslashes ($_POST['CurrentStatus']); } else { $trackingnumber= $_POST['trackingnumber']; $trackingURL=$_POST['trackingURL']; $OrderID=$_POST['OrderID']; $CustomerName=$_POST['CustomerName']; $user_email=$_POST['user_email']; $LocationShipped=$_POST['LocationShipped']; $ShipmentDate=$_POST['ShipmentDate']; $ShipmentMode=$_POST['ShipmentMode']; $CurrentStatus=$_POST['CurrentStatus']; } $sql = " UPDATE ordertracking SET trackingnumber =$trackingnumber, `trackingURL` = '" . $trackingURL . "', `CustomerName` = '" . $CustomerName . "', `LocationShipped` = '" . $LocationShipped . "', `user_email` = '" . $user_email . "', `ShipmentDate` = '" . $ShipmentDate . "', `ShipmentMode` = '" . $ShipmentMode . "', `CurrentStatus` = '" . $CurrentStatus . "', WHERE OrderNo = $OrderID, $result1 = mysql_query($query1); mysql_select_db('XXXXXXX'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('Could not enter data: ' . mysql_error()); } echo "Entered data successfully\n"; mysql_close($conn); ?> Parse error: syntax error, unexpected T_STRING in /home/buyerhel/public_html/ordertracking/backend/processeditship.php on line 46 Any help please ? Not sure what the problem is but it is really frustrating since I am on my last step for the Edit Section of the my project and it is allowing me to update the table. I purposely left out the quotes here - trackingnumber =$trackingnumber, So that is not the problem.. The
There is no ending symbol " in your $sql. Should be: $sql = " UPDATE ordertracking SET trackingnumber =$trackingnumber, `trackingURL` = '" . $trackingURL . "', `CustomerName` = '" . $CustomerName . "', `LocationShipped` = '" . $LocationShipped . "', `user_email` = '" . $user_email . "', `ShipmentDate` = '" . $ShipmentDate . "', `ShipmentMode` = '" . $ShipmentMode . "', `CurrentStatus` = '" . $CurrentStatus . "' WHERE OrderNo = $OrderID"; // < missing ";
You've used , instead of ; and forgot some ". $sql = " UPDATE `ordertracking` SET `trackingnumber` = " . $trackingnumber . ", `trackingURL` = '" . $trackingURL . "', `CustomerName` = '" . $CustomerName . "', `LocationShipped` = '" . $LocationShipped . "', `user_email` = '" . $user_email . "', `ShipmentDate` = '" . $ShipmentDate . "', `ShipmentMode` = '" . $ShipmentMode . "', `CurrentStatus` = '" . $CurrentStatus . "', WHERE `OrderNo` = " . $OrderID; // ; instead of , $result1 = mysql_query($query1);
Just replace Line no 50 OrderNo = $OrderID"; by this code
Two problems Close the double qoutes Remove the trailing comma after $OrderID So change $sql = " UPDATE ordertracking SET trackingnumber =$trackingnumber, `trackingURL` = '" . $trackingURL . "', `CustomerName` = '" . $CustomerName . "', `LocationShipped` = '" . $LocationShipped . "', `user_email` = '" . $user_email . "', `ShipmentDate` = '" . $ShipmentDate . "', `ShipmentMode` = '" . $ShipmentMode . "', `CurrentStatus` = '" . $CurrentStatus . "', WHERE OrderNo = $OrderID, to $sql = " UPDATE ordertracking SET trackingnumber =$trackingnumber, `trackingURL` = '" . $trackingURL . "', `CustomerName` = '" . $CustomerName . "', `LocationShipped` = '" . $LocationShipped . "', `user_email` = '" . $user_email . "', `ShipmentDate` = '" . $ShipmentDate . "', `ShipmentMode` = '" . $ShipmentMode . "', `CurrentStatus` = '" . $CurrentStatus . "', WHERE OrderNo = $OrderID";