Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. do{}while() loops are almost never used because they require extra code over using just a while(){} loop, because you must setup data before the start of the loop. In your code, where is $row being set at the first time through the loop? You should also be developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (so that fatal parse errors are displayed too) so that php will help you. You will save a ton of time. The uninitialized $row variables would have produced run time errors to alert you to the fact that they did not exist the first time through the loop.
  2. If your header() redirect is not working (i.e. you are actually seeing the output being sent to the browser after the redirect), you likely have content being output to the browser before the header() statement. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (so that fatal parse errors are displayed too) so that php will help you?
  3. Or you can just do this - Change your <form tag back to what it originally was - <form name="register" action="register.php" method="post"> Add a name="submit" attribute to your submit button. Change if(isset ($submit)){ to - if(isset ($_POST['submit'])){
  4. Muddy_Funster, just posting 'fixed' code without stating what you fixed in it or why you changed it usually does not help anyone. Also, $submit won't exist so the 'fixed' code will skip over all the form processing code anyway.
  5. $folder = "/"; A leading slash refers to the root of the current hard disk. I suspect that you want a ./ or even just a .
  6. The mysql password() function is not supposed to be used by user applications - And if you were using it, it requires 41 characters to store and it apparently does include a leading * -
  7. If $search contains some non-printing characters (\r, \n, or \0) a query executed through php won't match anything in your database but if you copy/paste the resulting echo of $query, it could match values in your database. Where is $_POST['search'] coming from and what do you get from the following - var_dump($_POST['search']);
  8. That's because inside of a double-quoted string \f and \xhh have special meaning. Because php under Windows converts / into \ before passing file paths to the operating system, you can just use /
  9. Just about every string in that code that contains either a php variable or contains another quote within the outer quoted string is wrong (take a look at the color highlighting that the forum software did.) A) php variables are only repalced by their value when they are contained within a string that starts/ends with double-quotes. B) Putting php variables inside double-quoted strings usually results in fewer syntax errors than using concatenate. C) Any quote within a string that is the same type of quote that started the string will close the string unless you escape it or use a different type of quote in the string than starts/ends the string. What does this thread have to do with the forum section you posted it in? It is php syntax errors in strings that are not being written correctly.
  10. If the error is near the second to the last line that was posted, those are not single-quotes. They are smart/curly quotes and are not php syntax friendly.
  11. static just means a variable is available between separate calls within one instance of a page.
  12. You do know that web servers are stateless? They don't know or care what happened on any page request before the current one or on any page request after the current one. All resources used on a page are destroyed at the end of the processing of that page request.
  13. Also, if you echo $sql, you will be able to see exactly what is in it (you are currently missing a closing ) that is part for the VALUES () term.)
  14. You should be developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (so that fatal parse errors will be displayed too) so that php will help you with things like mistyped variable names.
  15. You need to echo the $query to make sure it contains what you expect (using variables that are not named for the function they perform makes it difficult to write code that does what you want.) Your code does not have any error checking or error reporting logic in it to get it to tell you what it is or is not doing (for example, you should only echo that the information was updated if the query executed and the row was updated.) You code should be doing something like this - <?php if(mysql_query($query)){ // query executed without any errors if(mysql_affected_rows() > 0){ // one or more rows were updated echo "Information updated."; } else { // nothing was updated (either the data was identical or the WHERE clause did not match any rows) echo "Not updated."; } } else { // query failed, do some error reporting echo mysql_error(); } mysql_close($con); ?>
  16. When you put php array variables, i.e. $_POST['...'], inside of a double-quoted string, they must be enclosed in {} so that the php parser can find where they start and end. That will fix the php error message you are currently getting. Any string data that is put into an sql query statement must be enclosed in single-quotes so that sql will treat it as a string. If you are still getting a sql error, please post it as that will result in the quickest solution without a lot of guessing.
  17. You would need to 'remember' the last tab value and do some special processing when the tab value changes (you'll need to adapt the $result variable in the following to match what your query is producing) - <?php $content = "<div id=\"Accordion1\" class=\"Accordion\" tabindex=\"0\">\n"; $last_tab = NULL; // remember the last tab value (start with a value it will never be) while($row = mysql_fetch_assoc($result)){ if($last_tab != $row['tab']){ // the tab changed if($last_tab != NULL){ // it was not the first tab, close the previous tab $content .="\t</div>\n"; } $last_tab = $row['tab']; // remember the new tab value // start a new tab $content .="\t<div class=\"AccordionPanel\">\n"; $content .= "\t\t<div class=\"AccordionPanelTab\">{$row['tab']}</div>\n"; } // output each label $content .= "\t\t<div class=\"AccordionPanelContent\">{$row['label']}</div>\n"; } // close the last tab $content .= "\t</div>\n</div>\n"; echo $content; ?>
  18. LOL, I was just about to post the same thing (if you test your code with full error_reporting/display_errors it will give you a clue about what is happening because the variable variable that was created "_POST", does not exist.) You would want to pass ANY data that the class operates on into the class as a parameter anyway to make the code general purpose, which will solve the $_POST problem at the same time (untested.) edit: (just tested.)
  19. There are no php.ini settings that directly affect what you are trying. Perhaps if you posted enough of your code that is producing the $_POST data and using the class so that someone could duplicate the problem?
  20. mysql_query() ? I don't see one in your code.
  21. You did not exactly state what part of this you need help with. Assuming you just need the query and can work out how to produce the correct output and that you only want to show tabs that have content under them, this query will work - $query = "SELECT t1.menu AS tab, t2.menu AS label FROM your_table AS t1 INNER JOIN your_table AS t2 ON t2.parent_menu_id = t1.menu_id ORDER BY tab, label";
  22. The $_POST array is a perfectly usable array variable. By making a series of named variables from it, you must now keep track of each of those variable names and write out code to reference each one (or use more variable variables to access them.) That does not make for general purpose coding (using an OOP class) or efficient coding. Just use the elements in the $_POST array directly without going through an additional intermediate step of creating named variables (this will save processing time and memory as well.) Variable variables take three times longer to access than accessing an array variable. Are you sure you want to use variable variables?
  23. The error message obviously changed to indicate that there was output occurring at a different point in your code. If you didn't notice that the error message was different, we cannot help you. You already have an ob_start(); in the code you posted. It is after you have output something on the page, so it is not doing any good, but taking up extra processing time and memory. Adding a second ob_start(), while it does hide the cause of the error, adds even more overhead on the page (you have two nested levels of output buffering now.) It is always best to find and fix problems, rather than to hide them.
  24. There ARE in the code you posted and I just copy/pasted into a file to test.
  25. Remove any characters in the file that are after the ?> tag.
×
×
  • 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.