Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by benanamen

  1. benanamen

    running windows and linux side by side on s notebook

    Simplest thing to do is install VirtualBox and load Linux in a Virtual Machine
  2. benanamen

    How can I align digit

    function MaFonction($x){ for ($i=0 ; $i<=360 ; $i+=$x){ echo sprintf("%02d", $i) . " ==> " . deg2rad($i) . "<br />"; } } MaFonction(15 );
  3. benanamen

    Parse error: syntax error, unexpected ';' line 44

    The proper syntax is not else, else, else.... https://www.php.net/manual/en/control-structures.elseif.php
  4. benanamen

    Echoing all $_GET values

    Just use var_dump if you just need to see what the array contains.
  5. benanamen

    Join or Union?

    The the left join would have worked if you switched the tables around.
  6. benanamen

    Join or Union?

    You would do a JOIN on ProspectID
  7. benanamen

    Laravel vs raw php code

    It never hurts to learn new things. There are plenty of Laravel tutorials out there. Make sure the tutorial matches the version of Laravel you will be using or you will get stuck, as substantial changes have been made between particular versions.
  8. benanamen

    Laravel vs raw php code

    It depends. Do you want to learn how to code or do you want to learn how to use Laravel? Read the manual and watch the Laracast videos they provide. You should really learn the basics of coding before you attempt a Framework.
  9. benanamen

    Can’t figure out what’s wrong with this array

    It' simple really. You are providing an array, it matches the 1 and returns back to the caller so the rest of the if's are not processed. Try this... <?php declare(strict_types=1); function property_structure_type ($data) { if (in_array("1", $data)) { return "House"; } if (in_array("2", $data)) { return "Cabin"; } if (in_array("3", $data)) { return "Mobile Home"; } if (in_array("4", $data)) { return "Apartment"; } if (in_array("5", $data)) { return "Condominium"; } if (in_array("6", $data)) { return "Townhome"; } if (in_array("7", $data)) { return "None"; } } echo property_structure_type ([2]);
  10. benanamen

    Is there a way to simplify this code?

    A minor comment. This line if(count($result_contest) > 0) Can simply be if($result_contest) The return value for fetchALL is either an array with results or an empty array, or false on failure. There is no need to count anything. The default truthy check of the if is all you need.
  11. benanamen

    Arrays: concatenation operator .= vs =

    Well..., if that isn't a "how about that" LOL. I get the explanation by Andrea, but still.......
  12. benanamen

    Arrays: concatenation operator .= vs =

    Just a reminder, in PHP 7 with strict_types, the second parameter of print_r MUST be a boolean and not an integer or it will fail with a fatal error. Correct <?php declare(strict_types=1); echo '<pre>', print_r($array, true), '</pre>'; Fails Fatal Error <?php declare(strict_types=1); echo '<pre>', print_r($array, 1), '</pre>'; Fatal error: Uncaught TypeError: print_r() expects parameter 2 to be boolean, integer given TypeError: print_r() expects parameter 2 to be boolean, integer given It does "work" but it will give you an Undefined variable notice. It doesn't matter if it is an array or not.
  13. benanamen

    array in mysql database?

    The \ is escaping the /. Why is your data in the DB like that in the first place?
  14. benanamen

    Cant figure out PHP/MySQL Error

    No. https://dev.mysql.com/doc/refman/8.0/en/logical-operators.html
  15. benanamen

    JSON naming convention

    You pretty much covered it in the first sentence so I will just tell you what my standard is. snake_case = DB Columns, Variable Names & Function Names (same as Php. i.e: set_exemption_handler) camelCase = OOP methods, method calls, & OOP Properties PascalCase = Class Names. (i.e: class UserAccount) dash-seperator = Filenames (For SEO i.e: my-file.php)
  16. benanamen

    Extra characters in a image link string

    You have a malformed image tag. Forget the error prone escaping gymnastics. $image = "<img src='imgpg/$part_no.JPG'>";
  17. benanamen

    Hyperlink on email address from database element

    First off, I would suggest eliminating all the escaping gymnastics. It is harder to read, more prone to error and not as clean as not doing it. As to your problem, you are missing the basic syntax of a hyperlink, the closing </a>. Here is a cleaned up version. Take note of the single quotes on the elements. echo "<p>Name:{$item['first_name']} {$item['last_name']}<br> Email: <a href='mailto: {$item['email']}'>{$item['email']}</a></p>";
  18. benanamen

    refreshing page issue

    @gw1500se is correct, you would use PRG (Post/Redirect/Get). You would not need Sessions in this case.
  19. benanamen

    Taking the leap to MVC

    Is the Fowler book agnostic? The concepts are. Will it work for Python and Java as well as PHP? The concepts will Do I already need to understand MVC or OOP prior to reading it?  Not at all. When it says novice, it means it. Also, can you recommend some exceptional books (or online resources) for learning *proper* MVC? I already did.
  20. benanamen

    Taking the leap to MVC

    Novice to Ninja covers MVC and OOP. It's just like the name, you start out a Novice and end up a Ninja. I know the title can imply that the book is FOR novices to Ninja expertise level rather than starting as a novice and ending up a Ninja. I have also brought that up to the author, as my first impression was the latter.
  21. benanamen

    Taking the leap to MVC

    It's your code, your call. There is one other option, you could email a zip to me. There is nothing you have written that I could not do myself so you don't have to worry about me stealing it. I was just offering solutions that will get you on the fast track to where you want to go. So, if emailing to one person doesn't work for you either, then I would say take a break from your project and read a book. Actually, two books, the ones I mentioned previously. If you read and learn what is in them, you wont need us for much of anything, at least for a long time.
  22. benanamen

    Taking the leap to MVC

    LOL! I get it. Op would be in the copilots seat but there's no pilot! (Well, okay, the Laracasts are actually pretty good) Learning Laravel is just that, learning how to USE Laravel when what you really want to learn is how to write your own "Laravel". So sorry to hear you have to work with Laravel every day. I didn't realize things were that rough for you. I laugh when I see ads looking for "Laravel Ninja's". Some fun facts. A current install of Laravel before you even think about writing a lick of code is 7,445 Files and 1,445 Folders. Symphony is a whopping 9,855 Files and 1,843 Folders. I am coming in for a landing and waiting for the OP in the First Class Pilots Lounge.
  23. benanamen

    Taking the leap to MVC

    Jumping into a framework without even being able to do the basics of procedural code separation, de-duplication, logic, etc.. is not a good move IMO. I liken it to trying to fly a Jet Fighter when you haven't mastered the basics of flying a Cessna. Of course it wont hurt anything to snoop around and try out frameworks (I did as a noob) but the OP has some specific timing goals. If he just wanted to "get the job done" that may be one thing, but the OP has stated he wants to learn. It doesn't take MVC or a framework to "separate my website's PRESENTATION from its LOGIC" as the OP posted. Based on OP's posts across numerous forums, he is not ready for Controllers, Models and the like. A framework like Laravel has a whole ton of "magic" which is just going to confuse the OP. I go back to my previous post as a good approach for the OP to move forward swiftly. I for one would take some time to review OP's project as a whole if he should make it available on a repo. So OP, it's your move. You have at least one expert that will review your project and is willing to guide you towards higher level programming. Who better to teach you how to become a "Jedi" than other "Jedi's"? As you correctly stated, there is a lot of junk out there and you don't know enough to know what is a good tutorial.
  24. benanamen

    Taking the leap to MVC

    That's great you want to learn new things. I would encourage anyone to always keep learning. What I would suggest, instead of jumping into something completely new, especially based on your story, is to learn refactoring. There is probably quite a bit you can do with your current code base to refactor yourself towards an MVC/OOP application. I would recommend you put your entire project on GitHub so we can see what your working with and make recommendations. If you don't want the world to see the code you can make the repo private and PM access to those of us that would look it over. I very highly recommend the book "PHP & MySQL: Novice to Ninja, 6th Edition" by Tom Butler & Kevin Yank. I would also recommend the book "Refactoring - Improving the Design of Existing Code" by Martin Fowler. By the time you learn what is in those two books you will indeed be a master "Jedi".
  25. benanamen

    Securing 'hidden' form values

    The current coding standard is to use Prepared Statements. There is no "escaping" done.

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.