Jump to content


Popular Content

Showing content with the highest reputation since 01/29/2019 in all areas

  1. 3 points
    The code in each switch is identical so all it achieves is to ensure the calculation uses only the defined list of diameter options. Just use an array of the valid values to verify the values. You can use the same array to generate the option list <?php $diam_vals = [2,3,4,6,8,10,12,14,16,18,20,22,24,26]; $results = ''; if ($_SERVER['REQUEST_METHOD']=='POST') { $x = $_POST['x'] ?? 0; $y = $_POST['y'] ?? 0; $diametre = $_POST['diametre'] ?? 0; if ($x > 0 && $y > 0 && in_array($diametre, $diam_vals)) { $rayon = $diametre * 38.1; $dc = $x/2; $ad = ($y/2)-$rayon; $ac = sqrt(pow($ad,2) + pow($dc,2)); $ec = sqrt(pow($ac,2) - pow($rayon,2)); $LongueurBayonette = $ec*2; $alpha = asin($dc/$ac); $alpha = $alpha*180/M_PI; $beta = acos($rayon/$ac); $beta = $beta*180/M_PI; $angle = 180-$alpha-$beta; $results .= "X = " . $x . "mm" . "<br/>"; $results .= "Y = " . $y . "mm" . "<br/>"; $results .= "Longueur = " . number_format($LongueurBayonette,1) . " mm" . "<br/>"; $results .= "&beta; = " . number_format($angle,1) . "°" . "<br/>"; $results .= "Rayon = " . $rayon . " mm" . "<br/>"; $results .= "&phi; = " . $diametre . '"' . "<br/>"; } else { $results = 'Inputs are not valid'; } } ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Simplified Example</title> </head> <body> <form method="post" action=""> <fieldset> X: <input type="text" name="x" value="" /> <br/> Y: <input type="text" name="y" value="" /> <br/> Diametre: <select name="diametre"> <option value="0"> </option> <?php foreach ($diam_vals as $d) { echo "<option value='$d'>$d</option>\n" ; } ?> </select> <input type="submit" value = "Calculer" /> </fieldset> </form> <br> <?=$results?> Just curious - do you have a diagram of how those values relate to one another. It metions "rayon" and "bayonnette" so my guess is that it is some kind of laser rifle with attached bayonet (but I could be wrong) 😊
  2. 2 points
    I have been playing around with a possible database solution to your problem Given that a postcode such as "EH12 3AB" breaks down into four parts viz +------+----------+--------+------+ | area | district | sector | unit | +------+----------+--------+------+ | EH | 12 | 3 | AB | +------+----------+--------+------+ ... I was toying with this table structure CREATE TABLE `postcode` ( `pc_id` int(11) NOT NULL AUTO_INCREMENT, `seller` int(11) DEFAULT NULL, `area` varchar(2) DEFAULT NULL, `district` varchar(2) DEFAULT NULL, `sector_min` char(1) DEFAULT NULL, `sector_max` char(1) DEFAULT NULL, `unit_min` char(2) DEFAULT NULL, `unit_max` char(2) DEFAULT NULL, `deliverable` tinyint(4) DEFAULT NULL, `price` decimal(8,2) DEFAULT NULL, PRIMARY KEY (`pc_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +-------+--------+------+----------+------------+------------+----------+----------+-------------+-------+ | pc_id | seller | area | district | sector_min | sector_max | unit_min | unit_max | deliverable | price | +-------+--------+------+----------+------------+------------+----------+----------+-------------+-------+ | 1 | 1 | EH | 1 | 1 | 4 | AA | ZZ | 1 | 1.50 | | 2 | 1 | EH | 1 | 5 | 5 | AA | BZ | 1 | 1.80 | | 3 | 1 | EH | 1 | 5 | 5 | CA | ZZ | 0 | 2.00 | | 4 | 1 | EH | 2 | 1 | 9 | AA | ZZ | 1 | 2.25 | | 5 | 1 | EH | 3 | 1 | 9 | AA | PZ | 1 | 2.50 | +-------+--------+------+----------+------------+------------+----------+----------+-------------+-------+ My code was $postcodes = [ 'EH1 2DB', 'eh15bg' , 'eh1 5ba', 'eh15dg', 'EH2 7HJ', 'EH3 2PT', 'EH3 8SX', 'EH146DE' ]; echo '<pre>'; foreach ($postcodes as $pc) { vprintf('%s%s %s%s : %s<br>', deliveryPrice($db, $pc)); } echo '</pre>'; function deliveryPrice($db, $pcode) { $pcode = strtoupper(str_replace(' ', '', $pcode)); $area = $district = ''; $sector = substr($pcode,-3, 1); $unit = substr($pcode, -2); $l = strlen($pcode); $first = str_split(substr($pcode, 0, $l-3)); foreach ($first as $c) { if (ctype_digit($c)) { $district .= $c; } else { $area .= $c; } } $res = $db->prepare("SELECT price FROM postcode WHERE area = ? AND district = ? AND ? between sector_min AND sector_max AND ? BETWEEN unit_min AND unit_max AND deliverable "); $res->execute( [ $area, $district, $sector, $unit ] ); $p = $res->fetchColumn(); $price = $p ? number_format($p, 2) : 'N/A'; return [$area, $district, $sector, $unit, $price ]; } RESULTS: EH1 2DB : 1.50 EH1 5BG : 1.80 EH1 5BA : 1.80 EH1 5DG : N/A EH2 7HJ : 2.25 EH3 2PT : 2.50 EH3 8SX : N/A EH14 6DE : N/A
  3. 2 points
    $numbers = array(1,3,7,8,10,13); $max = max(array_filter($numbers, function($v) { return $v%2==0; })) ;
  4. 2 points
    Not as it is now - if you want to tell the user which is taken you'll have to update the query. Right now it just returns a count of records that match either the username or the email. You'll have to actually select both and then check in PHP which one matches, or rewrite the query to return the offending column. However, I'd recommend just letting people know that one of the two has been taken. That way you're not confirming to an outside party which of the two actually exists in the database - a hacker that knows for a fact a username exists has less work to do and can focus only on figuring out a correct password.
  5. 2 points
    here's a list of things i saw in the posted code - 1. don't put php variables inside of double-quotes if they are the only thing in the string. 2, don't use or die() for error handling. use exceptions and in most cases let php catch the exception. note: your use of mysqli_error(...) in the connection code won't work because there's no connection to use. 3. don't unconditionally output database errors onto a web page (this will go away when you get rid of the or die() logic.) 4. don't run queries inside of loops. learn to do JOIN queries. 5. if your code is tabbed that far over because it is located inside your html document, you need to put the php code that's responsible for getting/producing data before the start of your html document, fetch the data into appropriately named php variable(s), then use those variable(s) in the html document. 6. handling the negative/failure case is usually shorter then the positive/successful case. if you invert the logic tests and handle the negative/failure condition first, your code will be clearer. you won't have logic for the negative/failure case 10's/100's of lines later in the code. 7. don't use loops to fetch what will be at most one row of data. just directly fetch the single row of data. 8. don't put static calculations inside of loops. the various date values shouldn't change during one report (where they are at now, they will if the request spans midnight.) put them before the start of the loop. 9. don't put quotes around numbers. 10. don't selected things that are not used and don't create variables that are not used (given the amount of code, the cases i saw of this may not be accurate.) 11. if you are looping to do something (should go away with JOINed queries), don't evaluate count() statements in the loop. determine the loop count, once, before the start of the loop. 12. doing some of these things will simplify variable naming. you won't have to think up unique names for variables because you will only have one instance in the code. 13. the $AffID is probably from external/unknown data. you should NOT put eternal/unknown data directly into an sql query statement. use a prepared query, with a place-holder for each data value, then supply the data when the query gets executed. switching to the much simpler php PDO extension will make using prepared queries easy compared to the php mysqli extension.
  6. 1 point
    You need to learn the difference between arrays and strings. The first is an array of arrays, the second is an array of strings containing numbers and commas Array ( [0] => Array ( [0] => 1 [1] => 5 [2] => 6 [3] => 7 [4] => 8 [5] => 9 ) [1] => Array ( [0] => 2 [1] => 7 [2] => 6 [3] => 5 [4] => 4 [5] => 3 ) [2] => Array ( [0] => 3 [1] => 12 [2] => 13 [3] => 14 [4] => 15 [5] => 16 ) ) Array ( [0] => 1,5,6,7,8,9 [1] => 2,7,6,5,4,3 [2] => 3,12,13,14,15,16 )
  7. 1 point
    Your problem is that you're adding extra keyup handlers each time a field changes. Look at your code: $(".ui").change(function(){ myResult.keyup(function(e) { //... }); }); That says, every time an element in .ui changes, add a keyup handler to myResult. So on your first pass, as you enter your inputs you're adding a key up handler to every input. On your second pass, you end up adding yet another key up handler to every input so your handler function ends up running twice. On a third pass, you'd add another so your handler runs three times. ... Combine that with your global state variables and you get a mess. When you enter the right value your first handler changes myResult and m to a different input. Then your second handler looks at that new input value and sees that it doesn't match the next sequence value and shows an error. You need to remove the change handler and just add a single keyup (or keypress) handler. Ideally you'd find a way to rely on global state variables less as well.
  8. 1 point
    Or you could have just said: $cat_name = str_replace('&', 'and ', strtolower($cat_name)); No need to define arrays for this purpose nor to create a second field to hold category name.
  9. 1 point
    from one of your previous threads on this forum - if (IS_LOGGED == false) { header("Location: " . PT_Link('login')); exit(); } or more simply - if (!IS_LOGGED) { header("Location: " . PT_Link('login')); exit(); } this of course assumes that the code producing the IS_LOGGED defined constant is consistently being used and exists before the code you have posted. a feature like controlling who can view a certain page, like the profiles, should be part of the user permission system. does this code have a general purpose user permission system in it?
  10. 1 point
    there is something wrong with $query->wheres, it's not countable. So it's not an array or not an object. Do var_dump($query->wheres); after the $query = to find out what it is and what it does contain.
  11. 1 point
    consider <?php $dt1 = new DateTime(); $dt2 = new DateTime('2019-12-31'); echo $dt1->diff($dt2)->d . '<br>'; //--> 24 echo $dt1->diff($dt2)->days . '<br>'; //--> 177 ?> "d" gives days as in 6 months 24 days. "days" gives the total number of days
  12. 1 point
    It looks like your rule is slightly malformed. As I said earlier, I've found the add_rewrite_rule() function to be a bit fiddly - I try to use the 'rewrite_rules_array' filter instead. Try this: add_filter('add_rewrite_rules' ,'add_kudoskey_rule'); function add_kudoskey_rule(array $rules){ $new = [ 'kudos/([^/]+)/?$' => 'index.php?pagename=kudos&kudokey=$matches[1]', ]; $rules = array_merge($rules, $new); return $rules; } Now, with this in place you should be able to (after you've gone to the Permalinks page and clicked 'Save' to clear the rewrite cache) go to '' and it should show that specific kudos. If you want to get the kudos key referenced in the URL, use get_query_var('kudoskey'). If you want to show an archive listing of all kudos records, make sure that 'has_archive' is set to true in the arguments array of your custom post type registration call, then go to '' and you should see the listing. The whole point of adding a rewrite rule is to enable pretty URLs and to not have to use '?variableName=variableValue' because it's easier for the user and better for SEO.
  13. 1 point
    Yes. Here's a simplified version of your application as an example FORM CODE <?php // // FOR DEBUG PURPOSES ONLY - LIST CONTENTS OF SESSION PLAYLIST // session_start(); if (isset($_SESSION['playlist'])) { echo '<pre>', print_r($_SESSION['playlist'], 1), '</pre>'; echo "</hr><br>\n"; } ?> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $().ready( function() { $(".btn").click( function() { var vid = $(this).data("id"); var vname = $(this).data("name"); $.post( "my_cart.php", { "voice_id" : vid, "voice_name" : vname}, function(resp) { var list = "<tr><td><b>ID</b></td><td><b>Title</b></td></tr>\n"; $.each(resp, function(k, v) { list = list + "<tr><td>" + k + "</td><td>" + v + "</td></tr>\n" }) $("#playlist").html(list) }, "JSON" ) }) }) </script> </head> <body> Song 1 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="1" data-name="song-1.mp3">Add to PlayList </button> <br> Song 2 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="2" data-name="song-2.mp3">Add to PlayList </button> <br> Song 3 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="3" data-name="song-3.mp3">Add to PlayList </button> <br> Song 4 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="4" data-name="song-4.mp3">Add to PlayList </button> <br> Song 5 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="5" data-name="song-5.mp3">Add to PlayList </button> <br> Song 6 <button type="button" class="btn btn-primary" type="submit" style="padding: 5px 83px 5px 83px;" data-id="6" data-name="song-6.mp3">Add to PlayList </button> <br> <br> <h2>Playlist</h2> <table style="width:600px" id="playlist"> </table> </body> </html> MY_CART.PHP <?php session_start(); if ($_SERVER['REQUEST_METHOD']=='POST') { $voice_id = $_POST['voice_id'] ?? 0; $voice_name = $_POST['voice_name'] ?? ''; if ($voice_id && $voice_name) { $_SESSION['playlist'][$voice_id] = $voice_name; exit(json_encode($_SESSION['playlist'])) ; } } exit("ERROR") ; ?>
  14. 1 point
    Just my 0.02 worth ... 1. It is always a bad idea to place values provided by the user ($_GET, $_POST, $_COOKIE) directly into your SQL. A better way is this, which avoids doing that and also checks that only valid column names can be used $sort = $_GET['sort'] ?? ''; switch ($sort) { case 'recd_date': $orderby = 'location, recd_date, name'; break; case 'sent_date': $orderby = 'location, sent_date, name'; break; case 'birth_date': $orderby = 'location, birth_date, name'; break; default: $orderby = 'location, name'; break; } 2. Use prepared statements to place values into your query $result = $db->prepare("SELECT * FROM $company WHERE member = ? ORDER BY $orderby "); $result->bind_param('i', $member_number[$i]); $result->execute(); 3. The use of that [$i] index - are you running the query in a loop for different member_numbers? Don't. 4. You have a variable table name ($company) which suggests you have several tables, each for a different company. Better to have a single table and add an indexed "company" column.
  15. 1 point
    Remove the period from in front of your relative paths. The location of the files should be relative to your site document root.
  16. 1 point
    Your output depends on there being an input with the name "submit". There isn't one. As it is a bad idea to name an input "submit" rely on a button name to check for submissions of data (if you hit return the button name may not be sent depending on the browser) A better approach to test for posted data is if ($_SERVER['REQUEST_METHOD'] == 'POST' ) { // process posted data }
  17. 1 point
    Yeah, I got a little confused about when you wanted the scope. It's about the admin routes, not about whether it's doing testing. Having stepped away from the computer for a couple hours, public static function boot(){ parent::boot(); if(!request()->is('admin/*')){ static::addGlobalScope(new IsActiveScope()); } } The model will only be booted once, and it'll probably happen early. Like for the very first request. Which doesn't help with testing - unless you're requesting against the web server, but it doesn't sound like it. The admin/* check would have to be inside IsActiveScope when it's being applied. So basically what I said before, except instead of the middleware and flag (which I still recommend) you're testing the request() path.
  18. 1 point
    When you receive the form the first time (and every time after that) create an array of the 'values' that were checked. When you output the form again, as you build the html code check that array for the values that need to be re-checked and check them as they are built. easy-peasy.
  19. 1 point
    assuming that you are dynamically producing the checkboxes (if not that would be your 1st step), you would test if the corresponding submitted post data isset() for the current checkbox you are outputting. to address that you are initially checking all the checkboxes, you would have a common program variable that you initially setup with the necessary data, then copy the submitted post data to the same variable once the form has been submitted. see the following example code - <?php // recursive trim call-back function function _trim($val) { if(is_array($val)) { return array_map('_trim',$val); } else { return trim($val); } } $post = []; // holds a trimmed, working copy, of the submitted post data or any initial data // post method form processing if($_SERVER['REQUEST_METHOD'] == 'POST') { // examine the submitted data echo '<pre>'; print_r($_POST); echo '</pre>'; $post = array_map('_trim',$_POST); // get a trimmed copy of the submitted post data. use elements in $post in the rest of the code on the page // the rest of the form processing code goes here... } // get method business logic - get/produce data needed to display the page // if you were editing existing stored data, you would initially (if the $post variable is empty) retrieve that here into the $post variable if(empty($post)) // note: this requires at least one non-checkbox/radio form field to be present in case all checkbox/radio fields are ever unchecked { // for a set of defined checkboxes that are initially set, the same as through you were editing existing data where all the checkboxes are initially checked, set that up here // loop over a 'defined' list of checkboxes. for demo purposes this is just a list of ids from 1-4 foreach(range(1,4) as $id) { $post['chk'][$id] = true; } } ?> <form method='post'> <input type='hidden' name='action' value='create'> <?php // loop over a 'defined' list of checkboxes. for demo purposes this is just a list of ids from 1-4 foreach(range(1,4) as $id) { // determine if checkbox is checked $chk = isset($post['chk'][$id]) ? ' checked' : ''; echo "<input type='checkbox' name='chk[$id]'$chk> Checkbox: $id<br>"; } ?> <input type='submit'></form>
  20. 1 point
    The Chrome/Firefox dev tools are a great way to explore your understanding of these things. Basically HTTP has a request/response format. Client Makes Request to server ----> Server receives Request (GET or POST) Server processes request.... At this point your PHP code is running and can do whatever you want it to do. So if your goal is to redirect the user to a different page, then you have 2 ways to do that. Either set a location header or use the html meta refresh. In the case of the location header, once anything was echo'd to the client, the http header will have already been sent and it will be too late. Like session_start(), if you need to make header() calls, they have to come first. Of course that doesn't mean that you can't have done processing, stored data, sent email or anything else you require first.
  21. 1 point
    i was able to edit correctly and get the characters to look how i wanted, i used start_time and start_date to get the version of those i needed, and i even added timezone for clearification further on the automation needs moving forward for reference. So i see how you used $i the i believe its $i++ was that to say count incrementally higher ? and if so is this same thing possible only using a-z intead of 0-9
  22. 1 point
    This is what I was looking for: $jsondata = file_get_contents("https://kalebdf.com/flo/api.php?url=events%2Fnow-and-upcoming%3Flimit%3D70%26tz%3DAmerica%2FNew_York%26live_only%3D1%26site_id%3D1%252C2%252C3%252C4%252C5%252C6%252C7%252C8%252C9%252C10%252C11%252C12%252C13%252C14%252C15%252C16%252C17%252C18%252C19%252C20%252C21%252C22%252C23%252C24%252C25%252C26%252C27%252C28%252C29%252C30%252C31%252C32%252C33%252C34%252C35%252C36%252C37%252C38%252C39%252C41%252C43"); $json = json_decode($jsondata, true); var_dump($json['data']); Now that we can see your source json, this is obviously a huge result. I'm not sure that turning this into a gigantic array is helpful because it's such a large json data structure with many keys. However, in general you can determine what is going to happen based on whether the json has an array structure ie [ ] or a property "somename": "some_value" The original json has many of these properties. If something is inside a json array, then it will be turned into a numerically indexed array: $var[0], $var[1] etc. Unless you know which specific array element you need, typically you're going to foreach() loop through them. If the original json is a property then the property name is going to be turned into an array key, with the associated value stored in the array element. That value could be a nested object: { }, a single value, or an array. And in each case there is possible nesting. If you understand the basics of this, you should be able to look at the original json and figure out how it will be converted. In your case, when we var_dump($json['data']) the top level is revealed to be a giant numerically indexed array: You are foreach()ing through this array. So to get an idea of what just one looks like, it's helpful to var_dump the first one: var_dump($json['data'][0]); This shows the nested structure for each array element you'll get when you foreach through the outer structure: array(41) { ["id"]=> int(6251309) ["should_show_read_more"]=> bool(true) ["ad_set_code"]=> NULL ["slug_uri"]=> string(33) "/events/6251309-2019-giro-ditalia" ["title"]=> string(18) "2019 Giro d'Italia" ["short_title"]=> string(13) "Giro d'Italia" ["seo_description"]=> string(122) "Tune in to FloBikes for complete editorial coverage and to watch every stage of the 2019 Giro d'Italia live and on demand!" ["author"]=> array(10) { ["profile_picture_url_small"]=> string(86) "https://res.cloudinary.com/diznifoln/image/upload/w_100,h_100/oz7rkl8ihbds5yb20ujn.png" ["profile_picture_url_medium"]=> string(86) "https://res.cloudinary.com/diznifoln/image/upload/w_125,h_125/oz7rkl8ihbds5yb20ujn.png" ["profile_picture_url_large"]=> string(86) "https://res.cloudinary.com/diznifoln/image/upload/w_150,h_150/oz7rkl8ihbds5yb20ujn.png" ["id"]=> int(1625830) ["username"]=> string(10) "JoeBatts75" ["first_name"]=> string(3) "Joe" ["last_name"]=> string(9) "Battaglia" ["gender"]=> string(1) "m" ["created_at"]=> string(24) "2014-04-10T14:03:26+0000" ["modified_at"]=> string(24) "2019-02-04T16:24:23+0000" } ["asset"]=> array(14) { ["id"]=> int(6456733) ["title"]=> string(53) "El-Giro-de-Italia-2018-comenzará-en-Jerusalén.jpg" ["description"]=> NULL ["credit"]=> NULL ["source"]=> string(71) "//flo30-assets-prod.s3.amazonaws.com/uploads/FloBikes/5ba8fda8b17eb.png" ["site"]=> array(13) { ["domain"]=> string(16) "www.flobikes.com" ["id"]=> int(37) ["name"]=> string(8) "FloBikes" ["code"]=> string(8) "flobikes" ["host"]=> string(23) "http://www.flobikes.com" ["active"]=> bool(true) ["type"]=> string(4) "site" ["version"]=> int(3) ["color"]=> string(7) "#FF8200" ["hero_image"]=> string(86) "https://d6fm3yzmawlcs.cloudfront.net/mobileVerticalBackground/mobile_bg_flocycling.jpg" ["modified_at"]=> NULL ["show_on_mobile"]=> bool(true) ["sport_name"]=> string(7) "Cycling" } ["url"]=> string(55) "https://d2779tscntxxsw.cloudfront.net/5ba8fda8b17eb.png" ["library"]=> bool(true) ["status_code"]=> int(200) ["path"]=> string(77) "https://flo30-assets-prod.s3.amazonaws.com/uploads/FloBikes/5ba8fda8b17eb.png" ["copied"]=> bool(true) ["duplicated"]=> bool(false) ["created_at"]=> string(24) "2018-09-24T15:07:21+0000" ["modified_at"]=> string(24) "2018-10-13T08:09:22+0000" } ["logo"]=> NULL ["slug"]=> string(17) "2019-giro-ditalia" ["publish_start_date"]=> string(24) "2018-09-24T15:26:00+0000" ["publish_end_date"]=> NULL ["status"]=> int(1) ["status_text"]=> string(18) "Active - Published" ["status_color"]=> string(7) "#CDEB8B" ["premium"]=> bool(false) ["node"]=> array(13) { ["categories"]=> array(3) { [0]=> array(5) { ["id"]=> int(605) ["name"]=> string(4) "Road" ["parent"]=> array(5) { ["id"]=> int(602) ["name"]=> string(10) "Discipline" ["parent"]=> NULL ["created_at"]=> string(24) "2018-02-02T17:47:21+0000" ["modified_at"]=> NULL } ["created_at"]=> string(24) "2018-02-02T17:47:34+0000" ["modified_at"]=> NULL } [1]=> array(5) { ["id"]=> int(612) ["name"]=> string(12) "Professional" ["parent"]=> array(5) { ["id"]=> int(603) ["name"]=> string(11) "Rider Level" ["parent"]=> NULL ["created_at"]=> string(24) "2018-02-02T17:47:21+0000" ["modified_at"]=> NULL } ["created_at"]=> string(24) "2018-02-02T17:47:53+0000" ["modified_at"]=> NULL } [2]=> array(5) { ["id"]=> int(621) ["name"]=> string(8) "UCI 2.WT" ["parent"]=> array(5) { ["id"]=> int(604) ["name"]=> string(10) "Race Level" ["parent"]=> NULL ["created_at"]=> string(24) "2018-02-02T17:47:21+0000" ["modified_at"]=> NULL } ["created_at"]=> string(24) "2018-02-02T17:48:48+0000" ["modified_at"]=> NULL } } ["primary_event_association"]=> NULL ["primary_event_or_series_association"]=> NULL ["people"]=> array(0) { } ["teams"]=> array(0) { } ["id"]=> int(6251309) ["current_revision"]=> NULL ["site"]=> array(13) { ["domain"]=> string(16) "www.flobikes.com" ["id"]=> int(37) ["name"]=> string(8) "FloBikes" ["code"]=> string(8) "flobikes" ["host"]=> string(23) "http://www.flobikes.com" ["active"]=> bool(true) ["type"]=> string(4) "site" ["version"]=> int(3) ["color"]=> string(7) "#FF8200" ["hero_image"]=> string(86) "https://d6fm3yzmawlcs.cloudfront.net/mobileVerticalBackground/mobile_bg_flocycling.jpg" ["modified_at"]=> NULL ["show_on_mobile"]=> bool(true) ["sport_name"]=> string(7) "Cycling" } ["view_count"]=> int(100740) ["legacy_id"]=> NULL ["search_indexed_at"]=> string(24) "2019-05-22T12:13:40+0000" ["created_at"]=> string(24) "2018-09-24T15:27:50+0000" ["modified_at"]=> string(24) "2019-05-22T12:13:40+0000" } ["enable_interstitial_ad"]=> bool(true) ["enable_pre_roll_ads"]=> bool(true) ["shareable_link"]=> string(57) "https://www.flobikes.com/events/6251309-2019-giro-ditalia" ["created_at"]=> string(24) "2018-09-24T15:27:50+0000" ["modified_at"]=> string(24) "2019-05-22T12:04:37+0000" ["has_schedule"]=> bool(true) ["preview_text"]=> string(217) "<p>The 2019 Giro d’Italia is a UCI World Tour event. Tune in to FloBikes for a complete editorial coverage and to watch every stage of the 2019 Giro d'Italia live and on demand, available in the U.S. and Canada.</p>" ["description"]=> string(225) "<p>The 2019 Giro d&rsquo;Italia is a UCI World Tour event. Tune in to FloBikes for a complete editorial coverage and to watch every stage of the 2019 Giro d&#39;Italia live and on demand, available in the U.S. and Canada.</p>" ["city"]=> string(7) "Bologna" ["region"]=> NULL ["country"]=> string(2) "IT" ["venue"]=> NULL ["start_date"]=> string(10) "2019-05-11" ["end_date"]=> string(10) "2019-06-02" ["schedule_tab_label"]=> string(8) "Schedule" ["participant_tab_label"]=> string(7) "Entries" ["live_updates_tab_label"]=> string(12) "Live Updates" ["info_tab_label"]=> string(4) "Info" ["live_event"]=> array(33) { ["event_ids"]=> array(1) { [0]=> int(6251309) } ["start_at"]=> string(20) "2019-05-22T11:05:00Z" ["end_at"]=> string(20) "2019-06-03T03:59:59Z" ["id"]=> int(8778) ["title"]=> string(18) "2019 Giro d'Italia" ["short_title"]=> string(13) "Giro D'Italia" ["stream1"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream2"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_list"]=> array(2) { [0]=> array(7) { ["stream_id"]=> int(18633) ["stream_name"]=> string(18) "2019 Giro d'Italia" ["stream_code"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_active"]=> bool(true) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } [1]=> array(7) { ["stream_id"]=> int(25651) ["stream_name"]=> string(13) "Giro d'Italia" ["stream_code"]=> string(21) "cyp8778_giro_d_italia" ["stream_active"]=> bool(false) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } } ["slug"]=> string(18) "2019-giro-d-italia" ["description"]=> string(79) "<p> <span style="background-color: initial;">2019 Giro d'Italia</span> </p>" ["premium"]=> bool(true) ["ppv"]=> bool(false) ["disable_bumping"]=> bool(false) ["disable_login"]=> bool(false) ["enable_ott"]=> bool(true) ["status"]=> string(4) "LIVE" ["status_message"]=> NULL ["type"]=> string(6) "STREAM" ["start_date"]=> string(10) "2019-05-22" ["end_date"]=> string(10) "2019-06-02" ["start_time"]=> string(8) "07:05:00" ["end_time"]=> string(8) "23:59:59" ["timezone"]=> string(16) "America/New_York" ["start_date_time"]=> string(24) "2019-05-22T11:05:00+0000" ["end_date_time"]=> string(24) "2019-06-03T03:59:59+0000" ["start_at_next"]=> string(24) "2019-05-22T11:05:00+0000" ["background_url"]=> NULL ["live_event_url"]=> string(34) "https://www.flobikes.com/live/8778" ["player_version"]=> string(3) "3.0" ["dvr"]=> bool(false) ["created_at"]=> string(24) "2019-05-22T12:04:56+0000" ["modified_at"]=> string(24) "2019-05-22T12:04:56+0000" } ["watchable"]=> bool(true) ["replay_video_count"]=> int(10) ["replay_preview_vod"]=> NULL ["type"]=> string(5) "event" } Sometimes it's useful in such a large structure just to see the list of top level array keys. PHP has a helpful array_keys() function for this. Also, print_r has a slightly different output format from var_dump that omits the variable types. Just to get some clarity, I ran this: $json = json_decode($jsondata, true); $t = array_keys($json['data'][0]); sort($t); print_r($t); And got this output: Array ( [0] => ad_set_code [1] => asset [2] => author [3] => city [4] => country [5] => created_at [6] => description [7] => enable_interstitial_ad [8] => enable_pre_roll_ads [9] => end_date [10] => has_schedule [11] => id [12] => info_tab_label [13] => live_event [14] => live_updates_tab_label [15] => logo [16] => modified_at [17] => node [18] => participant_tab_label [19] => premium [20] => preview_text [21] => publish_end_date [22] => publish_start_date [23] => region [24] => replay_preview_vod [25] => replay_video_count [26] => schedule_tab_label [27] => seo_description [28] => shareable_link [29] => short_title [30] => should_show_read_more [31] => slug [32] => slug_uri [33] => start_date [34] => status [35] => status_color [36] => status_text [37] => title [38] => type [39] => venue [40] => watchable ) You had determined previously that the 2 top level elements you were interested in were 'title' and 'live_event'. 'title' is a single value, however live_event is another nested structure. To figure out what that looks like: var_dump($json['data'][0]['live_event']); And you get: array(33) { ["event_ids"]=> array(1) { [0]=> int(6251309) } ["start_at"]=> string(20) "2019-05-22T11:05:00Z" ["end_at"]=> string(20) "2019-06-03T03:59:59Z" ["id"]=> int(8778) ["title"]=> string(18) "2019 Giro d'Italia" ["short_title"]=> string(13) "Giro D'Italia" ["stream1"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream2"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_list"]=> array(2) { [0]=> array(7) { ["stream_id"]=> int(18633) ["stream_name"]=> string(18) "2019 Giro d'Italia" ["stream_code"]=> string(26) "cyp8778_2019_giro_d_italia" ["stream_active"]=> bool(true) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } [1]=> array(7) { ["stream_id"]=> int(25651) ["stream_name"]=> string(13) "Giro d'Italia" ["stream_code"]=> string(21) "cyp8778_giro_d_italia" ["stream_active"]=> bool(false) ["stream_hls"]=> string(68) "http://flocasts-hls.videocdn.scaleengine.net/flocasts-florigins/play" ["stream_type"]=> string(8) "multiple" ["stream_mode"]=> string(6) "normal" } } ["slug"]=> string(18) "2019-giro-d-italia" ["description"]=> string(79) "<p> <span style="background-color: initial;">2019 Giro d'Italia</span> </p>" ["premium"]=> bool(true) ["ppv"]=> bool(false) ["disable_bumping"]=> bool(false) ["disable_login"]=> bool(false) ["enable_ott"]=> bool(true) ["status"]=> string(4) "LIVE" ["status_message"]=> NULL ["type"]=> string(6) "STREAM" ["start_date"]=> string(10) "2019-05-22" ["end_date"]=> string(10) "2019-06-02" ["start_time"]=> string(8) "07:05:00" ["end_time"]=> string(8) "23:59:59" ["timezone"]=> string(16) "America/New_York" ["start_date_time"]=> string(24) "2019-05-22T11:05:00+0000" ["end_date_time"]=> string(24) "2019-06-03T03:59:59+0000" ["start_at_next"]=> string(24) "2019-05-22T11:05:00+0000" ["background_url"]=> NULL ["live_event_url"]=> string(34) "https://www.flobikes.com/live/8778" ["player_version"]=> string(3) "3.0" ["dvr"]=> bool(false) ["created_at"]=> string(24) "2019-05-22T12:04:56+0000" ["modified_at"]=> string(24) "2019-05-22T12:04:56+0000" } So finally we can see, that 'stream_list' is the key for an array of streams. Being that this is a numerically indexed array of 1..n items, you need to do a nested foreach() to iterate through the internal array elements. You've stated that you are only interested in the 'stream_id' element. So hopefully at this point, you can understand that you have an outer foreach() through the data elements, and then the requirement to do an inner foreach to get the individual stream_id elements from stream_list. <?php $jsondata = file_get_contents("https://kalebdf.com/flo/api.php?url=events%2Fnow-and-upcoming%3Flimit%3D70%26tz%3DAmerica%2FNew_York%26live_only%3D1%26site_id%3D1%252C2%252C3%252C4%252C5%252C6%252C7%252C8%252C9%252C10%252C11%252C12%252C13%252C14%252C15%252C16%252C17%252C18%252C19%252C20%252C21%252C22%252C23%252C24%252C25%252C26%252C27%252C28%252C29%252C30%252C31%252C32%252C33%252C34%252C35%252C36%252C37%252C38%252C39%252C41%252C43"); $json = json_decode($jsondata, true); foreach($json['data'] as $data) { echo "Title: {$data['title']}\n"; echo "Event Time: {$data['live_event']['start_time']}\n"; echo "Streams:\n"; foreach($data['live_event']['stream_list'] as $i => $stream) { $i++; echo " $i. {$stream['stream_id']}\n"; } echo "\n"; } Output: Title: 2019 Giro d'Italia Event Time: 07:05:00 Streams: 1. 18633 2. 25651 Title: 2019 Japan vs United States | Women's VNL Event Time: 08:45:00 Streams: 1. 24691 Title: 2019 Serbia vs Korea | Women's VNL Event Time: 09:45:00 Streams: 1. 24692 Title: 2019 Thailand vs Italy | Women's VNL Event Time: 10:15:00 Streams: 1. 24695 Title: 2019 Brose Bamberg vs Rasta Vechta | easyCredit BBL Event Time: 12:00:00 Streams: 1. 25885 Title: 2019 Bulgaria vs Belgium | Women's VNL Event Time: 12:15:00 Streams: 1. 24697 Title: 2019 Netherlands vs Turkey | Women's VNL Event Time: 12:45:00 Streams: 1. 24698 Title: 2019 Poland vs Germany | Women's VNL Event Time: 13:15:00 Streams: 1. 24699 Title: 2019 Kirolbet Baskonia vs Divinas Seguros Joventut | 2018-19 La Liga BB Event Time: 13:30:00 Streams: 1. 24555 Title: Here's The Deal Event Time: 14:30:00 Streams: 1. 17181 Title: 2019 China vs Russia | Women's VNL Event Time: 14:45:00 Streams: 1. 24700 Title: 2019 TSSAA Outdoor Championships Event Time: 17:00:00 Streams: 1. 23950 Title: Going Brooklyn: In Studio With Bowling's Big Names Event Time: 16:00:00 Streams: 1. 19566 Title: 2019 USAC Sprints at Terre Haute Action Track Event Time: 17:30:00 Streams: 1. 20891 2. 21547 3. 21850 Title: 2019 Brazil vs Dominican Republic | Women's VNL Event Time: 17:45:00 Streams: 1. 24701 Title: 2019 D.C. United vs Real Betis Event Time: 18:45:00 Streams: 1. 25324 2. 25961 Title: 2019 Sassari City Matteo Pellicone Memorial Event Time: 03:00:00 Streams: 1. 22004 Title: 2019 Canadian Gymnastics Championships - Artistic Event Time: 08:30:00 Streams: 1. 22977 Title: 2019 Belgium vs Japan | Women's VNL Event Time: 08:45:00 Streams: 1. 24702 Title: 2019 CAN vs SUI | IIHF World Quarterfinals Event Time: 09:15:00 Streams: 1. 25647 2. 25958 Title: 2019 Netherlands vs Korea | Women's VNL Event Time: 09:45:00 Streams: 1. 24703 Title: 2019 Italy vs Germany | Women's VNL Event Time: 10:15:00 Streams: 1. 24704 Title: FloTrack TV Event Time: 12:00:00 Streams: 1. 24624 Title: 2019 United States vs Bulgaria | Women's VNL Event Time: 12:15:00 Streams: 1. 24705 Title: 2019 Turkey vs Serbia | Women's VNL Event Time: 12:45:00 Streams: 1. 24706 Title: 2019 Thailand vs Poland | Women's VNL Event Time: 13:15:00 Streams: 1. 24707 Title: 2019 CZE vs GER | IIHF World QuarterFinals Event Time: 13:15:00 Streams: 1. 25959 Title: 2019 DI NCAA West Preliminary Round Event Time: 12:00:00 Streams: 1. 23835 2. 25953 Title: 2019 DI NCAA East Preliminary Round Event Time: 15:30:00 Streams: 1. 23834 2. 25954 Title: 2019 China vs Dominican Republic | Women's VNL Event Time: 14:45:00 Streams: 1. 24708 Title: 2019 MPSSAA Outdoor Championships Event Time: 16:00:00 Streams: 1. 24005 Title: 2019 NHSRA Louisiana State Finals: RidePass PRO Event Time: 15:15:00 Streams: 1. 25111 etc.
  23. 1 point
    you would initially create an array of the dates (Y-m-d date format) you want to highlight and store this array in a class property. at the point in the code where it is producing the css class selector and the cell content, you would use in_array() to find if $this->currentDate is one of the dates in the array. note: the author of that script should have produced a $today value in the Y-m-d format and just directly compared it with $this->currentDate in the existing css class selector code.
  24. 1 point
  25. 1 point
    Just use the index hierarchy down to the item you want echo $array['data'][0]['attributes']['title']
  26. 1 point
    There are a few issues here: echo'<form method="POST" action"'.getLocations($conn).'"> 1. getLocations() is a function that does not return anything. You can't use it with a string like that. 2. The form action is supposed to be a URL. If you want to submit the form to the same page it's on you can leave the action empty or missing. 3. There needs to be an equals sign with that action. <!--foreach($zip as $zip) : --> 4. That's PHP code. If you need to comment it out, keep it inside the <?php tags and use a PHP comment, not an HTML comment. 5. $zip that was set inside the getLocations() function is not going to be available to use outside the function. You should make the function return the value, then when you call it assign the returned value to a variable. 6. The function is only set to do anything when the form is submitted. Make sure that everything still works even when the form hasn't been submitted yet. 7. Don't iterate over a variable and then use that same variable name for the individual values. You'll confuse yourself. Perhaps use $zips and $zip? echo $address['address']; 8. $address is never defined anywhere. Did you mean $zip? But... echo $zip['zip']; 9. Since you commented out the foreach loop, and because of #5, there is no $zip to use. if (isset($_POST['submit'])){ 10. Your form's submit button is not named "submit". function getLocations($conn) { 11. This function requires that you pass it an argument for the database connection (which you have also named $conn). You aren't doing that.
  27. 1 point
    In order to use $_GET you need to understand what links look like and what the query string is. Research that and you should have an idea of what you need to do next.
  28. 1 point
    I'm sorry but this is an idiotic approach to handling carts. IP addresses are shared, sometimes en masse. There is no way that a shopping cart should be based upon a user's IP address. The IP address code is dumb. PHP has sessions built in, and they are easy to use and solve this problem. I don't know where you found this tutorial, but it's apparently old, outdated, and has a number of poor and/or obsolete practices. You know when you have code that requires global, this is php3 level sophistication. I'm also on the same bandwagon as most of the long time established developers who frequent phpfreaks, in being a firm proponent of the "use PDO, it's a better db API" camp. It might help to let people know what you are trying to get out of this: (learning exercise?, building a site for a small business or personal project?, homework?) as that might help people modulate their responses. The obvious issue with the code you provided is that you didn't show us the code that actually calls add_cart() function, so it's anyone's guess why it isn't working, although ginerjm already pointed out the way you bypass potential db errors and assume your connections and queries are functioning.
  29. 1 point
    the users table should only hold unique/one-time user information - first name, last name. this would produce a user_id (auto-increment integer column.) you would store any repetitive user information, such as the weight/date data in a second table, related back to the user through the user_id value. once you have properly stored the data, you can write sql queries to get any user(s) information for any date or date range.
  30. 1 point
    Create a table subquery to calculate the total points for each user and join that to the rewards table using the points total. (In my example I assume you have a table called points. SELECT first_name , last_name , total_points , reward FROM { SELECT first_name , last_name , SUM(points) as total_points FROM user u JOIN points p ON u.userID = p.userID GROUP BY u.userID } tot LEFT JOIN rewards r ON tot.total_points = r.valuePoints
  31. 1 point
    htmlentities/htmlspecialchars are output functions. they are used when you output dynamic values in a html context (web page, email.) they are not used when data is received by a script.
  32. 1 point
    Your binary representation is full of regular patterns, I'd wager it being indices (the alphanumeric text like $0<(4@LX`) preceding any compressed data (the unrepresented characters �) for each entry. Just a shot in the dark. It doesn't mean what is under it isn't encrypted. Wow, I haven't logged in for a decade, and Ignace you're a moderator, congrats!
  33. 1 point
    It's... no, moving it outside the root isn't going to change anything for the better. If the script needs to be run at user request, like yours, then moving it outside the root is irrelevant. The only reason for files to be outside the root is so that the user can't plug in some URL into their browser and execute files they aren't supposed to. But here, you want the user to execute ajax.php. So not only is there no point to moving it, you're actually hurting yourself in the process. Leave it where it was. It's fine.
  34. 1 point
    No, it's not a burden. It's how 95% of the web works now.
  35. 1 point
    You have single quotes arond "time" so it is being treated as a string literal. Use backticks like you have around the previous one.
  36. 1 point
    They are the same. Note the github url on the packagist page. Generally speaking in these situations I start by designing the PHP interface I need and then try and code the necessary drivers to match that interface. As drivers are built it may be necessary to change the interface to accommodate. For example you may start with: interface DeviceController { public function start() : Promise; public function stop() : Promise; public function open() : Promise; public function close() : Promise; //... } Then, foreach device you have to support make a driver that implements that interface, for example: class ModbusRtuDevice implements DeviceController { private $socket; public function __construct(SocketClient $socket){ $this->socket = $socket; } public function start() : Promise { return $this->send('start'); } public function stop() : Promise { return $this->send('stop'); } public function open() : Promise { return $this->send('open'); } public function close() : Promise { return $this->send('close'); } private function send($action) : Promise { $command = json_encode([ 'action' => $action , 'arguments' => [] ]); return $this->socket->sendCommand($data); } } The just code the rest of your application according to the DeviceController interface. I'd focus first on just creating an interface that you'd ideally want. Then focus on implementing a driver for it for whatever your most common device type is. Adjust the interface design where required as problems arise. Once that is working, move on to implementing a driver for the next most common devices. Again, adjust the interface as required but keep in mind your first driver. If a change is needed and avoid just adding some driver specific method/parameter. Adjust the interface to something that works for both devices and make the adjustments to the original driver as needed to accommodate the new interface design. A lot of this is sometimes easier said than done, I know. Sometimes it may take quite a few iterations to really get things in a good place.
  37. 1 point
    'One column'?? You mean a single column on a single record or that singled column across all of the records in that table? And how do you know that it has changed? Are you saving the original value somewhere in your session or in another record?
  38. 1 point
    Can you explain better what you mean by "changed database"? A database is a set of tables of which your server/account may have several. Are you talking about a chang e to a single table? How do you tell if a table has been changed? Query every single record and compare it to something saved?
  39. 1 point
    First step is to logs the contents of $data somewhere so you can look at what is in it.
  40. 1 point
    Attribute which are arrays (like "image" are ignored, as are attributes with no values. Where no heading translation is provided the raw attribute name is output. <?php $headings = [ 'attribute_pa_pack-quantity' => 'Pack&nbsp;Qty', 'attribute_pa_variation' => 'Variation', 'sku' => 'SKU', 'variation_description' => 'Var&nbsp;Desc', 'variation_id' => 'Id', 'price_html' => 'Price' ]; $systems = []; foreach ($variations as $var) { $atts = array_values($var['attributes']); $key = $atts[0]; $kv = count($var); $ka = count($var['attributes']); if (!isset($systems[$key])) { $systems[$key] = []; } $systems[$key][] = array_merge(array_slice($var['attributes'], 1, $ka-1, 1), array_slice($var, 1, $kv-1, 1)); } echo '<pre>', print_r($systems, 1), '</pre>'; ?> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Example</title> <style type='text/css'> body { font-family: calibri, sans-serif; font-size: 10pt; } .system { width: 30%; float: left; margin-right: 30px; } .item { padding: 5px; margin-bottom: 15px; } .hdg { display: inline-block; width: 150px; font-weight: 600; } </style> </head> <body> <?php foreach ($systems as $sys => $sdata) { echo "<div class='system'><h3>$sys</h3>\n"; foreach ($sdata as $item) { echo "<div class='item'>\n"; foreach ($item as $h => $v) { if ($v && !is_array($v)) { $hd = $headings[$h] ?? $h; // use attribute key if no translation available echo "<div class='hdg'>{$hd}</div>$v<br>\n"; } } echo "</div>\n"; } echo "</div>\n"; } ?> </body> </html>
  41. 1 point
    You are building your foreign keys the wrong way round, EG ALTER TABLE `programs` ADD FOREIGN KEY (`program_id`) REFERENCES `deal_type` (`program_id`); should be ALTER TABLE `deal_type` ADD FOREIGN KEY (`program_id`) REFERENCES `programs` (`program_id`); program_id is the primary key of the programs table. When it appears in another table (such as deal_type) it is, therefore, a foreign key linking back the programs record. Also CREATE TABLE `deal_type` ( `deal_type_id` int AUTO_INCREMENT, `affiliate_id` int, `program_id` int, `affiliate_deal_id` int, PRIMARY KEY(deal_type_id,affiliate_id,program_id,affiliate_deal_id) -- really? PK should be deal_type_id );
  42. 1 point
    If you have multiple web servers, no CDN, and no other form of centralized storage, putting files in a database is how you can distribute the files across all the servers. Another is replication - databases exchanging data with other databases. If you have multiple database servers running with replication already, putting files in there means those files are replicated as well. I disagree. I'm rather surprised to even hear that statement being made. But why? Why store them in multiple places? There's no need. A file is more than just binary data. Smart browsers can recognize the data from a PNG image and not confuse it with a JPEG image. But not all browsers are good at that, and sometimes file data looks similar across different types. Which means you need to know the MIME type for a file and send it to the browser. Which means identifying what it is, storing it in your database, and sending it through your PHP script. Additionally, a request for a file doesn't have to be for the entire file. If you had a large file, a browser could try to download it, and if that process fails (eg, internet disconnected) recover from where it left off. When it tries to continue it tells the server that it doesn't have to send the whole thing - only parts of it, or starting from a certain offset. Managing that on your own in PHP is annoying. Web servers can do all that for you.
  43. 1 point
    mssql_connect was removed from Php http://php.net/manual/en/function.mssql-connect.php PDO is how you will want to do it. http://php.net/manual/en/book.pdo.php
  44. 1 point
    You could do it with PHP, but the more you learn and advance with web development the more you're going to need to know Javascript and understand things like AJAX. One step at a time. Get the rest of your idea in place, the stuff you already know how to handle, then when you get to the trophies you can think about how to use the opportunity to expand your skillset.
  45. 1 point
    It is really incredible how MANY different problems you encounter and have to post for us to puzzle over. So much stuff I have never imagined could be in existence and you seem to come up with reasons why they don't work for you. Do you just spend 24x7 researching things to learn about? Or do you have such a diverse workload that you have to learn all of this "stuff"? All of the things you have posted can't possibly all be connected, can they? If so it must be one heck of a project!
  46. 1 point
    The only difference between the "OOP" and "procedural" versions is that one uses $object->function_name($arguments) and the other uses similar_function_name($object, $arguments). I didn't look hard at what you did but I did see you did more than just change the function calls.
  47. 1 point
    Since PHP doesn't actually "do" color, I would suggest that you use CSS. Setup a set of colors in your CSS area and then as you loop thru the numbers and create the HTML that will output those, assign a CSS classname. First the CSS <style> .color_1_10 {color:red;} .color_11_20 {color:blue;} .color_21_30 {color:green;} .color_more {color:black;} </style> Now the PHP for ($i=20; $i<=49; $i++) { switch ($i) { case <= 10: $clsname = 'class_1_10'; break; case <= 20: $clsname = 'class_11_20'; break; case <= 30: $clsname = 'class_21_30'; break; default: $clsname = 'class_more'; break; } echo "<span class='$clsname'>$i</span><br>"; } Note that I used a different range of numbers, but I think you get the idea.
  48. 1 point
    I tried it using the page you linked and it worked for me. Goes on the li. Oh, and remove the float. And you'll probably want to tweak the margins a little.
  49. 1 point
    Have you got php error reporting turned on in your php.ini file? (You have ann error in the PDO options)
  50. 1 point
    Have you tried the Query Browser? Also, SQLyog is also good, though the interface takes some getting used to. Obviously, Navicat is excellent, but not free. Personally, I still use the old MySQL Control Center, but only because the Query Browser is not supported under Win98. Hope that helps.
This leaderboard is set to New York/GMT-05:00
  • Newsletter

    Want to keep up to date with all our latest news and information?
    Sign Up
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.