Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,356
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. 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.
  2. 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.
  3. 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.
  4. @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.
  5. posting a sql dump of just your table definition, would help someone to recreate/debug the problem.
  6. it's likely that your new-lines in the csv file doesn't match $lineseparator = "\n"; where/how is the csv being produced and are you editing it at any point, where your editor could be modifying the new-lines?
  7. have you ever successfully sent an email from the server where this is running? does your web host have any smtp authentication or other requirements to send email? there may be a mail server that accepted the email from the php mail() function and didn't return an error to php, but that mail server may not have any intention, or ability, of actually sending the email to the recipient or it may not even be the correct mail server to use at your web hosting. it's also possible that the dns records where the domain in your From: address is hosted at are either nonexistent or miss-configured such that the receiving mail server cannot determine if the sending mail server is authorized to send the email, in which case the receiving mail server may simply discard the email. is the From: address an actual working mail box, so that any bounce/error messages from the receiving mail server would have a place to go and can be viewed? and while the From: address should get used as the Return-path: address for bounce messages, you can specifically include a Return-path: in the header. edit: also, which email address are you not receiving at, the To: address that you are entering in the form (and have you confirmed that the form is posting a value to the code), or the Bcc: address that's in your code or both?
  8. that's not correct jazzman. the posted code is escaping/casting each data value as it is building the string being put into each array element. each array element is one complete value section of the query - (1, 'a string', 2.34) (with the surrounding ()). the implode is just combining all the array elements into the VALUES section of a multi-value insert query. any escaped data in the array elements will still be escaped in the resulting sql statement. you cannot escape any of that afterwards since that would change the quotes that are part of the sql syntax. if there was a string data value - this contains a ' in it, the posted code will produce - (1, 'this contains a \' in it' ,2.34) your suggestion to apply the escape function after or as part of the implode would produce - (1, \'this contains a \' in it\', 2.34), which is not correct. the posted code produces the following actual sql query statement for some test data - INSERT INTO order_line_items (order_id, company_id, item, unit, unit_cost, quantity, tax, total) VALUES (0, 0, '123', 'this contains a \' in it', 0.00, 1, 1.00, 2.22), (0, 0, '456', 'this contains a \' in it', 0.00, 2, 2.00, 4.44) the only problem with the posted code, outside of any typo's, may be that the $item value is likely an id, not a string.
  9. $_SERVER["REQUEST_URI"] contains the path/file and also includes the url query string.
  10. this is the same error you had in your first thread on this forum. are you learning from your experience so that you don't repeat the same problems? you also used the mysqli database functions in your second thread on this forum. why now go backwards using the msyql functions?
  11. that would be two separate queries or a carefully crafted UNION of two LEFT JOIN queries.
  12. the while(){} loop in your code is - a) incomplete, it is only echoing the first line. you should always use opening and closing { } in conditional statements. b) it's unlikely that you have a column named value1, value2.. if your purpose is to loop over any/all columns that the query selected, you would do just that. $row is an array. use a foreach(){} loop to loop over and echo each element in the array.
  13. programming is an exact science. the values you are producing in your <option > tags are not just the table name, they contain html <br> tags as part of the value. when you echo <br> tags to a browser what do you see? white-space, specifically a new-line. people with thousands of posts and years of experience wouldn't have told you that the form has a problem if it didn't.
  14. we can only help you if we know what errors you are getting and what the corresponding code is.
  15. and please use the forum's bbcode tags (the edit form's <> button) around code when posting it in the forum.
  16. if the relationship is between jobs and quotes and jobs and messages and there is no relationship between quotes and messages, then you actually need two queries (unless the columns you want to retrieve from quotes and messages happen to correspond exactly so that you could use a UNION query.)
  17. the error message contains the database name and the table name to give you as much information about the problem as possible. that the database name is part of the error message is not the problem. the problem is you are supplying a table name that either doesn't exist or has some white-space as part of it or has a capitalization problem (and you are on an operating system that is case-sensitive.) that you are not posting actual information makes it hard to help you, especially since you don't understand the information you are seeing in front of you. i recommend that you post the code producing your form, since you likely have a problem in the code that's providing the value that's being submitted.
  18. if there are no messages or no quotes, your straight JOIN won't return any result. to always get the job information, you would use a LEFT JOIN between the jobs table and the other tables. you are also joining quotes to messages. what your query is doing - jobs have messages, messages have quotes. is that the correct relationship? what jazzman is suggesting is to only write out code for things that are different. that part of the query that's the same should only exist once in your code. the only conditional logic should be the part that building the WHERE clause. this will reduce that amount of clutter and make it easier to see what your code is actually doing. next, having just the necessary code, so that you can see what your code is actually doing, would perhaps let you see that you are using mysql_error() on the end of a php string assignment statement, where it won't do any good, and that you are not actually running the sql query you are building.
  19. the purpose of your javascript code is to add up and display the total price of the selected items. in order to do this, you must first have the price of the selected item(s). have you considered what information the user is presented with? he would want to see the prices displayed next to each possible choice as that would influence his selection. unless the use of ajax to retrieve the price was part of your assignment, there's no need to get the price on demand, you should already have the price for everything being listed when you (dynamically, using php code) build the radio-button choices by retrieving the information from your database table.
  20. first of all, there no code in your code to produce a total or even an element to display the total. where's your attempt at doing this? your code should be general purpose, with the fields you want to total up having a specific class name. you can then simply call a javascript function when any of the data changes, to total up the values of the fields having that class name and display the total in another field. using a javascript library like jquery would make this a simple task and you can probably search the web and find numerous examples.
  21. i think you misunderstand what programming help forums are for. they are for asking programming related questions and getting help with problems and errors in code you have. just stating you want to change how code works, isn't a question and isn't a programming problem or an error. if you haven't attempted to make the changes you have described, you don't have any code that we can help you with and we are not here to make changes to code for you. do you have a specific question about how to do what you want or a problem or error you had in your code when you tried to do this?
  22. as to merging the code. in general, your application/web-site should have only ONE database. the two tables you have appear to be for different categories/quantities of items. you should only have one items table that holds the information for all your items/products. and in fact, your file names and functions names (in the javascript) shouldn't be specific to the type of information that's being displayed. it's all just item/product information. as to your sub-total question, that's a javascript coding question and should be posted separately in the javascript forum section.
  23. the error you are getting is very common. see the following link for what it means and how to find what's causing it - http://forums.phpfreaks.com/topic/273121-readme-php-resources-faqs/?do=findComment&comment=1428660
  24. the most likely cause of the symptom is because the following line - $_SESSION["products"] = $product; is inside the foreach(){} loop and is adding elements to the array that the loop is iterating over.
  25. i have a recommendation that will greatly reduce the amount of code. use the item id/code as the array index. this will mean that you can directly test for or access the element in the array. you should also only store the quantity in the cart. the rest of the information is redundant and if you ever allow the chrname or initmod values to be edited or you add more columns of data, you will end up with out of sync data.
×
×
  • 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.