Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by benanamen

  1. 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
  2. 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
  3. 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.
  4. 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.
  5. 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);
  6. 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/
  7. 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.
  8. 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.
  9. I mean dump the $data variable. There is nothing there to loop over. var_dump($data);
  10. 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.
  11. 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);
  12. Any decent editor or IDE will do it for you.
  13. 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
  14. I knew this conversation sounded familiar......... https://www.phphelp.com/t/terminology-discourse/33277/5
  15. Sounds to me like you have an Architecture problem. You "should" be serving all your files through a single point of entry. You might want to start a new thread about that topic with details of how you have things set up.
  16. Where does $url magically come from?
  17. You need to use Prepared Statements and your problem will be solved. NEVER EVER put variables in your query and NEVER EVER trust user supplied data. But as to why the problem, there are no quotes in your $_POST values. You have $_POST[article_id] instead of $_POST['article_id']
  18. Yes, stop using shared hosting and get a VPS.
  19. As far as file names, what DOES make a difference is underscore and dash to separate words. As simple search proves this out. On google search fast_cars and see returned result count, then try fast-cars. I get 13,000,000 results and 1,600,000,000 respectively Bottom line, use dashes as the separator.
  20. Take a look at my clean-pdo code repo. https://github.com/benanamen/clean-pdo
  21. Your code is vulnerable to an SQL Injection Attack. You need to use Prepared Statements. NEVER EVER PUT VARIABLES IN YOUR QUERY
  22. The form data is in the POST array which you do nothing with. Besides that, this code will be vulnerable to an Email Header Injection Attack if it were to work.
  23. Oh, so your a Domain Squatter. 🚩🚩
  24. The break tag (br) by no means goes anywhere within a Select element. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select
×
×
  • 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.