-
Posts
24,565 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Curiously your table structure (from phpMyAdmin) shows year and month in separate columns yet your code is exploding datecolumn using "/"? What does this output... echo '<pre>'; var_export($data); echo '</pre>';
-
None with out knowing what the data you are processing looks like.
-
I have no idea how the function getQueryCount() is defined or what arguments it expects, but you appear to be passing 3 arguments in the one that works and 4 5 in the one that fails. Check your reference manual. Arguments... Array ( [0] => tbl_trades [1] => lg_short_trade [2] => AND lg_short_trade="Long" AND num_bot_trade="42" ) Array ( [0] => tbl_trades [1] => lg_short_trade [2] => AND lg_short_trade="Long" [3] => pnl_trade [4] => AND pnl_trade > 0 AND num_bot_trade="42" )
-
Take your pick, sql or php solution? $theDate = '2021-04-18 10:45:26'; $d1 = new DateTime($theDate); $elapsed = $d1->diff(new DateTime())->days; echo $elapsed; //--> 23 or SELECT datestarted , datediff(CURDATE(), datestarted) as elapsed FROM ...
-
1 ) Use code tags ("<>" button in the toolbar). I have edited your posts so far; in future I'll delete any vast tracts of code.. 2 ) Post relevant code - I doubt anyone will bother wading through all the code you posted. https://forums.phpfreaks.com/guidelines/
-
It is slightly different from yours A set of selections is valid only for a selected game, whereas yours is valid for 19 games. I update the database with each selection as soon as it is clicked (recording game_id/user_id/square_id) There is no on-line monetary collection. You paid the club treasurer in cash. One problem was that no-one wanted to bet on my team's score ending (or starting) with anything other than zero, even though I remember we did score once.
-
Oh right. It's one of those. I wrote an application like that about three years ago. If you want to display what has been selected then hidden fields don't seem the best option to me
-
Probably one of his other clients caught up with him In which case, sqNum_64 is the only one out of the hundred that won't give you an error. Do as mac_gyver suggested and name your inputs ... name="sqNum[n]" where n is a number from 1 to 100. You can then process the input withsomething like ... foreach ($_POST['sqNum'] as $i => $val) { // process $i } Out of curiosity, what does the input form code look like and what is it supposed to do?
-
What does your POST array actually contain? Put this before the for() loop. echo '<pre>' . print_r($_POST, 1) . '</pre>';
-
Open the txt file before the loop and close it after the loop.
-
Use the "<>" button when posting code. All I can tell you from the information given is "Something went wrong". Whey don't you get mysqli to tell you what went wrong. The easiest way is to put this line of code just above the line where you create your mysqli connection mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT);
-
You were complaining that the code sample I gave you didn't use the functions in your CMS. As I don't have your CMS, or even the function documentation for it, there would be no way I could test the code before posting. You are not being denied help. I am saying that under those restrictions, I personally cannot help. There are plenty of others on this forum willing to help. Also, any solutions I post here are not just for you but for others who may come along later looking for a solution to a similar problem, and they too will probably not use your CMS.
-
Point taken. In future I shall have to remember not to respond to any of your problems because I, like the majority of others, do not have your CMS.
-
Here's sample code I wrote a few years back. DATA mysql> select * from category; +----+-----------+--------+ | id | service | parent | +----+-----------+--------+ | 1 | Cat 1 | 0 | | 2 | Cat 2 | 0 | | 3 | Cat 3 | 0 | | 4 | Cat 1 1 | 1 | | 5 | Cat 1 2 | 1 | | 6 | Cat 2 1 | 2 | | 7 | Cat 2 2 | 2 | | 8 | Cat 2 3 | 2 | | 9 | Cat 3 1 | 3 | | 10 | Cat 1 1 1 | 4 | | 11 | Cat 1 1 2 | 4 | | 12 | Cat 2 3 1 | 8 | +----+-----------+--------+ OUTPUT CODE <?php $sql = "SELECT id, service, parent FROM category"; $res = $db->query($sql); // // store arrays of items for each parent in an array // while (list($id, $name, $parent) = $res->fetch_row()) { $data[$parent][] = array('id'=>$id, 'name'=>$name); } /** * recursive function to print a category then its child categories * * @param array $arr category data * @param int $parent parent category * @param int $level hierarchy level */ function displayHierarchy(&$arr, $parent, $level=0) { if (isset($arr[$parent])) { echo "<ul class='ul$level'>\n"; foreach($arr[$parent] as $rec) { echo "<li class='li$level'>{$rec['name']}\n"; if (isset($arr[$rec['id']])) displayHierarchy($arr, $rec['id'], $level+1); echo "</li>\n"; } echo "</ul>\n"; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Subcategories Example</title> </head> <body> <?php displayHierarchy($data, 0); ?> </body> </html>
-
Notice: A non well formed numeric value encountered in
Barand replied to Federica's topic in PHP Coding Help
microtime() without an argument returns a weird string format (eg "0.94624300 1620376872" ) that is not a valid number. Use microtime(true) to get a numeric value (eg 1620377011.4593). See https://www.php.net/microtime -
One problem you will have is that for any offset there are usually several possible names. For your "+05:30" example there are only two but as the array below shows, there are usualy quite a few more ... $timezones = array ( '+00:00' => array ( 0 => 'Africa/Abidjan', 1 => 'Africa/Accra', 2 => 'Africa/Bamako', 3 => 'Africa/Banjul', 4 => 'Africa/Bissau', 5 => 'Africa/Casablanca', 6 => 'Africa/Conakry', 7 => 'Africa/Dakar', 8 => 'Africa/El_Aaiun', 9 => 'Africa/Freetown', 10 => 'Africa/Lome', 11 => 'Africa/Monrovia', 12 => 'Africa/Nouakchott', 13 => 'Africa/Ouagadougou', 14 => 'Africa/Sao_Tome', 15 => 'America/Danmarkshavn', 16 => 'America/Scoresbysund', 17 => 'Atlantic/Azores', 18 => 'Atlantic/Reykjavik', 19 => 'Atlantic/St_Helena', 20 => 'UTC', ), '+01:00' => array ( 0 => 'Africa/Algiers', 1 => 'Africa/Bangui', 2 => 'Africa/Brazzaville', 3 => 'Africa/Douala', 4 => 'Africa/Kinshasa', 5 => 'Africa/Lagos', 6 => 'Africa/Libreville', 7 => 'Africa/Luanda', 8 => 'Africa/Malabo', 9 => 'Africa/Ndjamena', 10 => 'Africa/Niamey', 11 => 'Africa/Porto-Novo', 12 => 'Africa/Tunis', 13 => 'Atlantic/Canary', 14 => 'Atlantic/Faroe', 15 => 'Atlantic/Madeira', 16 => 'Europe/Dublin', 17 => 'Europe/Guernsey', 18 => 'Europe/Isle_of_Man', 19 => 'Europe/Jersey', 20 => 'Europe/Lisbon', 21 => 'Europe/London', ), '+02:00' => array ( 0 => 'Africa/Blantyre', 1 => 'Africa/Bujumbura', 2 => 'Africa/Cairo', 3 => 'Africa/Ceuta', 4 => 'Africa/Gaborone', 5 => 'Africa/Harare', 6 => 'Africa/Johannesburg', 7 => 'Africa/Khartoum', 8 => 'Africa/Kigali', 9 => 'Africa/Lubumbashi', 10 => 'Africa/Lusaka', 11 => 'Africa/Maputo', 12 => 'Africa/Maseru', 13 => 'Africa/Mbabane', 14 => 'Africa/Tripoli', 15 => 'Africa/Windhoek', 16 => 'Antarctica/Troll', 17 => 'Arctic/Longyearbyen', 18 => 'Europe/Amsterdam', 19 => 'Europe/Andorra', 20 => 'Europe/Belgrade', 21 => 'Europe/Berlin', 22 => 'Europe/Bratislava', 23 => 'Europe/Brussels', 24 => 'Europe/Budapest', 25 => 'Europe/Busingen', 26 => 'Europe/Copenhagen', 27 => 'Europe/Gibraltar', 28 => 'Europe/Kaliningrad', 29 => 'Europe/Ljubljana', 30 => 'Europe/Luxembourg', 31 => 'Europe/Madrid', 32 => 'Europe/Malta', 33 => 'Europe/Monaco', 34 => 'Europe/Oslo', 35 => 'Europe/Paris', 36 => 'Europe/Podgorica', 37 => 'Europe/Prague', 38 => 'Europe/Rome', 39 => 'Europe/San_Marino', 40 => 'Europe/Sarajevo', 41 => 'Europe/Skopje', 42 => 'Europe/Stockholm', 43 => 'Europe/Tirane', 44 => 'Europe/Vaduz', 45 => 'Europe/Vatican', 46 => 'Europe/Vienna', 47 => 'Europe/Warsaw', 48 => 'Europe/Zagreb', 49 => 'Europe/Zurich', ), '+03:00' => array ( 0 => 'Africa/Addis_Ababa', 1 => 'Africa/Asmara', 2 => 'Africa/Dar_es_Salaam', 3 => 'Africa/Djibouti', 4 => 'Africa/Juba', 5 => 'Africa/Kampala', 6 => 'Africa/Mogadishu', 7 => 'Africa/Nairobi', 8 => 'Antarctica/Syowa', 9 => 'Asia/Aden', 10 => 'Asia/Amman', 11 => 'Asia/Baghdad', 12 => 'Asia/Bahrain', 13 => 'Asia/Beirut', 14 => 'Asia/Damascus', 15 => 'Asia/Famagusta', 16 => 'Asia/Gaza', 17 => 'Asia/Hebron', 18 => 'Asia/Jerusalem', 19 => 'Asia/Kuwait', 20 => 'Asia/Nicosia', 21 => 'Asia/Qatar', 22 => 'Asia/Riyadh', 23 => 'Europe/Athens', 24 => 'Europe/Bucharest', 25 => 'Europe/Chisinau', 26 => 'Europe/Helsinki', 27 => 'Europe/Istanbul', 28 => 'Europe/Kiev', 29 => 'Europe/Kirov', 30 => 'Europe/Mariehamn', 31 => 'Europe/Minsk', 32 => 'Europe/Moscow', 33 => 'Europe/Riga', 34 => 'Europe/Simferopol', 35 => 'Europe/Sofia', 36 => 'Europe/Tallinn', 37 => 'Europe/Uzhgorod', 38 => 'Europe/Vilnius', 39 => 'Europe/Volgograd', 40 => 'Europe/Zaporozhye', 41 => 'Indian/Antananarivo', 42 => 'Indian/Comoro', 43 => 'Indian/Mayotte', ), '+04:00' => array ( 0 => 'Asia/Baku', 1 => 'Asia/Dubai', 2 => 'Asia/Muscat', 3 => 'Asia/Tbilisi', 4 => 'Asia/Yerevan', 5 => 'Europe/Astrakhan', 6 => 'Europe/Samara', 7 => 'Europe/Saratov', 8 => 'Europe/Ulyanovsk', 9 => 'Indian/Mahe', 10 => 'Indian/Mauritius', 11 => 'Indian/Reunion', ), '+04:30' => array ( 0 => 'Asia/Kabul', 1 => 'Asia/Tehran', ), '+05:00' => array ( 0 => 'Antarctica/Mawson', 1 => 'Asia/Aqtau', 2 => 'Asia/Aqtobe', 3 => 'Asia/Ashgabat', 4 => 'Asia/Atyrau', 5 => 'Asia/Dushanbe', 6 => 'Asia/Karachi', 7 => 'Asia/Oral', 8 => 'Asia/Samarkand', 9 => 'Asia/Tashkent', 10 => 'Asia/Yekaterinburg', 11 => 'Indian/Kerguelen', 12 => 'Indian/Maldives', ), '+05:30' => array ( 0 => 'Asia/Colombo', 1 => 'Asia/Kolkata', ), '+05:45' => array ( 0 => 'Asia/Kathmandu', ), '+06:00' => array ( 0 => 'Antarctica/Vostok', 1 => 'Asia/Almaty', 2 => 'Asia/Bishkek', 3 => 'Asia/Dhaka', 4 => 'Asia/Omsk', 5 => 'Asia/Qyzylorda', 6 => 'Asia/Thimphu', 7 => 'Asia/Urumqi', 8 => 'Indian/Chagos', ), '+06:30' => array ( 0 => 'Asia/Yangon', 1 => 'Indian/Cocos', ), '+07:00' => array ( 0 => 'Antarctica/Davis', 1 => 'Asia/Bangkok', 2 => 'Asia/Barnaul', 3 => 'Asia/Ho_Chi_Minh', 4 => 'Asia/Hovd', 5 => 'Asia/Jakarta', 6 => 'Asia/Krasnoyarsk', 7 => 'Asia/Novokuznetsk', 8 => 'Asia/Novosibirsk', 9 => 'Asia/Phnom_Penh', 10 => 'Asia/Pontianak', 11 => 'Asia/Tomsk', 12 => 'Asia/Vientiane', 13 => 'Indian/Christmas', ), '+08:00' => array ( 0 => 'Asia/Brunei', 1 => 'Asia/Choibalsan', 2 => 'Asia/Hong_Kong', 3 => 'Asia/Irkutsk', 4 => 'Asia/Kuala_Lumpur', 5 => 'Asia/Kuching', 6 => 'Asia/Macau', 7 => 'Asia/Makassar', 8 => 'Asia/Manila', 9 => 'Asia/Shanghai', 10 => 'Asia/Singapore', 11 => 'Asia/Taipei', 12 => 'Asia/Ulaanbaatar', 13 => 'Australia/Perth', ), '+08:30' => array ( 0 => 'Asia/Pyongyang', ), '+08:45' => array ( 0 => 'Australia/Eucla', ), '+09:00' => array ( 0 => 'Asia/Chita', 1 => 'Asia/Dili', 2 => 'Asia/Jayapura', 3 => 'Asia/Khandyga', 4 => 'Asia/Seoul', 5 => 'Asia/Tokyo', 6 => 'Asia/Yakutsk', 7 => 'Pacific/Palau', ), '+09:30' => array ( 0 => 'Australia/Adelaide', 1 => 'Australia/Broken_Hill', 2 => 'Australia/Darwin', ), '+10:00' => array ( 0 => 'Antarctica/DumontDUrville', 1 => 'Asia/Ust-Nera', 2 => 'Asia/Vladivostok', 3 => 'Australia/Brisbane', 4 => 'Australia/Currie', 5 => 'Australia/Hobart', 6 => 'Australia/Lindeman', 7 => 'Australia/Melbourne', 8 => 'Australia/Sydney', 9 => 'Pacific/Chuuk', 10 => 'Pacific/Guam', 11 => 'Pacific/Port_Moresby', 12 => 'Pacific/Saipan', ), '+10:30' => array ( 0 => 'Australia/Lord_Howe', ), '+11:00' => array ( 0 => 'Antarctica/Casey', 1 => 'Antarctica/Macquarie', 2 => 'Asia/Magadan', 3 => 'Asia/Sakhalin', 4 => 'Asia/Srednekolymsk', 5 => 'Pacific/Bougainville', 6 => 'Pacific/Efate', 7 => 'Pacific/Guadalcanal', 8 => 'Pacific/Kosrae', 9 => 'Pacific/Norfolk', 10 => 'Pacific/Noumea', 11 => 'Pacific/Pohnpei', ), '+12:00' => array ( 0 => 'Antarctica/McMurdo', 1 => 'Asia/Anadyr', 2 => 'Asia/Kamchatka', 3 => 'Pacific/Auckland', 4 => 'Pacific/Fiji', 5 => 'Pacific/Funafuti', 6 => 'Pacific/Kwajalein', 7 => 'Pacific/Majuro', 8 => 'Pacific/Nauru', 9 => 'Pacific/Tarawa', 10 => 'Pacific/Wake', 11 => 'Pacific/Wallis', ), '+12:45' => array ( 0 => 'Pacific/Chatham', ), '+13:00' => array ( 0 => 'Pacific/Apia', 1 => 'Pacific/Enderbury', 2 => 'Pacific/Fakaofo', 3 => 'Pacific/Tongatapu', ), '+14:00' => array ( 0 => 'Pacific/Kiritimati', ), '-01:00' => array ( 0 => 'Atlantic/Cape_Verde', ), '-02:-30' => array ( 0 => 'America/St_Johns', ), '-02:00' => array ( 0 => 'America/Godthab', 1 => 'America/Miquelon', 2 => 'America/Noronha', 3 => 'Atlantic/South_Georgia', ), '-03:00' => array ( 0 => 'America/Araguaina', 1 => 'America/Argentina/Buenos_Aires', 2 => 'America/Argentina/Catamarca', 3 => 'America/Argentina/Cordoba', 4 => 'America/Argentina/Jujuy', 5 => 'America/Argentina/La_Rioja', 6 => 'America/Argentina/Mendoza', 7 => 'America/Argentina/Rio_Gallegos', 8 => 'America/Argentina/Salta', 9 => 'America/Argentina/San_Juan', 10 => 'America/Argentina/San_Luis', 11 => 'America/Argentina/Tucuman', 12 => 'America/Argentina/Ushuaia', 13 => 'America/Bahia', 14 => 'America/Belem', 15 => 'America/Cayenne', 16 => 'America/Fortaleza', 17 => 'America/Glace_Bay', 18 => 'America/Goose_Bay', 19 => 'America/Halifax', 20 => 'America/Maceio', 21 => 'America/Moncton', 22 => 'America/Montevideo', 23 => 'America/Paramaribo', 24 => 'America/Punta_Arenas', 25 => 'America/Recife', 26 => 'America/Santarem', 27 => 'America/Santiago', 28 => 'America/Sao_Paulo', 29 => 'America/Thule', 30 => 'Antarctica/Palmer', 31 => 'Antarctica/Rothera', 32 => 'Atlantic/Bermuda', 33 => 'Atlantic/Stanley', ), '-04:00' => array ( 0 => 'America/Anguilla', 1 => 'America/Antigua', 2 => 'America/Aruba', 3 => 'America/Asuncion', 4 => 'America/Barbados', 5 => 'America/Blanc-Sablon', 6 => 'America/Boa_Vista', 7 => 'America/Campo_Grande', 8 => 'America/Caracas', 9 => 'America/Cuiaba', 10 => 'America/Curacao', 11 => 'America/Detroit', 12 => 'America/Dominica', 13 => 'America/Grand_Turk', 14 => 'America/Grenada', 15 => 'America/Guadeloupe', 16 => 'America/Guyana', 17 => 'America/Havana', 18 => 'America/Indiana/Indianapolis', 19 => 'America/Indiana/Marengo', 20 => 'America/Indiana/Petersburg', 21 => 'America/Indiana/Vevay', 22 => 'America/Indiana/Vincennes', 23 => 'America/Indiana/Winamac', 24 => 'America/Iqaluit', 25 => 'America/Kentucky/Louisville', 26 => 'America/Kentucky/Monticello', 27 => 'America/Kralendijk', 28 => 'America/La_Paz', 29 => 'America/Lower_Princes', 30 => 'America/Manaus', 31 => 'America/Marigot', 32 => 'America/Martinique', 33 => 'America/Montserrat', 34 => 'America/Nassau', 35 => 'America/New_York', 36 => 'America/Nipigon', 37 => 'America/Pangnirtung', 38 => 'America/Port-au-Prince', 39 => 'America/Port_of_Spain', 40 => 'America/Porto_Velho', 41 => 'America/Puerto_Rico', 42 => 'America/Santo_Domingo', 43 => 'America/St_Barthelemy', 44 => 'America/St_Kitts', 45 => 'America/St_Lucia', 46 => 'America/St_Thomas', 47 => 'America/St_Vincent', 48 => 'America/Thunder_Bay', 49 => 'America/Toronto', 50 => 'America/Tortola', ), '-05:00' => array ( 0 => 'America/Atikokan', 1 => 'America/Bahia_Banderas', 2 => 'America/Bogota', 3 => 'America/Cancun', 4 => 'America/Cayman', 5 => 'America/Chicago', 6 => 'America/Eirunepe', 7 => 'America/Guayaquil', 8 => 'America/Indiana/Knox', 9 => 'America/Indiana/Tell_City', 10 => 'America/Jamaica', 11 => 'America/Lima', 12 => 'America/Matamoros', 13 => 'America/Menominee', 14 => 'America/Merida', 15 => 'America/Mexico_City', 16 => 'America/Monterrey', 17 => 'America/North_Dakota/Beulah', 18 => 'America/North_Dakota/Center', 19 => 'America/North_Dakota/New_Salem', 20 => 'America/Panama', 21 => 'America/Rainy_River', 22 => 'America/Rankin_Inlet', 23 => 'America/Resolute', 24 => 'America/Rio_Branco', 25 => 'America/Winnipeg', 26 => 'Pacific/Easter', ), '-06:00' => array ( 0 => 'America/Belize', 1 => 'America/Boise', 2 => 'America/Cambridge_Bay', 3 => 'America/Chihuahua', 4 => 'America/Costa_Rica', 5 => 'America/Denver', 6 => 'America/Edmonton', 7 => 'America/El_Salvador', 8 => 'America/Guatemala', 9 => 'America/Inuvik', 10 => 'America/Managua', 11 => 'America/Mazatlan', 12 => 'America/Ojinaga', 13 => 'America/Regina', 14 => 'America/Swift_Current', 15 => 'America/Tegucigalpa', 16 => 'America/Yellowknife', 17 => 'Pacific/Galapagos', ), '-07:00' => array ( 0 => 'America/Creston', 1 => 'America/Dawson', 2 => 'America/Dawson_Creek', 3 => 'America/Fort_Nelson', 4 => 'America/Hermosillo', 5 => 'America/Los_Angeles', 6 => 'America/Phoenix', 7 => 'America/Tijuana', 8 => 'America/Vancouver', 9 => 'America/Whitehorse', ), '-08:00' => array ( 0 => 'America/Anchorage', 1 => 'America/Juneau', 2 => 'America/Metlakatla', 3 => 'America/Nome', 4 => 'America/Sitka', 5 => 'America/Yakutat', 6 => 'Pacific/Pitcairn', ), '-09:-30' => array ( 0 => 'Pacific/Marquesas', ), '-09:00' => array ( 0 => 'America/Adak', 1 => 'Pacific/Gambier', ), '-10:00' => array ( 0 => 'Pacific/Honolulu', 1 => 'Pacific/Rarotonga', 2 => 'Pacific/Tahiti', ), '-11:00' => array ( 0 => 'Pacific/Midway', 1 => 'Pacific/Niue', 2 => 'Pacific/Pago_Pago', ), );
-
-
I'm using IIS on Windows 10 Home. AFAIK, it just need kicking into life using IIS Manager.
-
If you have Windows, IIS should already be installed.
-
Depends the structure you want for your array. Using your existing query... $res = $pdo->query("SELECT i.title_eng as title , d.content_eng as content FROM tb_helpinfo i INNER JOIN tb_helpdetail d ON i.id = d.helpinfo_id ORDER BY title "); ## METHOD 1 $data = []; foreach ($res as $r) { if (!isset($data[$r['title']])) { $data[$r['title']] = []; } $data[$r['title']][] = $r['content']; } echo '<pre> Method 1 ', print_r($data, 1), '</pre>'; echo json_encode($data); ## METHOD 2 $data = $res->fetchAll(); echo '<pre> Method 2 ', print_r($data, 1), '</pre>'; echo json_encode($data);
-
Did you just want to advertise the results of your efforts or do you actually have a question?
-
"password" is a keyword (and, I agree, best avoided) but is not a reserved word requiring backticks. @Kausalya use password_hash() and password_verify() when storing and checking passwords.
-
Check the column definition in your table. If you make it UNSIGNED you can double that value, which will take you to the year 2106. echo date('Y-m-d', 4294967294); // 2106-02-07 Better still, use date or DATE/DATETIME fields for dates - that's what they're there for.
-
I suggest you turn on error reporting in your php.ini file.
-
WHERE id = ? AND FirstImage IN (0,1)