-
Posts
24,605 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
Run this script <?php phpinfo(); ?> In the first part of the output look for the heading "Loaded Configuration File". That tells you the php.ini file that is being used and its location. That is the file you need to edit.
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
Where did you get your data? Your coordinates for airport CRL place it in the middle of the English Channel- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
yes- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
what about mysql> show variables like 'sql_big_sel%'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | sql_big_selects | ON | +-----------------+-------+ If it is OFF, try running the query "SET SQL_BIG_SELECTS = 1" before running your query.- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
And run this query (in phpMyAdmin or similar) and see what the result is SHOW VARIABLES LIKE 'max_join%'; EG mysql> SHOW VARIABLES LIKE 'max_join%'; +---------------+----------------------+ | Variable_name | Value | +---------------+----------------------+ | max_join_size | 18446744073709551615 | +---------------+----------------------+- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
I gave you the combined query. Can you attach an SQL dump of those two tables?- 23 replies
-
echo $Arr['scan_results']['scan_details']['F-prot']['scan_result_i'];
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
You use $result for the result of the first query and then use that same variable again inside the loop. Another reason not to be calling queries inside loops. As I said, get rid of that first query and replace it with the second, and just process those results. Are you running on a live host?- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
Those files are not particularly large, so I am baffled by that MAX_JOIN_SIZE error. The default is 18,446,744,073,709,551,615 which is a few more more than 1,352,000,000 (the cartesian product of your query, which is the number of rows returned if every record in the tables was joined with every record in the other tables ie 20000 x 260 x 260). Did you get an error message for that first query?- 23 replies
-
try foreach ($Arr['scan_results']['scan_details']['F-prot'] as $k => $v) { echo "$k : $v <br>"; }
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
Change die ("Cant do it!"); to die ($cnx->error); Then we can see why the first query is failing. You should not be running that first query any more. I said you should NOT run queries inside loops and you are still doing it. You should just be running the one combined query and process it's results. EDIT : How many rows in your tables?- 23 replies
-
- 1
-
-
can you alter your code to this $Arr = json_decode($FileScanner, true); echo '<pre>' . print_r($Arr, true) . '</pre>'; That should make it easier to read.
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
Those errors are not from $cxn_>error. Where you had or die("no can do"); change to or die($cxn->error); Is that simple enough?- 23 replies
-
- 1
-
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
you were supposed be outputting $cxn_error instead of "no can do"- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
try outputting a meaningful, helpful message, like $cxn->error- 23 replies
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
Don't run queries inside loops - it eats server resources. Combine the two queries into one. SELECT d.Latitude AS departure_lat , d.Longitude AS depatrure_lng , a.Latitude AS arrival_lat , a.Longitude AS arrival_lng FROM rosters INNER JOIN airport a ON a.IATA = rosters.Arr INNER JOIN airport d ON d.IATA = rosters.Dep WHERE rosters.Arr = 'CRL' AND rosters.Dep = 'BGY'; AND Code = '$Code' AND SectorDate >= '$today' ORDER BY RostersID- 23 replies
-
There is no direct equivalent of mysql_result(), which was inefficient anyway. You would fetch the row then reference that to get the data $row = mysqli_fetch_row($age); echo $row[0]; Bad idea to have your age variable and your query result both with the same "$age".
-
retrieving mysql data with table joins using one query
Barand replied to unistake's topic in PHP Coding Help
try SELECT d.Latitude AS departure_lat , d.Longitude AS depatrure_lng , a.Latitude AS arrival_lat , a.Longitude AS arrival_lng FROM rosters INNER JOIN airport a ON a.IATA = rosters.Arr INNER JOIN airport d ON d.IATA = rosters.Dep WHERE rosters.Arr = 'CRL' AND rosters.Dep = 'BGY'- 23 replies
-
You cannot mix mysql_ and mysqli_ functions, Use just mysqli_ library.
-
Brand New to PHP... AND I haven't coded in a few years... :)
Barand replied to Gregan's topic in PHP Coding Help
Disregard my last post, I understand your data array structure now. This "works" but I don't know what results you are expecting. <?php $colors = [ [ 'color'=> '# 000000 '], [ 'color'=> '# 97233F '], [ 'color'=> '# 841F27 '], [ 'color'=> '# A71930 '], [ 'color'=> '# EF0107 '], [ 'color'=> '# 94BEE5 '], [ 'color'=> '# CE1141 '], [ 'color'=> '# E13A3E '], [ 'color'=> '# DF4601 '], [ 'color'=> '# 241773 '], [ 'color'=> '# 008348 '], [ 'color'=> '# BD3039 '], [ 'color'=> '# 061922 '], [ 'color'=> '# 00338D '], [ 'color'=> '# 002E62 '], [ 'color'=> '# 8CCCE5 '], [ 'color'=> '# E03A3E '], [ 'color'=> '# 0085CA '], [ 'color'=> '# 1D1160 '], [ 'color'=> '# 034694 '], [ 'color'=> '# 0B162A '], [ 'color'=> '# E3263A '], [ 'color'=> '# CC3433 '], [ 'color'=> '# AF2626 '], [ 'color'=> '# AA002C '], [ 'color'=> '# C6011F '], [ 'color'=> '# FB4F14 '], [ 'color'=> '# 860038 '], [ 'color'=> '# E31937 '], [ 'color'=> '# 8B2942 '], [ 'color'=> '# 91022D '], [ 'color'=> '# 333366 '], [ 'color'=> '# 00285C '], [ 'color'=> '# 1B458F '], [ 'color'=> '# 002244 '], [ 'color'=> '# 007DC5 '], [ 'color'=> '# 006A4E '], [ 'color'=> '# 4D90CD '], [ 'color'=> '# 005A8B '], [ 'color'=> '# ED174C '], [ 'color'=> '# EC1F26 '], [ 'color'=> '# 0C2C56 '], [ 'color'=> '# 003777 '], [ 'color'=> '# 274488 '], [ 'color'=> '# CF0032 '], [ 'color'=> '# C8213F '], [ 'color'=> '# FDB927 '], [ 'color'=> '# 203731 '], [ 'color'=> '# 002D62 '], [ 'color'=> '# F36600 '], [ 'color'=> '# 03202F '], [ 'color'=> '# F5A12D '], [ 'color'=> '# FFC633 '], [ 'color'=> '# 002C5F '], [ 'color'=> '# E31837 '], [ 'color'=> '# 004687 '], [ 'color'=> '# FDBE11 '], [ 'color'=> '# 00A398 '], [ 'color'=> '# BA0021 '], [ 'color'=> '# EF3E42 '], [ 'color'=> '# 00245D '], [ 'color'=> '# 5CBFEB '], [ 'color'=> '# DA020E '], [ 'color'=> '# 0F586C '], [ 'color'=> '# 008E97 '], [ 'color'=> '# 98002E '], [ 'color'=> '# FF6600 '], [ 'color'=> '# 0A2351 '], [ 'color'=> '# 00471B '], [ 'color'=> '# 005083 '], [ 'color'=> '# 002B5C '], [ 'color'=> '# 4F2683 '], [ 'color'=> '# 025736 '], [ 'color'=> '# BF2F38 '], [ 'color'=> '# 122089 '], [ 'color'=> '# FDBB2F '], [ 'color'=> '# 0A2141 '], [ 'color'=> '# 9F8958 '], [ 'color'=> '# 6CADDF '], [ 'color'=> '# 0B2265 '], [ 'color'=> '# 00529B '], [ 'color'=> '# 006BB6 '], [ 'color'=> '# FF5910 '], [ 'color'=> '# 0161AB '], [ 'color'=> '# D50031 '], [ 'color'=> '# E4002B '], [ 'color'=> '# 00B6F1 '], [ 'color'=> '# 003831 '], [ 'color'=> '# A5ACAF '], [ 'color'=> '# 007DC3 '], [ 'color'=> '# 633492 '], [ 'color'=> '# E4173E '], [ 'color'=> '# 004953 '], [ 'color'=> '# F47940 '], [ 'color'=> '# 284898 '], [ 'color'=> '# 001B2D '], [ 'color'=> '# E56020 '], [ 'color'=> '# FDB827 '], [ 'color'=> '# 004812 '], [ 'color'=> '# 005CAB '], [ 'color'=> '# A50531 '], [ 'color'=> '# 724C9F '], [ 'color'=> '# BAC3C9 '], [ 'color'=> '# 05143F '], [ 'color'=> '# AA0000 '], [ 'color'=> '# FD5A1E '], [ 'color'=> '# 0051BA '], [ 'color'=> '# 05535D '], [ 'color'=> '# 4F8A10 '], [ 'color'=> '# ED1A3B '], [ 'color'=> '# 91B0D5 '], [ 'color'=> '# 0546A0 '], [ 'color'=> '# C41E3A '], [ 'color'=> '# EB172B '], [ 'color'=> '# D50A0A '], [ 'color'=> '# 013E7D '], [ 'color'=> '# 092C5C '], [ 'color'=> '# C0111F '], [ 'color'=> '# 134A8E '], [ 'color'=> '# D80016 '], [ 'color'=> '# 001C58 '], [ 'color'=> '# 07346F '], [ 'color'=> '# 12264C '], [ 'color'=> '# CF132B '], [ 'color'=> '# AB0003 '], [ 'color'=> '# 773141 '], [ 'color'=> '# 091453 '], [ 'color'=> '# 60223B '], [ 'color'=> '# 91764B '], [ 'color'=> '# 023474 '], [ 'color'=> '# 7A003C '], [ 'color'=> '# 13274F '], [ 'color'=> '# C4D600 '], [ 'color'=> '# FFC422 '], [ 'color'=> '# BB9753 '], [ 'color'=> '# 0D2B56 '], [ 'color'=> '# E03A3F '], [ 'color'=> '# 565A5C '], [ 'color'=> '# B95915 '], [ 'color'=> '# B1BABF '], [ 'color'=> '# C60C30 '], [ 'color'=> '# FAB383 '], [ 'color'=> '# A9B0B8 '], [ 'color'=> '# 313F49 '], [ 'color'=> '# 20385B '], [ 'color'=> '# D7A22A '], [ 'color'=> '# BEC0C2 '], [ 'color'=> '# FFD200 '], [ 'color'=> '# 8177B7 '], [ 'color'=> '# BCBEC0 '], [ 'color'=> '# FFE600 '], [ 'color'=> '# EEE3C7 '], [ 'color'=> '# 231F20 '], [ 'color'=> '# 8A8D8F '], [ 'color'=> '# F0B83D '], [ 'color'=> '# C4CED3 '], [ 'color'=> '# F9A01B '], [ 'color'=> '# 00539B '], [ 'color'=> '# FF7900 '], [ 'color'=> '# B4975A '], [ 'color'=> '# 5B2B2F '], [ 'color'=> '# 006778 '], [ 'color'=> '# C09A5B '], [ 'color'=> '# 0053A0 '], [ 'color'=> '# D00027 '], [ 'color'=> '# 003263 '], [ 'color'=> '# 005A9C '], [ 'color'=> '# 004689 '], [ 'color'=> '# AFB7BA '], [ 'color'=> '# 552582 '], [ 'color'=> '# FFCE65 '], [ 'color'=> '# FFE500 '], [ 'color'=> '# 7399C6 '], [ 'color'=> '# F58220 '], [ 'color'=> '# 0077C8 '], [ 'color'=> '# B6922E '], [ 'color'=> '# F0EBD2 '], [ 'color'=> '# 00A94F '], [ 'color'=> '# D31145 '], [ 'color'=> '# FFC62F '], [ 'color'=> '# BF2B37 '], [ 'color'=> '# 213770 '], [ 'color'=> '# 00285E '], [ 'color'=> '# F57D31 '], [ 'color'=> '# F58426 '], [ 'color'=> '# 002D72 '], [ 'color'=> '# E6393F '], [ 'color'=> '# 012055 '], [ 'color'=> '# 003087 '], [ 'color'=> '# BBBDBF '], [ 'color'=> '# EFB21E '], [ 'color'=> '# F05133 '], [ 'color'=> '# FDE192 '], [ 'color'=> '# E81828 '], [ 'color'=> '# B18500 '], [ 'color'=> '# D1BD80 '], [ 'color'=> '# EBE72B '], [ 'color'=> '# 013474 '], [ 'color'=> '# 8E9090 '], [ 'color'=> '# 0073CF '], [ 'color'=> '# B3995D '], [ 'color'=> '# F38F20 '], [ 'color'=> '# 005C5C '], [ 'color'=> '# 69BE28 '], [ 'color'=> '# 11568C '], [ 'color'=> '# 211E1F '], [ 'color'=> '# FFC325 '], [ 'color'=> '# 000066 '], [ 'color'=> '# 1B449C '], [ 'color'=> '# A68A26 '], [ 'color'=> '# 34302B '], [ 'color'=> '# 8FBCE6 '], [ 'color'=> '# 4B92DB '], [ 'color'=> '# 003278 '], [ 'color'=> '# 1D2D5C '], [ 'color'=> '# 047A4A '], [ 'color'=> '# 00214E '], [ 'color'=> '# 11225B '], [ 'color'=> '# F7C240 '], [ 'color'=> '# 0168AB '], [ 'color'=> '# EF5225 '], [ 'color'=> '# FFB612 '], [ 'color'=> '# EFE1C6 '], [ 'color'=> '# E3D4AD '], [ 'color'=> '# 9C824A '], ]; foreach ($colors as $k => $color) { $colors[$k]['color'] = str_replace(' ', '', $color['color']); $colors[$k]['hsl']= hexToHsl($color['color']); } // // now sort the colors array by HSL value // usort($colors, function ($a, $b) { $dh = 100*($a['hsl']['h']) - 100*($b['hsl']['h']); if ($dh==0) { $ds = 100*($a['hsl']['s']) - 100*($b['hsl']['s']); if ($ds==0) { return 100*($a['hsl']['l']) - 100*($b['hsl']['l']); } else return $ds; } else return $dh; }); /** * Convert a hexadecimal color in RGB * @param string $hex * @return array */ function hexToHsl($hex){ list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x"); return rgbToHsl($r, $g, $b); } /** * Convert a RGB color in its HSL value * @param int $r red * @param int $g green * @param int $b blue * @return array */ function rgbToHsl($r, $g, $b) { $r /= 255; $g /= 255; $b /= 255; $max = max($r, $g, $b); $min = min($r, $g, $b); $h = 0; $l = ($max + $min) / 2; $d = $max - $min; if ($d == 0) { $h = $s = 0; // achromatic } else { $s = $d / (1 - abs(2 * $l - 1)); switch ($max) { case $r: $h = 60 * fmod((($g - $b) / $d), 6); if ($b > $g) { $h += 360; } break; case $g: $h = 60 * (($b - $r) / $d + 2); break; case $b: $h = 60 * (($r - $g) / $d + 4); break; } } return array('h' => round($h, 2), 's' => round($s, 2), 'l' => round($l, 2)); } /** * Check if two hues are in the same given interval * @param float $hue1 * @param float $hue2 * @param int $interval * @return bool */ function huesAreinSameInterval($hue1, $hue2, $interval = 30){ return (round(($hue1 / $interval), 0, PHP_ROUND_HALF_DOWN) === round(($hue2 / $interval), 0, PHP_ROUND_HALF_DOWN)); } ?> <html> <head> <title>Colors</title> <style type="text/css"> .clr { width: 20px; height: 20px; float: left; } </style> </head> <body> <?php foreach ($colors as $k=>$col) { $c = $col['color']; echo "<div class='clr' style='background-color: $c'> </div>\n"; if ( ($k+1)%15==0) echo "<div style='clear:left'></div>"; } ?> </body> </html> -
Brand New to PHP... AND I haven't coded in a few years... :)
Barand replied to Gregan's topic in PHP Coding Help
this will convert your existing $colors array to a simple indexed array ($newcolors) $newcolors = array(); foreach ($colors as $color) { $newcolors[] = str_replace(' ', '', $color['color']); } -
You started out acknowledging there was a problem with your current structure so I gave you a solution. Now you say you want to stick with that crap. problematic design and get someone to bail you out. Perhaps someone else will.
-
From what you have described you would want four tables (see attached model) video tag video_tag (to store the tags for each video) click (to log each click of a video's tag)
-
That's an interesting list of optional solutions but, having read it three times, I still no no idea of what you are trying to achieve. What are you trying to do?
-
I'd use a multiple insert query and batch in 1,000 rows at a time. EG INSERT INTO tablename (col1, col2, col3) VALUES (1, 2, 'aaa'), (2, 2, 'bbb'), (3, 2, 'ccc'), (4, 3, 'ccc'), (5, 4, 'aaa'), . . . (1000, 1, 'xyz');