Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,352
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. if php's output_buffing is on prior to any output being produced, the output is buffered instead of being sent to the browser and header() statements will function. php's output buffering can be turned on in the php.ini on your system. this is not the ideal situation, as it hides things like php error messages and messages your application intentionally displays, and results in code that is not portable between systems. it's always best to NOT rely on any sort of setting like output_buffing when developing code so that your code is properly structured and will work on the largest number of systems.
  2. some/most of points that were made in one of your earlier threads were to reduce the amount of code you are writing to accomplish any task. it's likely that your giant isset() statement contains a typo and that whole block of code is being skipped over. to repeat one of the recommendations previously given, to detect if your form has been submitted, you only need to test one of the fields you know will always exist in the form using an isset() statement. because isset() won't produce any php errors when you have made a typo in an variable name, php won't help you find mis-typed variables in your current code. edit: and i just proof-read your code and you do have a typo in one of the variables in the isset() statement. i'll let you find it (hint: a programming editor with a spell checker would be of some use.) PLEASE make use of the recommendations made. they will reduce the amount of code needed, which in turn reduces the chance of errors, makes it easier to write your code because you don't have to spend as much time copy/pasting/updating things, makes it easier to see what your code actually is and makes it easier to debug your code.
  3. you have to present the data in a meaningful form (no pun intended) in the client/browser, so, there needs to be some structure. however, what you have shown in this thread is a basic CRUD (Create, Read, Update, Delete) application. this can be coded general purpose, where all you do is define what database table(s) you want, what fields to include/exclude, and everything else can be handled by the code, using array variables/array functions, without writing out specific code for each field name. here's one such application that i know of - http://www.phpmyedit.org/
  4. the msyql_connect() statement you posted is incorrect. the 4th parameter is NOT the database name. it's a flag the controls if a new connection is made if an existing connection with the same credentials already exists. however, you should not be using mysql_ functions as they are depreciated, should not be used for new code, and will be removed in a future version of php. you should be using either the msyqli_ or PDO database library functions. if you were using mysqli_connect(), the 4th parameter is the database name and your code would then be closer to running. does your development system you have php's error_reporting set to E_ALL and display_errors set to ON so that php would report and display all the errors it detects? you also need to test if queries work or not. for development you would display any query errors, on the live server you would log any database errors. lastly, the posted php code has no security to limit who can post data to it and no protection against sql injection. it's not even testing if a form was submitted before trying to use the $_POST form data values. all of these things are needed if this is more than just a classroom assignment for learning purposes that won't ever be on a live server.
  5. assuming you have or have written a database based pagination script, it is doing two things. 1) getting a total count of the number of data items, and 2) retrieving the correct 'page' of data to display. to accomplish pagination for an array of data, you would first get all your data into an array, in the order that you want the data. then, to accomplish item #1, you would use count() on the array of data. to accomplish item #2, you would use array_slice() on the array of data, using the offset and length (number of rows per page) values normally going into the LIMIT clause in a database query as the parameters going into the array_slice() statement. you would then loop over the array of data that the array_slice() statement returned to produce the output on the page. to get your array of data ordered the way you want, you can either use php's usort() or array_multisort() statements. examples of using these are in the php.net documentation and posted all over the web.
  6. the best method would be to put the information into an array, then use array_slice() to reference a specific 'page' of that information. the array_slice() offset and length parameters function exactly the same as a LIMIT clause in a mysql based pagination query.
  7. jazzman, you and the OP are both connecting using ISP's in Toronto. i think the OP intendeds to insert one row of data for each player, per event/match, with the point result for that event/match (or whatever the granularity of the information is for.) if this is the case, there's no 'on duplicate update ...' part needed.
  8. does the 'view source' of the html have the expected values for the id='...' attributes? edit: am also fairly certain that when pdo is doing emulated prepared queries (the unfortunate default), that bind statements don't return or throw any database/data releated errors.
  9. i think you misunderstand what programming help is, especially if you have received the same response on other programming help forums. we are here to help programmers with their code, hopefully code that they have written, or if they have found it or been given it, that they know enough about the programming language it is using so that they understand what it is doing and can even make an attempt at solving their programming problems or would understand any code given in a reply. a programming help forum should not be your first line of help, it is the last, after you have exhausted all the means available to you. if you have no programming means available to you and you are turning to programming help forums as your first line of help, without having or posting the result of your coding attempt, along with any relevant errors or symptoms, you don't have anything that we can help you with. you are instead asking someone to do it for you, which when it comes to the task of even looking into what is needed to integrate a payment gateway with your existing site, is more than what you should expect to get for free. so yes, someone taking the time to find out what your site database and coding structure is, what the payment gateways return as data, and integrating the gateway into your site, would help you, but that's not what programming help is. programming help means you are doing 99% of the work and we are just providing direction. in order to provide you with any direction, you must be at the point of asking specific questions or have specific errors or symptoms that you need help with. short-answer: you want something, you don't have the knowledge, skills, or experience to do the work yourself. that is the test for when you should hire someone to do the work for you, especially if the task involves actual money and products. re: your drawing example. i recall some lady making an attempt at touching up an expensive painting within the past year, and it came out looking like a kindergartner did it with finger paints. the work required someone with the correct knowledge and experience, not just someone with a brush and some paint.
  10. scientific notation is just another way of representing a floating point value. to get the output formatted the way you want - $answer = sprintf('%.11F',1/212500); @Richard_Grant, the large image in your signature is in violation of the forum's rules. i suggest you remove it or make it much smaller before you receive warning for it.
  11. in your previous thread, it was suggested to use mysqli_error($con) to display query errors. what worked before, can work again. you would be getting a query error at or right after the $tablename portion of the query because you are using a non-existent $_POST variable to provide the value for the $tablename variable. you would also be getting a php undefined index error where you referenced that non-existent $_POST variable.
  12. also, putting php settings into a .htaccess file only works when php is running as an apache module, which is uncommon on shared web hosting. so doing it the way you are trying would limit your framework to just apache servers and to just a fraction of those that have php running as a server module.
  13. a) change the short-opening php tag <? to a full <?php tag. the short one is not portable between server settings and was a waste of time just to save typing three characters. b) ALL of the program variables, based on form data or server data, don't exist. you will instead need to use the $_POST and $_SERVER variables to access them. setting php's error_reporting to E_ALL and display_errors to ON will help you find these since they will all produce undefined variable error messages. c) if you review the php.net documentation appendixes, there are migration sections that describe what has changed over time in php.
  14. in actuality, once you have the necessary database tables set up, the only thing you need to do differently in any cart code to accomplish what i suggested is to change the queries that operate on the data. the following is a little different from what i described above (which is why you should work out the details yourself, rather than follow along with what someone quickly writes out in a post somewhere on the web.) instead of having a query that updates a row to subtract the quantity in your products table, you would instead insert a new row into a different table (such as a cart/order_details table), with the item id and the quantity that was ordered (if you store the cart in a database table, instead of a session, this step isn't needed since the item id/quantity would already be in a database table.) any query that needs to get the current quantity, instead of reading the row(s) from your products table, would take the quantity on hand and subtract the SUM() of the quantity from this new table. if you do an advanced search on the forum for 'cart' and my user name, you should find a lot previously written information about this. in fact, see the second half of the post at the following link -- http://forums.phpfreaks.com/topic/286051-php-shopping-cart-and-quantity-help/?hl=%2Bcart&do=findComment&comment=1468275 and i added the forum's bbcode tags around your posted code above, as that may have been a reason no one bothered to look at the code to offer any specific help with it.
  15. prepared queries aren't just about security. $variable = "Mc'Gyver"; results in broken sql syntax and an error.
  16. the main point of using a prepared query is to bind data into the syntax of the query. the syntax of the query, less the data, is what is being prepared. the data values are actually supplied and inserted when the query is ran, so that there's no possibility of sql injection. by putting a variable holding raw data into the sql query statement, you have side-stepped the process, and allowed sql injection. @deathbeam, putting a variable directly into the query being prepared, in itself, doesn't cause any type of error. in the php context, the sql statement is only a php string that is being built.
  17. sorry for this, but we are not here to find or to give you things you need or want, because we don't know the requirements of your assignment or what your skill level is. that's NOT a suggestion to post your requirements. the only person here who can find what you are looking for is you. we can help you with specific questions you have once you have attempted to do this and have actual code and symptoms or errors you can post or if you have a specific question about how to do some part, again after you have attempted to figure it out first.
  18. the code is doing exactly what it was written to do. if you want it to produce different specific data, you will have to write the query and code that does what you want. if you want to graph one bar for each/any month, with the total for that month, you will have to produce data that does that. [month name,total for that month],[another month name, total for that month], ... you should do this in the query, like the example that Psycho posted (modified for a total and $type you are actually doing), which if you are going to do this in general for any range of dates, would be the best place. to get the month name, you would either convert the 9 to the name in your php code or you can use the mysql MONTHNAME() function in the query. edit: in addition to what others have mentioned, i recommend that you use table alias names in your query to reduce the clutter and make it easier to read and easier to write in the first place.
  19. just because an update query runs without any errors, doesn't mean that it actually updated the row, if the WHERE clause if false. you should also be testing if the number of rows updated is greater then zero. to debug the problem of why the update query isn't updating the data, have you echoed the $query variable so that you know it contains what you expect?
  20. see the sticky/pinned post for this forum - http://forums.phpfreaks.com/topic/150979-this-board-is-not-a-code-repository/ php help forums are not for finding or giving you code that you want or need. we are here for helping with actual code problems. topic locked.
  21. you are also going to need to ask specific question(s). just posting a list of requirements, isn't asking a question, but it is a fine start at a request for quote to hire and pay someone to do this for you. we are here to answer specific questions that you have, after you have made an attempt at solving your programming problem.
  22. one of the most likely reasons for session variables not working when redirecting all over the place is that the redirects are switching back and forth between having and not having the www. on the url, because by default, a session will only match the variation of the url where it was set.
  23. given that you are using the DISTINCT keyword, i doubt there are exact duplicate rows. i suspect you mean that the job information exists in each set of rows for any job_id. if that's the case, that's how joined queries work. if that's not the case, you would need to post the result you are getting. however, that query is not what was suggested. you either need to separate queries, one for jobs and messages and the second for jobs and quotes OR if as has already been stated, if the columns you are selecting for messages and quotes are similar in meaning (because the UNION query will use the column names from the first query in the UNION), you can write one query that combines these two queries as a UNION query.
  24. the short answer is to treat your inventory as a deposit/debit account, where you have a row for each transaction. each row contains all the who, what, when, where, and why information about the transaction. when inventory is added (including the initial quantity), you insert a row with a positive quantity (deposit). when inventory is added to a 'cart' and the person go to the checkout stage, you would you add a row to the database table for each item in the cart, listing a negative quantity (debit), but with a status value that indicates is has been 'ordered'. when the item is actually pulled and shipped, the status for each item would be changed to 'shipped'. to get the current quantity of any item(s), you would simply run a query that sums up the positive and negative quantities for each item id/item number.
  25. @Richard_Grant, is_int and is_string test the type of a variable, not what's in a variable, and by definition all $_POST data are string variables, no matter what's in them.
×
×
  • 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.