Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,369
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. 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.
  2. 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.
  3. 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.
  4. 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?
  5. 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.
  6. 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
  7. 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.
  8. 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.
  9. you would write a SELECT query to retrieve the password field, FROM the correct table, WHERE the username is equal to = the posted username, applying either your database library's string escape function to the posted username or using a prepared query, to prevent errors or to prevent sql injection. if that's a little less than you expected, it's because what you are asking, form and run a query that retrieves a specific column from a specific row in a database table, is a basic skill that you need to learn first, before you can attempt to do it for your data.
  10. the array that the database retrieval code is storing the results into is $products. if 1077 is the index value that corresponds to your SMX 800E example, you would use echo $products['1077']; this is why copy/pasting code is not learning. the code that gets posted is only an example to look at, and in just about every case is untested, and can contain syntax errors, hastily typed variable names, logical errors...
  11. @asif456, this is why programming help forums are not here to find or to give you programming related things you want or need. we don't know exactly what you are looking for, nor do we know your level of experience and understanding. programming help forums are for helping programmers with code they have written. topic locked.
  12. but, to get the prices from a database table and list them for all the products on the page, YOU WILL BE CHANGING THE ENTIRE PAGE. you might as well dynamically produce the page and save the time it would take you to add php code in 40+ places on the page.
  13. the http response for the download request must only consist of the header statements and the content of the file you want to download. what you are seeing in the downloaded file is the content of the file and the html that's being output on your success.php page, making the file invalid.
  14. in your download.php code, you would also need to verify that the requested file belongs to the logged in user.
  15. in your code, $results will be an array, not an object. if you use echo '<pre>',print_r($results,true),</pre>;, you can see what the structure of the array is.
  16. it would be up to you to find code examples at your level of understanding. all a blog is, are - forms, form processing code (that stores submitted data in appropriate database tables), navigation/search/sort code to list or limit entries and pick display order, and code to retrieve/display the correct contents from those database tables in the correct order. you would also need a log-in system with access permissions, to control who can access the forms and the form processing code, a lot of validation and security to prevent nefarious visitors from doing things they shouldn't or to tell legitimate visitors what was wrong with what they did so that they can correct it, and error checking logic on everything so that your code will let the visitor know when the site isn't going to produce any result and to log (or display during development) all the information about each error so that you can find and fix problems.
  17. so, you used a site/form creator that includes ads as part of its terms of use and you are trying to fix your site that broke when you attempted to get rid of the ads? it's not the purpose of programming help forums to help you bypass or disable features of software that you agreed to when you used that software. topic locked.
  18. there's no limit to the number of terms you can have. as pointed out, you likely had a typo and as also pointed out, you don't (ever) need to write out a statement that has that many terms in it.
  19. the particular message occurs when your massive isset(...) && isset(...) statement is false. the purpose of that statement is (should be) to test if a form was submitted. it doesn't need to test if every field is set, because all text/password/textarea fields will be set. so, just test if one field isset(), such as a hidden field that identifies that your registration form was submitted, which is what the $_POST['reg'] appears to be for. next, DRY (Don't Repeat Yourself.) You have a ton of code repeating the inclusion of the header/footer files. You should only have those ONCE. lastly, you should validate all the inputs at once and output all the errors at once so that the visitor doesn't need to repeatedly submit the form to find out each error in turn. your elseif() logic validating different fields should be completely separate conditional tests. to accomplish validating all the inputs at once, you would make an array to hold the error messages and then simply test if the array is empty at the end of all the validation. if it is empty, no errors. if is not empty, loop over the elements in the array and echo them to display the error messages.
  20. the answer to your question of can you use the logged in username (you should actually use the user's id, an auto increment column in your user table that corresponds to the user name, since this will be much faster than using a text string in queries. this is the id that trq mentioned in the first reply in this thread) as a filter in a query is yes, but this does require that you understand some basics about php, such as php variables, and to understand something about the code you are using, so that you know at what point in that code a variable exists. if your login script, which i am assuming is accessed via the session.php file, makes $login_session available, then you can only use $login_session after the point where you have included session.php. you have mentioned 'in dreamweaver' a couple of times. you do know that dreamweaver is just a tool, and a poor one when it comes to server-side php code. you should not be relying on a tool to do your work for you. a tool is something that you use to accomplish a goal.
  21. post the error message you are getting and post an example of an input data value causes the error.
  22. the reason for the error on the mysqli_fetch_all() is because it's another one of php's screw-ups that is only present in a specific case that you won't generally have any control over.
  23. are you 100% sure that the fetched array contains this 'missing' row? there are two possibilities - 1) you query is not matching that row, possibly because the where clause is false 2) your php code, doing things like testing for empty() values is skipping the display of that row, because an element of that row or of the join with the contact information resulted in empty or null values. if that row is in your fetched array, what does using var_dump() on that one row show?
  24. the syntax error is because your source code contains an error. you are using the Ternary operator on the line where the error is being reported. the Ternary operator doesn't use an if(). next, the best, general purpose method to use to highlight/change words in text, based on database entries would be - 1) get a unique list of words from all the content you are going to display on the page. this would require that you retrieve the rows from your pagination query. if you store these rows into an array, you can simply loop over this array later when displaying the information. as you are retrieving the rows from the pagination query, split them on the white-space/word boundaries and add all the words to an array. then use array_unique() to reduce this array to just the unique list of words. 2) using the unique list of words from step #1, run a query against your banned word table to get just the entries from that table that are found in the unique list of words from the content. you can implode the unique list of words and use WHERE word IN('word1','word2','word3', ...) comparison in the query. 3) retrieve the list of matching bad words into an array, then when you have the full list, implode that array using a | character. this makes a regular expression OR'ed pattern of all the found bad words. 4) as you loop through the content (the first array from step #1) to display it, you can use a preg_replace() statement, with the regular expression pattern from step #3, to find and replace any bad words with the replacement string.
  25. ^^^ except that the stated age of something depends on if the birthday has or has not occurred yet in the current year. the age is the difference in years, subtract one if the month and day are less than the current month and day.
×
×
  • 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.