Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Php labels (class names, function names/class methods, and variables/class properties) may not contain spaces or dashes.
  2. Don't use php's lazy-way short open tags <?. They are not always enabled and you won't always be on a server where you will have the ability to enable them. All the short-cuts php put into the language waste more time then they ever saved. The full opening <?php tag will always work and should always be used.
  3. What do you get when you do a 'view source' of the page in your browser?
  4. The output on your site abruptly stops after it outputs that re-check database image/link. There is probably a fatal runtime error. For debugging purposes, add the following two lines of code immediately after the first opening <?php tag in the index.php file in the setup folder (and hope that the pog code does not turn off the two settings) - ini_set("display_errors", "1"); error_reporting(-1);
  5. If you want to mass update any number of data values (one overall form with one submit button), you can either carry the existing values in hidden fields or in a session array variable, or you can query for the all the current values in the form processing code. Alternatively, you can update each value as you change it (one form and one submit button for each value.)
  6. Line 4 is the for() statement. You are missing the $ in front of one of the i variable names.
  7. The php code in the file you are including must be valid php code, with any opening and closing php tags (you can include anything, like HTML, and php must be told where the php code starts and ends in every file.) Also, use .php for the extension of the file. It does not matter in this case, but if you start putting database connection credentials in an included file, if the file extension is not .php, someone can browse to the file and get the raw database connection credentials.
  8. ^^^ You should not use the mysql PASSWORD() function in your application (there's a note to that effect in the mysql documentation for the PASSWORD() function.) You should also remove the @ in front of the @mysql_fetch_object($r) statement. If you are getting an error at the fetch statement, because the query failed due to an error of some kind, you would want to know that and then troubleshoot why the query is failing.
  9. Also post the table definition(s) and indicate the approximate number of rows in each table.
  10. The post that smerny made shows using a while(){} loop.
  11. do{}while() loops are almost never used because they require extra logic (which you don't have in your code) to set up the data before the start of the loop. For looping over database query results, where you don't expect exactly one row, you should always use a while(){} loop.
  12. Why do you think you would be UPDATING 100's of rows. That would imply that 100's of pieces of original data were entered incorrectly or that you are simply looping over all the submitted form fields instead of just the ones that were changed.
  13. That error means that your query failed due to an error of some kind (no database connection, permission problem, wrong table/column names, un-escaped data that breaks the sql syntax/allows sql injection,...) If you use mysql_error(), php/mysql will tell you why it failed. You can temporarily change your mysql_query() statement to the following to get some debugging information from it - $query = mysql_query("SELECT * FROM news WHERE `ref` = '$last'") or die('Query failed: ' . mysql_error());
  14. A) What does a phpinfo statement show for register_globals? B) How do you know the code with the die() statements didn't reach one of the die() statements? What was the output on the page and what was the 'view source' of the page in your browser? How do you know for a fact it is that specific mail() statement that is being executed? There's nothing in the posted code that indicates what any of the mail() parameters are being set to. The code you did post might be skipped over and you have another mail() statement in some code that is being executed that is actually sending you the email. C) If A) or B) don't expose what is causing the problem, you will need to post ALL the code (less any database credentials) that reproduces the problem on your problematic page in question. You could be doing things like header() redirects to the same page without stopping execution on the page after the header statement or using/having output buffering turned on that is hiding what is actually occurring on the page or having assignment = operators instead of == comparison operators causing the logic to do something unexpected.
  15. You need to investigate what the actual query statement is that is failing. Form the query statement in a php variable and output it as part of the die() statement so that you can see exactly what the whole query is and exactly what is at the point where the error is being reported.
  16. Actually, since you are using a COUNT() in your query and you are not using an alias name, you would need to use mysql_fetch_row or mysql_fetch_array and then access the zero'th element of that array to get the count. Do you have php's error_reporting set to E_ALL so that all the errors php detects will be reported and displayed? You would be getting several notice and perhaps warnings from your code.
  17. Note: There's an error in the code I posted above for the $totals array. It should be - $totals[$row['PCODE']] = $row['total']; We know what your table looks like. It is designed incorrectly. That's why different people keep telling you in your threads that you need to straighten out your design so that you don't need to keep writing hundreds of lines of unnecessary code. You have over 100 lines of code that I was able to replace with 12 lines of code. Writing block after block of code with variables like $P28, $P28_max, $P28_min, $P30, $P30_max, $P30_min, ... is not effective use of variables and is not effective programming. Also, putting a fixed/static query (that returns the same result set every time it is executed) inside of a loop, is a complete waste of processing time. The following code will (untested) retrieve your parameter settings into the $settings array that I show in the code I have been posting - <?php $sql = "SELECT P28, P28_max, P28_min, P30, P30_max, P30_min, P32, P32_max, P32_min, P33, P33_max, P33_min, P35, P35_max, P35_min, P35M, P35M_max, P35M_min, P35W, P35W_max, P35W_min, P38, P38_max, P38_min, P41, P41_max, P41_min, P42, P42_max, P42_min, P43, P43_max, P43_min, P46, P46_max, P46_min, P47, P47_max, P47_min FROM parameter_settings"; $res_pcode = mysql_query($sql, $con); $settings = array(); $row = mysql_fetch_assoc($res_pcode); $settings[$row['P28']]['max'] = $row['P28_max']; $settings[$row['P28']]['min'] = $row['P28_min']; $settings[$row['P30']]['max'] = $row['P30_max']; $settings[$row['P30']]['min'] = $row['P30_min']; $settings[$row['P32']]['max'] = $row['P32_max']; $settings[$row['P32']]['min'] = $row['P32_min']; $settings[$row['P33']]['max'] = $row['P33_max']; $settings[$row['P33']]['min'] = $row['P33_min']; $settings[$row['P35']]['max'] = $row['P35_max']; $settings[$row['P35']]['min'] = $row['P35_min']; $settings[$row['P35M']]['max'] = $row['P35M_max']; $settings[$row['P35M']]['min'] = $row['P35M_min']; $settings[$row['P35W']]['max'] = $row['P35W_max']; $settings[$row['P35W']]['min'] = $row['P35W_min']; $settings[$row['P38']]['max'] = $row['P38_max']; $settings[$row['P38']]['min'] = $row['P38_min']; $settings[$row['P41']]['max'] = $row['P41_max']; $settings[$row['P41']]['min'] = $row['P41_min']; $settings[$row['P42']]['max'] = $row['P42_max']; $settings[$row['P42']]['min'] = $row['P42_min']; $settings[$row['P43']]['max'] = $row['P43_max']; $settings[$row['P43']]['min'] = $row['P43_min']; $settings[$row['P46']]['max'] = $row['P46_max']; $settings[$row['P46']]['min'] = $row['P46_min']; $settings[$row['P47']]['max'] = $row['P47_max']; $settings[$row['P47']]['min'] = $row['P47_min']; $settings[$row['P28']]['max'] = $row['P28_max']; $settings[$row['P28']]['min'] = $row['P28_min']; $settings[$row['P28']]['max'] = $row['P28_max']; $settings[$row['P28']]['min'] = $row['P28_min']; $settings[$row['P28']]['max'] = $row['P28_max']; $settings[$row['P28']]['min'] = $row['P28_min']; $settings[$row['P28']]['max'] = $row['P28_max']; $settings[$row['P28']]['min'] = $row['P28_min'];
  18. Now that I have studied what it is you are trying to do, based on my post above (of fixing the settings table design so that you can easily retrieve the data into an array), to conditionally output the subitems when the total for the PCODE/Items is == to the minimum, you would do something like the following - ------ <snip> code above this point not shown <snip> ------ <table> <thead> <th>Items</th> <th>Sub Items</th> <th>Item Code</th> <th>Demanded Qty</th> <th>UoM</th> <th>Class</th> <th>Description</th> <th>BIN Location</th> </thead> <?php // select all the min/max settings (NOTE: you should have one row per PCODE with columns for the PCODE, min, max, and other settings for this PCODE...) // you would then let php make an array (instead of you typing out a long list of named variables that you must change every time you add a pcode name) where the array index name is the pcode (so you can directly access the corresponding values) and you have an array with the min/max settings. $sql = "SELECT PCODE, min, max FROM parameter_settings"; $result = mysql_query($sql,$con) or die(mysql_error()); $settings = array(); while($row = mysql_fetch_assoc($result)){ $settings[$row['PCODE']] = $row; // an array with the SELECT'ed pcode, min, and max values for this pcode } // select all PCODE's and their total $sql = "SELECT PCODE, total FROM kanban_checker ORDER BY PCODE"; $res = mysql_query($sql, $con) or die(mysql_error()); $totals = array(); while($row = mysql_fetch_assoc($res)){ // get a PCODE/total $totals[$PCODE] = $row['total']; } // get a list of Items/PCODEs appearing in the bom_subites table $sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items"; $res_bom = mysql_query($sql, $con); while($row = mysql_fetch_assoc($res_bom)){ $Items = $row['Items']; echo "<tr> <td style='border: none;font-weight: bold;'> $Items</td> </tr>"; // conditionally get and output the subitems if($totals[$Items] == $settings[$Items]['min']){ // the following code gets the subitems for the current item $sql = "SELECT SubItems, ItemCode, UoM, Class, Description, BINLocation FROM bom_subitems WHERE Items = '$Items' ORDER BY Items"; $res_sub = mysql_query($sql, $con); while($row_sub = mysql_fetch_assoc($res_sub)){ echo "<tr> <td style='border: none;'> </td> <td style='border: none;'>$row_sub[subItems]</td> <td style='border: none;'> $row_sub[itemCode]</td> <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty' value='' size='7'></center></td> <td style='border: none;' size='3'> $row_sub[uoM]</td> <td style='border: none;'> $row_sub[Class]</td> <td style='border: none;'> $row_sub[Description]</td> <td style='border: none;'> $row_sub[bINLocation]</td> </tr>"; } } } ?> </table> </div> </body> </html> Note: If all you are doing on this page is making the form, you can combine and reduce the three queries and the looped query using the parameter_settings, kanban_checker, and bom_subitems tables into one joined query statement, but that is beyond the scope of this thread (or the amount of time I would be willing to spend learning your table structures.)
  19. Do you even know what data is in your table? You have changed the query from using Available = 'Yes' to using Available = '1'? What is the actual data in your database table that the query should return?
  20. Sorry to jump in here, but you are still writing (and testing and changing and testing) far too many lines of repetitious hard-coded logic. In at least one of your previous threads, someone suggested fixing your database table designs and to NOT use a series of named variables where the variable name indicates the data in the variable (the variable name should indicate the purpose of the data in the variable - $PCODE, $total, $min, $max.) Since your kanban_checker table is apparently laid out correctly, I'm not sure why you haven't corrected your parameter_settings table. If you do this, it will greatly simplify your code, which will shorten the time it takes you to write, test, and change your code and it will also increase the chance of someone helping with your code problems (if we cannot figure out what your code is trying to do, there's little chance of us helping with it.) For example, if your parameter_settings table was corrected so that it had one row per PCODE, all that logic you have written and rewritten can be reduced to the following - <?php // select all the min/max settings (NOTE: you should have one row per PCODE with columns for the PCODE, min, max, and other settings for this PCODE...) // you would then let php make an array (instead of you typing out a long list of named variables that you must change every time you add a pcode name) where the array index name is the pcode (so you can directly access the corresponding values) and you have an array with the min/max settings. $sql = "SELECT PCODE, min, max FROM parameter_settings" $result = mysql_query($sql,$con); $settings = array(); while($row = mysql_fetch_assoc($result)){ $settings[$row['PCODE']] = $row; // an array with the SELECT'ed pcode, min, and max values for this pcode } // select all PCODE's and their total $sql = "SELECT PCODE, total FROM kanban_checker ORDER BY PCODE"; $res = mysql_query($sql, $con) or die(mysql_error()); while($row = mysql_fetch_assoc($res)){ // get a PCODE/total $PCODE = $row['PCODE']; $total = $row['total']; // if the total for this PCODE is the same as its minimum, echo the minimum if($settings[$PCODE]['min'] == $total){ echo $settings[$PCODE]['min']; } }
  21. That editor, probably as a workaround instead of fixing a problem, inserts a <br /> in each empty textarea, that posts as a <br> (I'm not sure where/how the space and / are removed.) If you don't enter anything in a textarea, a <br> is posted. If you do enter something, there is a <br> on the end of it. You would need to check if the posted data from each field is just a <br> and remove it. If you don't want a <br> on the end of each actual value you do enter, you would need to strip that off as well. Didn't it occur to you to mention or show up front that you had some code like a WYSIWYG (and which one) involved? You could have gotten an answer almost 4 days ago.
  22. You are overwriting the $sql variable inside the while(){} loop, so the second time through the loop it no longer contains the result object from the SELECT query.
  23. The OP is having difficulty assigning things to and using the correct variables at the right points in his code. He needs to be able to crawl before he can walk.
  24. A) Please read the sticky post concerning header errors - http://www.phpfreaks.com/forums/index.php?topic=37442.0 B) Next read the error message, it tells you where the OUTPUT is occurring at in your script that you need to find and eliminate. C) We cannot help you without the whole error message (xxxxx out any sensitive information you don't want to post) and the code from the start of your page up to the point where the error message says the output is occurring at.
  25. If you want to only produce the pagination links when the total number of matching items is greater than the rowsperpage, you can put all the logic that forms and outputs the pagination links inside of a conditional statement that tests if($total > $rowsperpage){... pagination link code ...}
×
×
  • 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.