Jump to content

philipolson

Members
  • Posts

    33
  • Joined

  • Last visited

    Never

Everything posted by philipolson

  1. But an INT is an INT, so I disagree that it's recommended or better here to use 'quotes' for it. intval() is a straight forward function. Life goes on, not a big deal, query works both ways, but I wanted to clarify.
  2. To be blatantly honest, your code is wrong on so many levels that it's difficult to know where to begin but perhaps some kind soul with more patience will respond. I suggest you lose most of this code and simply use intval(), so, replace .$id. with .intval($id). and in the meantime read up on how to define and use functions.
  3. If you fix your whitespace it'd be much MUCH easier to debug. An example of nice whitespace: <?php $foo = 'bar'; if ($foo === 'bar') { echo "Hello"; } else { if ($stuff) { echo "Hello"; } } See how easy that is to debug? Trust me, it's well well well worth it.
  4. A few notes: - You execute the query before the check, so really the use of isValidID() is useless here. - Change !empty to empty. - Since you use intval() it will pass the is_numeric() check 100% of the time - For INT, don't use '' in the query around it. - Feel free to place your function definition somewhere else, it can be defined after use
  5. On a only slightly related note, please don't use mysql_fetch_array() as it wastes energy. Either pass in the second parameter to it or more likely just use mysql_fetch_assoc().
  6. No, but you should start printing stuff to see what these variables contain.
  7. And assuming you do $id = $_GET['content_id'] above it then $id will ALWAYS be set so I think you mean empty() and not isset() here.
  8. Basically it's too much code to read and understand here. I suggest starting the debugging process by writing stuff like die("HELLO!"); in places so you know that part of the code executes, and when you see it does, move to somewhere else.
  9. Parse errors are ALWAYS syntax errors, and in this case you are missing a semicolon ( to end line 18.
  10. It's logic. foo() OR bar(); If foo() evaluates to false here then bar() will execute otherwise it will not. Read the following and do some tests too: http://php.net/manual/en/language.operators.logical.php And I prefer an if statement here, and not 'or' because it allows for a { block } to execute more than one statement. As for include_path, not sure, I was not aware of this behavior and always make sure '.' is in the include_path when wanting to include files from the cwd. I think that's a wise choice.
  11. Still you're making helping you difficult by not saying what line is what... like, what is line 15 and 16?
  12. Another problem is your code will never output "Wrong" because $message will be set 100% of the time (since you set it above) so I reckon you meant to use empty() or some other check there and not isset(). Or, isset() on the $_GET['message'] is fine too.
  13. As someone already stated, it's because you kill (exit) the script before it gets there... This has nothing to do with the header() call but rather exit; much like the following will never print "Hello World" <?php exit; echo "Hello World"; // I will never be printed
  14. You must set the MySQL configuration directive ft_min_word_len to something like 3 because it defaults to 4.
  15. Also, it's ?> and not php?> ... Also, 100% of the time a parse error is for invalid PHP syntax. Also, most of the time when PHP says an error is on a certain line the problem exists on the line before it (because it becomes a problem after)... anyway, so here PHP said line 39 and I reckon line 38 had the problem... the first one at least. Also, when posting a question, it's helpful to say which line is in the error... so in this case state which line is 39. Sorry I wrote "Also," so much here, I think it's getting late.
  16. Read about AJAX to make pretty little fancy "instant" thingees like this. Regardless, upon submit do the validation and if there are problems fill the form values with what they wrote, and tell them what they did wrong.
  17. Included by another site? If that's even possible then you have larger problems to worry about. Maybe I (or we) are misunderstanding the question?
  18. Your browser cache? Search your hard drive for words that were contained in the pages... *shrug* Lesson learned? ;]
  19. Too much code to read, but the concept is simple: <?php if (empty($_POST['Submit'])) { // Show form } else { // Process form } ?> So, put the form where it says "Show form"... does this make sense?
  20. Too much code to read, and you've not told this forum what the error is (or why you think it doesn't work).
  21. First, I've never seen anyone use the <script> syntax for PHP before (sure it exists, however, make life easier and don't use it) so I suggest using PHP tags (<?php ?>) instead. Second, your code is completely broken so I suggest you go find some beginning PHP tutorials and go through them before writing code. Sorry to be frank, and possibly you will not like this response, but it's clear you lack much understanding of PHP to begin writing such code because it's clear you cut-n-pasted a few snippets and hoped for the best... something we all did or tried to do early in our PHP careers! But trust me, it's not worth it. Third, when you start writing similar examples I suggest starting very very simply like a form that passes one value, then have another page that prints out that value, and from there expand your form.
  22. I've not read this entire thread, but quick glance shows broken code: <?php // Your code echo "<input name=\"antal[]\" type=\"text\" value=\""; $antal[$t]; echo "\" size=\"6\" />"; // Working code echo "<input name=\"antal[]\" type=\"text\" value=\""; echo $antal[$t]; echo "\" size=\"6\" />"; // Some preferred code (that works too) echo '<input name="antal[]" type="text" value="' . $antal[$t] . '" size="6" />'; ?> Also, one form of debugging is to look at your HTML ... so go look at your generated HTML (via your browser) and see if it looks like what you want. For example, it is likely showing an empty value here which will explain why PHP sees no values...
  23. This is too wordy for me to read, however, the problem sounds like a classic "string being treated as an array" problem... For example: <?php $notarray = 'abc'; echo $notarray[0]; // Prints 'a' ?>
×
×
  • 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.