Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. What do you mean by 'doesn't work'? There's nothing wrong with the statements, altho the else echo seems odd with those closing html tags embedded. do you have error checking turned on?
  2. Post (Properly please!) the code that is the form and then the code that processes the form values and creates the query to insert them. Be sure that you show the part where you turn on php error checking.
  3. Why don't you test them before you start manipulating them? Actually - they will be "set" when you assign those POST vars to them, or else you would get an error/notice that the post vars are not set. So what you really want to test is the POST vars for being set and for being <> blank
  4. To elaborate on Barand's offering: In your loop you need to build an html table row only once for every 3 times thru the loop. So you conduct the test he gave you and if it equals zero, you output the start row tag (after first checking if you have a row already started) and then output the td tag with that occurrence of data. Then you increment the rowcount var and loop again. This time the test will fail, so you only output the td tag. Play with it and you'll figure out the little things as you do
  5. Part of being a good programmer is learning how to test your own code. I doubt that you are writing such a complex script at this stage that you really need to automate your testing process. Simply look at your code and analyze how many paths it can take and try and use your script in ways that will test all those paths and be sure your script is handling them properly.
  6. So - since you aren't showing us the messages, did you fix all the errors? Be sure to check the resuls of your query call and output the MySQL_error code if there is one.
  7. Because you tested for a match instead of a break first. Follow my example (with the additional output at the end that was pointed out) And WHY DID you double post this problem?
  8. Are you getting any errors? (ie, do you have php error checking on?)
  9. When one posts code and says the menu is empty the IMPLIED statement is that one has actually run that code. Otherwise why offer it for display and say that results were bad? Glad to have helped tho.
  10. You seem to be rusty on html as well. Your input tags have no value= clause. PS - imho - shorter var names are better. Who needs to be typing 10 or 20 char var names again and again? Too prone to error. Plus - as a newbie you would be smart to turn on php error checking - it will come in handy when you do misspell one of the var names.
  11. Order the query by that field and then in your processing loop add a field to retain the last value of that field. At the beginning of the loop, check if the new record has the same value, and if so accumulate your data in an 'output' var for the email. Once the new record doesn't match, do your email, re-init the output var and then continue on and process the record that started the new value and keep on going. Pseudo code: lastvalue='xxx'; while(loop logic) { if newvalue <> lastvalue and lastvalue <> 'xxx { call your output function that sends email with accumulated data in vars } process new record by taking new data and accumulating into vars lastvalue = newvalue } Hope this makes sense.
  12. Once again - are you one of those re-typers who post fake code that they "say" is what they ran but really isn't? Please - only post ACTUAL code that ACTUALLY ran so that we don't all waste our time solving the wrong problem. Your open php tag is not an open php tag, so nothing is happening in that loop. Plus - it makes for easier typing, easier reading when you don't choose to go in and out of php mode like you are doing. Just used php and echo the entire piece of code instead of only the php var. <?php echo '<select name="quantity">'; echo "<option value='$quantity'>Maximum of $quantity available</option>"; for ($q=1; $q<=$quantity; $q++) { echo "<option value='$q'>$q</option>"; } echo '</select>';
  13. Php gets input data from a form via the 'name=' attribute of an input element. So - if you want to post that data being typed into the textarea tag you need to look for THAT element's name in the POST array. That would be $_POST['main'] since that is what you named it. As for the query statement. Read the manual on mysqli prepared queries. Then you can build a safe query to do your database updates. I don't use mysqli myself so I can't help you. PDO, yes. Mysqli - no. PS - once you get this piece built how do you plan on the users retrieving specific text entries from your database. You have no identifying criteria in a one-field table. Perhaps you want to think about your database design and add some fields. Maybe add a date added, a date modified, a username or id, a 'type' field to perhaps separate different types of entries from each other. Then a specific user can sign on with their uid and provide a date or a type and query the table for entries they have made that match. Sound like a plan?
  14. If you turn on php error checking you may see some errors. Additionally you should be using prepared queries and not such an unsafe query that you are using with that post var being plugged in. Incorrectly as well. As for you code - you are trying to update a table with the value of a form field named 'header'. Perhaps you gave me the wrong code again? I don't see a form field with that name. That said - I have to wonder what you are doing here. You have one big giant meaningless paragraph of text that you are storing into an unkeyed table. Whatever for? PS - when referencing an array element you should ALWAYS quote the index.
  15. Actually I don't see what you are doing. 1 - show me the script that contains the form and the fields involved in it 2 - show me the php code that grabs the form's inputs and what you have attempted to do to save them in a db table. Please name the blocks of code with actual script names so I can be sure of what I am looking at. I am trying to approach this very slowly in order to help you understand what should be happening. If you don't want to do it that way, I'll move on .
  16. Let's start slowly. Post the script that creates your form and process the entries made on it. Let's just focus on that part of your project.
  17. Be sure that the data on the screen is wiped off upon completion? Or as was suggested on another forum have a random token buried in your form and save it to a session var when you first save the data. If that token then matches the session var you have already posted this data.
  18. your postings make no sense. How about 1 - turn on php error checking 2 - stop opening and closing php mode. 3 - put together some code that shows the entire problem, not 3 pieces that we don't know how to put together.. Be sure to show us the form code and point out to us which is line 26
  19. pdo is a better choice. At least that's what most people say here. I find it pretty easy to use. Just make sure you read Jacques1 writeup on how to use it properly and how to make your standard connection logic do it correctly.
  20. What does "it says this ) here" mean? The message is telling you the file and line number. Show us that. More importantly the line number is a good hint of where to look. If it is the end of the named file, then you are definitely missing a curly brace. Walk thru your code looking to see that they are all paired up. If you are using a good ide that highlights your code it s/b easy to locate the unmatched brace; otherwise it's a pia but a necessary part of debugging.
  21. If you switched to either mysqlI or pdo you would be able to fix the problem of unescaped input (contining quote marks) by using prepared queries. You really need to read up on the dangers of running queries against your db with unsanitized inputs - probably from malicious users!
  22. And while you are changing things, you really should change your db interface to be mysqlI or PDO instead of the DEPRECATED MYSQL
  23. Your definition terms are confusing. You want to get "a contact form" (html?) into a "header" (a PHP include module perhaps?) ? Uhhh... Could you be a little more specific in your description so that we can at least understand what you are trying to do?
  24. Why do you use php tags for every statement? Rather silly. Turn it on. Turn if off. Turn it on. Turn if off. Talk about code bloat! Turn on error checking (see my signature). Add checks of your query calls to ensure that they ran.
  25. Why do you check if a function exists that you are only going to create? Are you duplicating some already installed function name? As for your real problem - you do a connect using mysqli but then you try and use MySQL functions which are deprecated.
×
×
  • 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.