Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by benanamen

  1. benanamen

    Newbee Needs Help With Javascript/PHP/Mysql

    OP, What is the point of adding another layer (Javascript) just to get a random value? Why not just generate in Php? And rather than tell us about your attempted solution to the real problem, how about tell us what the real problem is.
  2. benanamen

    Insert into database at all at once

    All of this... $category = $_POST['category']; $item_type = $_POST['item_type']; $item_size = $_POST['item_size']; $product_name = $_POST['product_name']; $item_qty = $_POST['item_qty']; $price = $_POST['price']; $total_price = $_POST['total_price']; $item_price = $_POST['item_price'];
  3. benanamen

    Insert into database at all at once

    Get rid of the variables for nothing. You already have the POST values, just use them.
  4. The option is in Webmin=>Webmin Users
  5. benanamen

    Optimize My Code

    "Variable for nothing" $task = $_POST['task']; There is no change or transformation of the data. The $task variable is for nothing. You already have the POST variable, just use it. "Internal System Error" echo $sql. "<br>". $e->getMessage(); That info is completely useless to the user unless they are a hacker.
  6. benanamen

    Optimize My Code

    There are a few things. From the top down.. $errors should be an array. You need to check the REQUEST METHOD, not the name of a button. You need to use Prepared Statements You need to kill the script after header redirects Do not output internal system errors to the user Do not create variables for nothing
  7. benanamen

    having a brain-block

    A single equals is an assignment. A double equals is a comparison.
  8. benanamen

    Need Help

    You are missing a right parentheses. If you used a decent IDE it would have shown the error.
  9. 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
  10. 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 );
  11. 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
  12. benanamen

    Echoing all $_GET values

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

    Join or Union?

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

    Join or Union?

    You would do a JOIN on ProspectID
  15. 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.
  16. 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.
  17. 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]);
  18. 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.
  19. benanamen

    Arrays: concatenation operator .= vs =

    Well..., if that isn't a "how about that" LOL. I get the explanation by Andrea, but still.......
  20. 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.
  21. benanamen

    array in mysql database?

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

    Cant figure out PHP/MySQL Error

    No. https://dev.mysql.com/doc/refman/8.0/en/logical-operators.html
  23. 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)
  24. 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'>";
  25. 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>";

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.