Jump to content

gizmola

Administrators
  • Posts

    5,959
  • Joined

  • Last visited

  • Days Won

    146

Everything posted by gizmola

  1. If you can afford it, PHPStorm is pretty much the professional standard. A lot of people also use visual studio code, in combination with the "Intelephense" plugin. Intelephense provides a good number of features for free, but you can also license it for $20 to unlock the rest of the features, which I would highly recommend.
  2. I looked at the site, opened the menu and tried to navigate to: http://whymyphp.online/galery/fetchit.php which produces a 500 error. This is the same issue we've been looking at, and we keep coming back to the fact that mysqli is not the version that has been linked to the myslqnd driver. This is not by any means a new issue. See this 4 year old SO question. The confusion relates to godaddy and cpanel, and the specific extensions that are enabled through cpanel. At this point, it is pretty much up to the OP to enable the right extensions through cpanel.
  3. Phpmyadmin is just a PHP application. Access to the CPanel setting you want is described here: https://www.godaddy.com/help/view-or-change-the-php-version-for-my-linux-hosting-16090
  4. It would not work any better in Oracle, because your logic is faulty. Keep in mind that inside your parens, if any of those items are TRUE, then the entire group is true. team_name is not null or team_name !='' or team_name NOT LIKE '%[teamname]%') In the row you don't expect, consider each condition team_name is not null ---> true team_name !='' ---> true team_name NOT LIKE '....' ---> false. So you get the row, despite the fact that the 3rd condition is false. What it appears you really want is: team_name is not null AND team_name !='' AND team_name NOT LIKE '%[teamname]%')
  5. This is really the crux of the issue. Applications are rarely written from scratch -- they are assembled from component libraries (a collection of OOP classes). You don't have to know how to write your own OOP code immediately, or even to write any sophisticated OOP to make use of other peoples components. This is why you really want to start with composer and learn enough about that to start making use of components that will make your application faster, and better quality in the vast majority of cases. You can always verify the quality of the component, by looking at and even running unit tests they have written for the library. You need to know the basics of oop, but you don't have to be an OOP expert.
  6. Along with validation, using the developer tools is an excellent iterative way to explore the state of the DOM, and to find syntax errors in javascript, or to explore layout and effective styles. The network tab is also extremely valuable, in examining request/response data for ajax or regular form processing via get or post requests. That should always be your first step in starting to debug things. Most modern code editors people use to develop PHP with will also catch a lot of syntax errors, although code that renders html will typically look valid so long as the php code is valid. Moving html into a template engine, or even making use of heredoc and nowdoc is helpful in many ways to separate markup from your logical code.
  7. The purpose of phpfreaks is to help people learn about and develop web applications. Ultimately, all we want is people who are genuinely making their best effort. There's no reason for anyone to be angry with you or this thread. I do appreciate you providing an update on your progress, and the reasoning behind your conclusions.
  8. GoDaddy has a bunch of different hosting plans, and lots of servers. Experience with one particular server, doesn't predict exactly what you might experience with a different account, that is likely hosted on a different server. You can get a lot of information just using phpinfo() on each. As Requinix has already discussed, the issue points to lack of the mysqlnd driver. In GoDaddy's cpanel, you can change php configurations using the Select PHP Version. In the menu, I'm guessing you'll see mysqli checked, and nd_mysqli unchecked. There should also be a choice for mysqlnd, that may or may not be checked. If it is not checked, check it. Uncheck the mysqli option, and check the nd_mysqli option. Save this new configuration, and then retry your code. Please let us know if this fixes the issue.
  9. I should add, you could attach this code to the onclick of a button you have separately, or add to every new row. Obviously, as you can see, setting the onclick for the buttons this way makes it very easy to render an equivalent button without having to also manage a call to addEventListener for each new row that's generated. If you only want to have one button for adding new rows, then I'd give that button an id and use element.addEventListener instead.
  10. In this case you don't need ajax. The way to think about a feature like this, is to make sure you are clear on what is happening in the browser when you are on a web page that has already been delivered to your browser in an HTTP response. The page has the DOM loaded, and is running completely disconnected from the server. If you were looking at network traffic, you would likely see that there is no connection to the web server open. So the way to think about it, is that you have a javascript application running in your browser. A traditional form, when submitted, is a new request to the server. Depending on if it's GET or POST method, a new HTTP request gets sent, the browser waits for the response, and the entire DOM is rebuilt based upon the response data, which is going to be more HTML (along with associated javascript, css etc.). Ajax was added to the DOM api, in order for there to be a way that a page could send and receive data, without this entirely new HTTP request/response. It's an HTTP request through javascript, where the data returned can then be evaluated within the running javascript and used to update the page. So ajax is an alternative to standard HTTP request/response, typically with forms, but now, with many other aspects of dynamic DOM manipulation with javascript. So, hopefully that helps you understand ajax, and why it is extremely beneficial and useful in modern web applications. In this case, it is absolutely not needed. So to go back to the page in your browser, that page is running locally as an application hosted within the browser. It has to be able to handle mouse and keyboard events, and unless it's a standard click on a link, or a submit button for a form, there won't be a new http request generated by default. What you have is a form, where you have rendered a table inside of it with a series of HTML form elements to be filled in. You want to be able to add a new set of these form elements, and all that is required there is javascript, running locally to dynamically manipulate the DOM and add a new row to the table with a new set of table elements. jquery is the grandfather of javascript frameworks. It was designed to make it easy for people to do DOM manipulation of the type you need, and it also has functions that make ajax easy. Most developers who have been around a while, have probably used it in the past, and it was part of the first really popular css ui framework (Twitter Bootstrap). It's got a lot of capabilities, but it's also a bit bloated by today's standards. As things have evolved and changed in the javascript UI world, a lot of other libraries and javascript frameworks have emerged, and many of the things jquery was used for in the past are being done instead with a framework like react or vue. So I won't show you how to do this in jquery, since if you already aren't using it in some way, I won't suggest to start down a path that isn't being used for new development. Here is some simple javascript that will dynamically add a new row to an existing table. It isn't exactly matched to what you have now, but is based on it. function addRow() { console.log('clicked addrow'); const table = document.getElementById("form_wrapper"); const row = table.insertRow(1); let c1 = row.insertCell(0); let c2 = row.insertCell(1); let c3 = row.insertCell(2); let c4 = row.insertCell(3); c1.innerHTML = '<label>Item:</label><input type="text" class="item" size="5" name="item_number[]">'; c2.innerHTML = '<label>Desc:</label><input type="text" class="description" size="20" name="description[]">'; c3.innerHTML = '<label>Qty:</label> <input type="text" class="quantity" size="3" name="quantity[]">'; c4.innerHTML = '<button type="button" name="add_row" onclick="addRow()">+</button>'; } Here's a codepen, for demonstration purposes: https://codepen.io/gizmola/pen/jOQLKBd I think you'll find that this use of document.getElementById, is the most common way to select an item that has an id attribute. There should only ever be one element on a page with that id, so it's perfect for selecting the table. Once you have the table element you can dynamically add a new row, and the cells you need.
  11. I don't think you understand rewrites. Rewriting in this way allows you to use a non-existent url like /slugname/ to the scripts that can actually process them. You can't "rewrite" the actual scripts to a non-existent url. They could never be resolved. Rewrites are not magical "rewrite my url's to the rest of the world on the fly". It's the responsibility of your markup and code to display your url's in the virtual/ pre-rewritten form you want users to see them. If I've misunderstood your statement, please let respond with a specific example as in: Client sends https://www.domain.com/a/ ---> Server rewrites to https://www.domain.com/page.php?slug=a
  12. The fields that are part of the result from 4 joined tables, isn't really important in comparison to the number of rows in the result set, and any limiting where clause criteria. As @requinix stated: EXPLAIN query... is your analysis tool. We'd need to see the query and its explain plan to offer further insight. Many times, if performance is bad, you'll be able to see the reasons in the explain. Depending on the criteria, adding a covering index might solve your performance issue, but the only way to know for sure is via the explain. You want to take a look at the rows and key columns to see how many rows are being examined, and what indexes (if any) are used in generating the final result.
  13. There are different strategies for handling multiple entries, but the one employed most frequently is to implement some javascript that will allow you to add a new form group to the table dynamically, using an "Add another item" button or something similar. Rather than trying to make the input names unique, utilize array name syntax like so: echo '<td><input class="item" name="item_number[]"></td>'; Once you do this, $_POST['item_number'] will be an array, and you can foreach() through it to validate data and do as many inserts as you have validated items. Hopefully, it is clear that you will use the array syntax with all the fields, and when you dynamically add a new input row, be sure to also use that syntax for the dynamically created row/input group.
  14. Gonna throw out my best guess here, based on the snippet and some variable naming, that OP has gotten a script designed to be run from the cli, that automates interaction with some crypto faucets. OP didn't write the app, doesn't really know PHP, isn't likely to learn it, and is just trying to run this script to get it running as a means to an end. Script contains features designed to isolate it from anything else that might be running on a server offering PHP.
  15. PHP is in a pretty good place now, and is a very different experience than what it was 10 years ago. With that said, it's really not a highly used Devops/sysadmin language. Neither is Perl, for that matter. Devops, and the emergence of the practice of Devops will likely be new to you. It's where system administration has evolved to. Here are the main take aways in my opinion: Virtualization/The Cloud is pervasive Much of hosting is done on virtualized servers. So familiarity with the different types of virtualization is highly valuable In addition/ Containers (Docker, Kubernetes, etc) have been taking over application development, and increasingly production deployments DevOps makes git and hosted git repositories a core component of deployment and administration. You have to know git well, and the options for hosted git like github, gitlab and bitbucket DevOps groups use Hashicorp Terraform for "infrastructure as code" to setup/teardown/alter complicated environments in the cloud The tools for additional provisioning and maintenance of servers continues to evolve Chef and Puppet were both popular and continue to be used by many orgs, but Ansible and Salt(stack) have emerged as alternatives for automation of administrative tasks Ansible and Salt are both written in Python Chef is written in a combination of Ruby/Erlang Puppet was originally written in Ruby, but has evolved into a hybrid c++/clojure/ruby product Once you start using any of these provisioning/admin tools, you end up focused on their recipes/modules and in some cases, you might be able to extend them, or use elements of the core language. Notice that there is no java/javascript/php or perl to be found in this list. I don't mean to discourage you from jumping into modern PHP development, but it has to be said, that it's not a big player in the world of System administration/Devops, so you might be better off learning Python & Ansible if you plan to get back into hosting & system administration.
  16. Add some extra checks in to prevent the rendering of dates in the table if they are in the past. This should work: <section class="content" id="termin"> <?php $dt = new DateTime; $thisWeek = $dt->format('W'); $thisYear = $dt->format('o'); if (isset($_GET['year']) && $_GET['year'] >= $thisYear && isset($_GET['week']) && $_GET['week'] >= $thisWeek ) { $dt->setISODate($_GET['year'], $_GET['week']); } else { $dt->setISODate($dt->format('o'), $dt->format('W')); } $year = $dt->format('o'); $week = $dt->format('W'); ?>
  17. I don't understand the question. You created the table with code to have a range of days and times. Your code created the table. What would you want to be different about the days or times output?
  18. HTML5 date inputs have a min/max attributes you can set. See the mozillla page.
  19. You need to define what "not working correctly" means. $mail->Host = 'localhost'; This tries to send mail through your server. That is not going to work. With godaddy, you need to send your email through their mail servers. Typically they provide that information to you in some fashion.
  20. This is going to be a little more complicated with your date string, because you will need to turn the date string back into a valid javascript date, so that you set your form date element value. See if you can figure out how to do that. I'll give you a hint, on how to strip out the <br> tag from the date string, leaving you only with the text. function MyFunction(col, time) { const tbl = document.getElementById("myTable"); let dateValue = tbl.rows[0].cells[col].innerHTML; console.log('dateValue: ' + dateValue); dateValue = dateValue.replace('<br>', ' '); let dateEl = document.getElementsByName("tDatum"); let timeEl = document.getElementsByName("tVreme"); dateEl[0].value = dateValue; timeEl[0].value = time; } Another hint: google for javascript Date.parse()
  21. You should see a pattern by this point, in terms of how you select a dom element in html. So long as the element has an id, you can use: let someVar = document.getElementById('someId'); So that is one way. You did not give your form elements id attributes. It would be simpler if you did in this case. However, there are other ways to select an element into a javascript variable. Since you did use name attributes, you can use that. However, the same name can be used for multiple elements, so you would need to do this instead. function MyFunction(col, time) { const tbl = document.getElementById("myTable"); let dateValue = tbl.rows[0].cells[col].innerHTML; console.log('dateValue: ' + dateValue); let dateEl = document.getElementsByName("tDatum"); let timeEl = document.getElementsByName("tVreme"); dateEl[0].value = dateValue; timeEl[0].value = time; } You reference the 0th element in the arrays returned by getElementsByName, which is fine in this case, because we know that there is only one form element with that name in your html document.
  22. The time is being passed as the 2nd parameter as a string. In my function it was named time. If you console.log('Time:' + time); you should see the value.
  23. Pictures of code don't help either of us. If you need to, you can paste your code into the forum here, or you can use a pastebin like the one on my site here: https://forum.gizmola.com/pastebin/
  24. You also did not see that I did not provide you the complete code for setting the 2 form element values. Prior to adding that code you first should console.log the values inside MyFunction so that you can test that the onclick is doing what you want it to do. <script type='text/javascript'> function MyFunction(col, time) { const tbl = document.getElementById("myTable"); let dateValue = tbl.rows[0].cells[col].innerHTML; console.log('dateValue: ' + dateValue); } </script>
  25. To be clear that refers to changes to the timeslots function. Put that back to the way it was in your original post.
×
×
  • 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.