Jump to content

benanamen

Members
  • Posts

    2,044
  • Joined

  • Last visited

  • Days Won

    39

Everything posted by benanamen

  1. You have the $ sign bass ackwards. It comes first.
  2. If you are going with a Windows WAMP, Laragon is the best one out of all of them for many reasons. I have used them all. https://laragon.org/
  3. You would first need to trim the POST array as a space would bypass the check.
  4. Just an FYI, Tables for layout went out in the 90's, We use CSS now.
  5. @gizmola and I both gave you code that you have not implemented. You should spend some time going through this PDO tutorial. Making a PDO connection is one of the simplest things you would ever need to do. https://phpdelusions.net/pdo This is all that is required to make a PDO connection. Anything you do beyond this, you should know exactly WHY you are doing more. $con = new PDO("mysql:host=localhost;dbname=test", 'root', '');
  6. Why are you extending PDO? There is no reason for you to do that and you haven't "extended" anything. You already create a connection in Config.php. Why are you recreating it again in Data.php? Take a look at my "Clean PDO" example. https://github.com/benanamen/clean-pdo
  7. For a Windows Dev my recommendation is Laragon and PhpStorm IDE. For Production Server, Debian OS with a current LAMP stack. You will also want to use GIT.
  8. The best books I have found that deals with the Party Model A.K.A "Universal Data Model" is "The Data Model Resource Book" volumes 1-3 by Len Silverston. Your project is a perfect fit for this data model. You will end up needing to re-think how you are currently looking at your data. There are no tenents or vendors. There are parties that have one or more roles that could be a tenent, vendor or anything else. it is possible that a party has multiple roles such as being a tenent AND a vendor. Your current model could not handle that without duplicating data. The party model, no problem and no redesigning or duplicate data whatsoever. https://www.amazon.com/Data-Model-Resource-Book-Enterprises-ebook/dp/B006BBVQQY https://www.amazon.com/gp/product/B0033AHGMY/ref=dbs_a_def_rwt_bibl_vppi_i0 https://www.amazon.com/gp/product/B004U7MUOS/ref=dbs_a_def_rwt_bibl_vppi_i1
  9. IMO, your whole model is off. You would really benefit from implementing the "Party Model". Without getting too deep into it,... at the root you have a Party. A Party is either a Person or an Organization. It then branches off from there. The Party Model is infinitely scalable without having to ever re-design anything. * When you start duplicating things, i.e names, phone numbers, etc, that is a good sign you probably have a design problem. Here is an example.
  10. "Every resource" is wrong. Try reading the free manual. This is too simple to just give you the answer. https://www.php.net/manual/en/mysqli.quickstart.connections.php https://www.php.net/manual/en/mysqli.select-db.php
  11. Two things. You need to upgrade your PHP to a current version. Second thing, mysql_* has been completely removed from PHP. I would suggest you use PDO with Prepared Statements. https://phpdelusions.net/pdo
  12. I am not suggesting you go to a Framework although they are structured the way I mentioned. Check out this free Laracast video series on PHP. It is the only video tutorial I have seen that I would recommend to anyone. It will get you going in the right direction. Watch each one even if you understand it already. The PHP Practitioner https://laracasts.com/series/php-for-beginners
  13. The "real" problem is that you have no Architecture to your site. Having a direct correlation of URLS to file paths is a very restrictive and low level design. By designing using a "Front Controller" or "MVC" pattern with a single point of entry you could move files anywhere you want without affecting the URLS. Optimally, all your files should be above the root save for the index.php and your assets such as images, JS and CSS. It may be above your current skill level but it is well worth learning.
  14. After re-reading this thread it seems apparent that what you really need is a BI (Business Intelligence) tool that is purpose built for the real problem you are trying to solve, generating various reports. Tableau and Power BI are such tools. (There are many others). I am going to bow out of your specific request since I think you are going about it wrong and are not willing to do anything beyond "how" you are trying to solve a problem.
  15. Since you are insisting on doing things they way you are, here is working code. <?php $host = '127.0.0.1'; $db = 'test'; $user = 'root'; $pass = ''; $charset = 'utf8mb4'; $dsn = "mysql:host=$host;dbname=$db;charset=$charset"; $options = [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::ATTR_EMULATE_PREPARES => false, ]; try { $pdo = new PDO($dsn, $user, $pass, $options); } catch (\PDOException $e) { throw new \PDOException($e->getMessage(), (int)$e->getCode()); } $sql = 'DROP PROCEDURE IF EXISTS test1'; $pdo->exec($sql); $sql ='CREATE PROCEDURE test1(IN LastID INT(5)) BEGIN SELECT person.RecordID AS PersonID, organization.Name FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 10; SELECT person.RecordID AS PersonID, organization.Name, organization.City, organization.State, organization.Zip FROM person INNER JOIN organization ON person.lnk_organization = organization.RecordID LIMIT 25; END'; $pdo->exec($sql);
  16. You will get a lot farther if you give us a high level overview of what you have going on rather than how you want to do it. "The users can create tables" is a very bad smell. Something is not right. What we currently have here is know as an XY Problem. https://xyproblem.info/
  17. It's hardly purist. It is basic Database Normalization. What are you going to do if there are more image caps, keep adding columns? +2 to the ADDITIONAL bad DB design. How is the OP supposed to learn when a forum expert shows them the wrong way.
  18. Surprised at you @Barand. There should be a separate table for the image caps keyed to the image url id not consecutive numbered columns. I know you know that.
  19. I mean dump the $data variable. There is nothing there to loop over. var_dump($data);
  20. Additionally, you need to access the file through a server, not the filesystem. If your URL starts like file:/// you are not using a server.
  21. It should be noted that trimming $_POST with array_map as shown will fail on multi-dimensional arrays. A simple function will solve the problem. function trim_array($input) { if (!is_array($input)) { return trim($input); } return array_map('trim_array', $input); } $_POST = [ ["data1 ", " data2", " data3 "], ["data4", " data5", " data6 "]]; $post = trim_array($_POST); var_dump($post);
  22. Any decent editor or IDE will do it for you.
  23. mysql_* has been completely removed from current versions of Php. You need to use PDO with Prepared statements. This tutorial will get you going. https://phpdelusions.net/pdo
  24. I knew this conversation sounded familiar......... https://www.phphelp.com/t/terminology-discourse/33277/5
×
×
  • 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.