Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


gizmola last won the day on January 21

gizmola had the most liked content!


About gizmola

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Los Angeles, CA USA

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

gizmola's Achievements

Prolific Member

Prolific Member (5/5)




Community Answers

  1. Please use code tags <>. Basically you need to make up your mind as to what this script is intended to do: Return the data for an image, so that it can be referenced as the source in an image tag. Return Some html The problem you have right now is that you are setting the header, as if you wanted to return image data header ('Content-Type: image/png'); Then you return some html, which includes an img tag and an embedded base64 image. echo '<img src="data:image;base64, ' .$im. '" style="width:5in;height:5in;">'; So, if you want to return the data and reference the script in an <img src="..."> tag, then you would continue to use the header (as long as your image is actually going to be a .png) and just return the image data. Often this is what people want to do, when creating an image on the fly in the server. In your case, you started with some base64 data, that is perhaps an image. If so, then all your existing code would need is this // header ('Content-Type: image/png'); --NO! You are returning HTML not image data $b64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; echo '<img src="data:image/png;base64, ' . $b64 . '" style="width:5in;height:5in;">'; Amongst the several confusing mistakes you are making currently, you read data into a GD OBJECT. Then you try and return that object in a place where you need base64 encoded data. If you are going to use a function, you need to actually take 30 seconds and look up the function and at minimum: Check the number and types of the parameters Check what the function returns I'm going to assume here that there is some reason you want to read image data into GD. In this case, you commented out all the code that you would need to actually have this function. At minimum it would be more like this: // header ('Content-Type: image/png'); --NO! You are returning HTML not image data $b64 = "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; $bin = base64_decode($b64); // Load GD resource from binary data $im = imageCreateFromString($bin); if (!$im) { die('Base64 value is not a valid image'); } echo '<img src="data:image/png;base64, ' . base64_encode(imagepng($im)) . '" style="width:5in;height:5in;">'; This is unsophisticated code, because it has the baked in assumption that your original source is the base64 encoded version of a .png image.
  2. $data is an array with one element that is an array. That array has a lot of elements including the one you say you want. So try: <?php foreach ($data[0]['lastData'] as $key => $key_value) { echo "key: $key, value: $key_value <br>"; } Once you have figured out which keys you actually want, you should be able to access them more directly. So for example: echo "<p>Temperature (F): {$data[0]['lastData']['tempinf']}</p>"; echo "<p>Wind (mph): {$data[0]['lastData']['windspeedmph']}</p>"; I don't see a min/max temp value in the data you provided. Aside from 'lastData', there are several other keys and nested arrays in some cases. For figuring this out in the future, aside from var_dump, print_r is often a useful development/debugging function that can be used as an alternative.
  3. Maybe one of your validations failed, and it set a value in $this->error_array. You check if that's empty, but if it isn't, you just return false, so the value of that array is set to something you don't make that visible. You should probably have a method to return it. class Account { // current code public function getValidationErrors() { return $this->error_array; } } And then your code could be something like: if($account->UpdateDetails($firstName,$lastName,$email,$userLoggedin)){ //Sucess echo "update"; } else { ///failure echo "No update"; echo '<pre>' . explode(PHP_EOL, $account->getValidationErrors()) . '</pre>'; }
  4. Being able to pass extra/unlabeled parameters was a feature you could make use of using func_get_args. PHP version 5.6 added variable parameter lists(variadic) and the "..." operator to formalize this and make it easier to use. So now you can have code like this: function giftBasket($occasion, ...$contents) { echo "You purchased the $occasion basket that contains " . implode(', ', $contents) . '.' . PHP_EOL; } giftBasket('Holiday', 'Salmon', 'Crackers', 'Candy'); giftBasket('Birthday', 'Balloons', 'Cupcakes'); giftBasket('Valentine', 'Chocolates'); The "..." operator is called the Spread operator or spread syntax in javascript. Some languages like Ruby call it the "splat" operator, although most use the asterisk. It works to essentially explode an array into individual variables that can then be passed as parameters. function bio($name, $city, $state) { echo "$name is from $city, $state" . PHP_EOL; } $players[] = array('Bob', 'Phoenix', 'AZ'); $players[] = array('Samantha', 'Boise', 'ID'); $players[] = array('Charlie', 'New Haven', 'CT'); foreach ($players as $player) { bio(...$player); } The PHP group has been pretty busy adding features like this to the language.
  5. Hope your recuperation goes well. We'll be here when you are feeling better.
  6. Not sure what you mean by "not getting"? One thing that's important to understand is that url's involve "web space", not filesystem space on a workstation. If you use FILE|OPEN with your browser, the browser goes into a local mode where it will parse html etc, and will work with local files and paths but rarely do I see this use case. Since I'm not sure what the purpose of your current scripts are, it's hard to say, but a URL is not a filesystem path. Is this code meant to be accessed via a browser? Then your URL's need to be within webspace, and not reflecting a file system path. Just for clarity, even with what you have, it's odd, and you introduce a space where you probably need a directory separator. If you are using interpolation, then use it. Maybe? echo "<a href='$latest_dir/$latest_file'><button>continue</button></a><br>"; With that said, this should only produce a url with a local filesystem path, and only usable by a browser in local mode, which is almost never what you want to be using PHP for.
  7. I interpreted the question specifically to be someone with subdomains. So for example. www.mysite.com store.mysite.com It's pretty common to have setups like this, where you might want or need a session to be accessible to both subdomains. Since the main mechanism used to pass the session id is a cookie, restrictions on cookies are relevant. The default unless you change it, is to have the PHP session cookie set for the subdomain rather than the domain. The setup information provided was ostensibly code to change default session handling so that the session cookie is configured for all subdomains (.mysite.com) which would enable the reading and writing of session values by any subdomains of mysite.com.
  8. 100% what requinix said. Unless there is some important reason you need to try and differentiate between "mobile" devices and whatever other client might be consuming your site, all that matters is that your site is responsive. It's probably just as important that your site looks good on large screens rather than designing to a one-size fits all mentality. min-width and max-width can be helpful. Some of that is using newer layout features like flexbox or grid, and avoiding fix sizes. Use em and rem for typography. learn about attributes relative to the viewport like vw, vh, vmin & vmax. learn about min-width and max-width style images with width: 100% so they expand and contract. learn and use flexbox and/or grid for your layout learn media queries and how to use them A basic example would be a nav bar styled using flexbox. With flexbox you would have a container/parent element like "nav" <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> </nav> CSS would be something like this: nav ul { list-style: none; padding: 0; font-size: 3rem; display: flex; justify-content: center; } nav li { margin-left: 2em; } nav a { text-decoration: none; color: #707070; font-weight: 700; padding: .25em 0; } nav a:hover, nav a:focus { color: lightblue; } @media (max-width: 650px) { nav ul { flex-direction: column; font-size: 1rem; } /* have to reset the margin for centered menu items */ nav li { margin: .5em 0; } } You can play with the max-width value here, but this illustrates a pretty standard technique of having a desktop layout that you then modify using one or more media queries, to change your desktop styles to something more mobile friendly. In this example, I have the nav with a default "row" orientation. The li items are centered and layout in a row across the screen. When the width of the browser is shrunk below the threshold of 650px wide, I change the "nav ul" flex-direction to "column" which causes the li items in the nav to be in a column. I also reduce the font-size and change the margin property so the text is no longer centered. This is a very simple example, but it should give you a jumpstart into what "responsive" design offers.
  9. No worries my friend, your passion and desire to produce is very evident, and speaking for most of the regulars here, we invest time here to try and help people like yourself who are working hard at building up their expertise.
  10. I am doing the same as @requinix. I also paid the $15 fee to get the registered/upgraded capabilities of Inteliphense. Just make sure you follow the instructions for the use of Inteliphense. Very worth it. Key thing to do after you install intelliphense: VSCode's built in Emmet support is a killer feature when you are writing a lot of html.
  11. First off, does it matter whether or not a column is null or ''. The answer to that very much will dictate what you might need to do here. The difference between NULL and an empty string with mysql is an annoyance. Short answer: If you need to query for values in a column that are either NULL or not NULL, then your syntax needs to be different. The standard equality '=' check doesn't work. For example, looking for NULL values in a name column: SELECT * FROM test WHERE name = NULL; Will be empty. You have to use: SELECT * FROM test WHERE name IS NULL; However, if the value is an empty string: SELECT * FROM test WHERE name = '' Will work. In order to update a column to NULL you need to use the exact syntax of UPDATE asset set sale_stamp = null WHERE id = '17' You mention the "generated SQL". You don't specify what is generating the code. With that said, I would probably first try to see if setting the value of $sale_stamp to PHP null works. $sale_stamp = empty($_POST['sale_stamp']) ? null : $_POST['sale_stamp'];
  12. Hi Leon, Some problems with your markup: Block elements already have a box around them. You don't want to nest an h1 inside a p for example: <p><h1 class="headline">Et godt eksempel på at det fungerer, er at IANA har godkjent særnorske tegn i domenenavn. Om det er noe som har slått til (blitt en suksess) er ett annet spørsmål. Du kan jo forsøke selv og se om det er noen norske butikker og firmaer som har registrert sitt firmanavn, for eksempel. www.elkjøp.no .</h1></p> Use something like this instead: <article class="article"> <h1>Title</h1> <p>Article text here ........ </p> </article> Hey let me suggest to you a methodology for css naming and specificity I really like: BEM. CSS can easily have specificity issues, and can also make your page structure brittle. One thing you are doing that is not great, is to use div.class in your css. That's just a bad idea. Rules of thumb are these: Never use ID's for selectors Don't select by tags for any complex selectors Give everything you want to style its own class So with BEM you want to step back and look at your "blocks" What are they from a structural level? From what I can see your outline should have started with something like this: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Site Title</title> <link rel="stylesheet" href="style.css"> </head> <body class="body"> <header class="header"> <!-- Logo Top Menu nested here--> </header> <div class="body__container"> <section class="menu"> <!-- Menu block here --> </section> <main class="main"> <article class="main__article main__article--primary"> <h1 class="main__headline">Hva ligger bakenfor?</h1> <p class="main__content">Organisasjoner som setter standarder for drift, bruk og utvikling av internett.</p> </article> <article class="main__article"> <h1 class="main__headline">...</h1> <p class="main__content">...</p> </article> </main> </div> <footer class="footer">Footer Stuff Nested here</footer> </body> </html> I would take a step back from what you are doing and make sure you have a clean block structure. With BEM, you make a class for each semantic block. You should remove all those div.class selectors. Make a css class for every block, element and element--modifier you see, and add any additional ones you need for menus etc. .body { } .body__container { } .menu { } .menu__button { } .menu__title { } .menu__text { } .menu__link { } etc. For the menu, usually people will use either a ul with nested li items, or a bunch of buttons inside a section. <section class="menu"> <div class="menu__title">Naviger</div> <a class="menu__link" href="index.php" title="Tilbake til Start"> <button class="menu__button"> <span class="menu__text">Hjem</span> </button> </a> <!-- other menu items the same --> </section>
  13. There are many ways to accomplish this. What approach have you attempted so far? HTML tables Flexbox Grid One fundamental technique for procedural programming, when looping through a set of data, is to utilize the modulus operator. By checking the remainder of division by the number of items you want per row, you can determine whether or not to start a new line, or whether a new line was just started. Consider this code that has a simulated result set of rows: <?php define('PER_ROW', 3); $resultset[] = array('id' => 3, 'name' => 'Bob'); $resultset[] = array('id' => 5, 'name' => 'Mark'); $resultset[] = array('id' => 9, 'name' => 'Sam'); $resultset[] = array('id' => 10, 'name' => 'Linda'); $resultset[] = array('id' => 11, 'name' => 'Amy'); $resultset[] = array('id' => 75, 'name' => 'John'); $resultset[] = array('id' => 20, 'name' => 'Aaron'); $resultset[] = array('id' => 19, 'name' => 'Ringo'); $resultset[] = array('id' => 2, 'name' => 'Paul'); $resultset[] = array('id' => 99, 'name' => 'George'); foreach ($resultset as $key => $row) { $key++; if ($key % PER_ROW === 1) { // First item in row echo "| "; } echo "{$row['id']}: {$row['name']} | "; if ($key % PER_ROW === 0) { // Last item in row echo PHP_EOL; } } echo PHP_EOL; You can play with this example here: https://3v4l.org/lD83M Changing the PER_ROW constant to another number like 4 for example, should help you see how this common technique works.
  14. One reason I keep coming back to the forum, is that there are times when someone uses some syntax or a function or technique I'm not familiar with or wouldn't have thought to use. Seeing what other people offer as a solution to questions is a nice diversion and helps keep the learning process fresh.
  15. This is the expected behavior. YOu have declared that the content_box has a width of 950px. So at the point that it can not fit side by side with the menu_box div. I'm not sure what you are going for, because the typical way to handle responsiveness down to mobile sizes is to use a media query and do something to hide the menu, perhaps with the display of a hamburger widget. If you want to keep these divs side by side, then I would suggest you use flexbox instead. With Flexbox, you need a parent container for the columns you want to orientate. There are many layout options possible with flexbox, so I leave that to you, but you can see from this demo that this performs more inline with your expectations. Rather than use a fixed width for your content div, I used 80%, but you can also see how flexbox handles expanding or shrinking. Test Markup <div class="content"> <div class="menu_box"> <ul> <li>Home</li> <li>Item1</li> <li>Item2</li> </ul> </div> <div class="content_box"> <h1>Content Box</h1> </div> </div> CSS div.content { display: flex; } div.menu_box { color: #008833; margin-top: 0px; margin-left: 10px; width: 165px; /*max-height; 100px;*/ height: 300px; /*border: solid 1px;*/ /*border-color: #ffcc99;*/ /*border-radius: 5px;*/ background: gray; } div.content_box { margin-left: auto; margin-right: auto; margin-top: 5px; width: 80%; max-height: 100%; margin: auto; border: solid 1px; border-color: #ffcc99; border-radius: 5px; background: blue; } Codepen based on your original code, with some background colors to see something: https://codepen.io/gizmola/pen/xxXMwLP
  • 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.