Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. I'm confused. Is my code working now ? (with the change as suggested to a .php filename)
  2. you have four fields in your selection, but only 3 in your list(). I realize that list will work like that but it's still poor practice and should be giving you a notice error
  3. OK - try this. It's your code with some error checking and some re-arrangement to make it more readable. <?php error_reporting(E_ALL | E_STRICT | E_NOTICE); ini_set('display_errors', '1'); //MySQL Database Connect include 'sqlconnect.php'; $sql = mysqli_query($con,"SELECT title FROM aktiviteter"); // check query did not return an error if(!$sql) { trigger_error('DB Error: ' . mysql_error(), E_USER_ERROR); exit(); } $options = "<select name='aktivitet' id='aktivitet'>"; while ($row = mysqli_fetch_array($sql)) { // NOTE - ALL OF YOUR OPTIONS WILL HAVE THE EXACT SAME VALUE CLAUSE - N.G.!! $options .= "<option value='owner1'>" . $row['title'] . "</option>"; } $options .= "</select>"; // NOW begin sending html!!! ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> $options </body> </html>
  4. Perhaps it is the fact that you begin your class with a line of code instead of a method?
  5. Your code is hard to follow. But - if you turn on error checking you should get some help in finding your errors. ALWAYS TURN ON ERROR CHECKING DURING DEVELOPMENT. The first rule of developing in PHP.
  6. looks like you found your solution. good bye
  7. Where is this updated code? I don't see it in your post.
  8. As the message says you can't output anything before your graph package does its output. You are sending the html for your page prior to the graph package calls, so that is your problem. However I'm not entirely sure since line 21 is NOT doing anything so it is a bit confusing. When you said "here is line 21" are we seeing the VERY beginning of the currently running script or a part of the whole thing?
  9. Are you showing us history.php or is the code above from some other script?
  10. The message has a line number in it - that is your problem line. Find the # and identify the line and then show us in the code where it is.
  11. Which you could have found out rather quickly by reading about the 'bindvalue' statement in the MANUAL It is simply amazing how so many would-be programming types visit forums with questions that are so easily answered with a little research (aka, reading!) in the most appropriate place, namely, the manual.
  12. What you should really learn from this is to ALWAYS DO ERROR CHECKING whenever you do something (as I say) 'external'. A call to your db server (a query!) is external so you should always do some bit of code that will verify that what you 'think' happened actually Did happen. A simple check on the query result var and display of MySQL_error would have solved this before you even made your first post here. Glad you solved it.
  13. Well, you'll never LEARN by just copying someone else's bad code. The sooner you start READING up on php and WRITING your own code the SMARTER you'll be. Good luck in your endeavors - and on this course, they will definitely be endeavors.
  14. Why are you playing with classes and inheritance at this stage in your PHP development? You have so many problems and apparently don't recognize proper syntax yet. Just stick to writing some decent code and grow into classes later on, otherwise you will only be re-writing them again and again as you FINALLY begin to catch on. 1 - where is $db defined? 2 - you set your pdo to retrieve assoc arrays but then you try and retrieve the data with numeric indices. 3 - you fetch your entire result set and store it into an array to then pass that array on to some method. Why? Much smarter functions available to you but you haven't realized that yet. Read the manual on 'fetchall'
  15. So - have you added the error checking and added code to check the results of your query call? If you re-run your code with those two things you should definitely see some error messages to help you. At this point - you query is so simple that there must be something wrong like an invalid column name or table name.
  16. How about skipping the sprintf calls to build your query and just create the string you need? Nothing magic about sprintf and it just complicates things. Then - echo out the query statement before you run it so we can what has been built. Be sure you have error checking turned on in your php and ALWAYS check the result of the query call to be sure it ran.
  17. On what are you basing your conclusion that there are no results? The bare echo of the count?
  18. Do you have error checking turned on? Do you have some more code preceding this code? (Basically, where is the code creating $conn?)
  19. Since you are learning here's a sample of code that IMHO is a much better way to develop. It makes for easier reading and debugging and for fewer typos when trying to enter/exit php mode constantly. The idea is to separate html and js from php and let the php vars bring the dynamic parts of the output into the html after being built somewhere else. // always turn on error checking during devl. error_reporting(E_ALL | E_STRICT | E_NOTICE); ini_set('display_errors', '1'); // GET the position of a letter that is in // your own name $name = "John"; $letter1 = "h"; // the function strpos returns a value which you weren't retrieving. $pos1 = strpos($name, $letter1); if ($pos1 !== false) $msg1 = "The letter '$letter1' is at position ".($pos1 +1); // Check for a false value of a letter that is not // in your own name and print out an error message $letter2 = "K"; if (strpos($name,$letter2) === false) { $msg2 = "Sorry - no '$letter2' in '$name'."; } // Now use the assigned vars above in your html and avoid // having to mix php with html. // The PHP 'heredocs' operand (?) is great for outputting lots of html mixed with php vars. Check it out in the manual $code=<<<heredocs <html> <p> $msg1 </p> <p> $msg2 </p> </html> heredocs; echo $code; exit();
  20. Where IS the order by clause?
  21. That says that the post array is empty. Something is wrong with your submit - either the js validation routine is doing something to you, or the organization of the table and form tags has to be altered. I remember having some difficulties in the past when mingling those tags. Try removing the validation on your form tag and see if a plain old submit gives you anything in the post array
  22. Hmm..... Your error message says it is coming from 'contact.php' - is that the module you expect to be running at that time? I ask because your form has an invalid (?) action attribute. Did you define $PHP_SELF or did you mean to reference the PHP_SELF index of the $_SERVER array?
  23. ok - it appears that you 'should' have an item named 'Submit' in your post array. Do this - in the line before the error line add: print_r($_POST); exit(); and let's see what the post array actually contains.
×
×
  • 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.