Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Either escape the $ "\$L" or use single quotes - '$L'
  2. The indirect answer to that is they won't interfere with each other because there will only be one $query and one $results variable. You won't have 10 sets of code to view all the players on one page. You will have one set of code that loops over the players. Use one query (without a where clause) to get the results for all the players at once, then loop over the result set and process or output the information for each player inside the loop. <?php $query = "SELECT Player,SUM(GLI) AS 'gli', SUM(Goals) AS 'goals', SUM(Saves) AS 'saves', SUM(SOG) AS 'sog', SUM(Assists) AS 'assists', SUM(CK) AS 'ck', SUM(YC) AS 'yc', SUM(RC) AS 'rc' FROM pinkpanther_stats GROUP BY Player"; $results = mysql_query($query) or die ("Query failed ($query) - " . mysql_error()); while($row = mysql_fetch_array($results)){ // use the data or display the result for each player here... $row['Player'] will contain the player's name. }
  3. If you are doing this for ALL the players in the table, you would simply use GROUP BY player in the query to consolidate all the rows for each player together (you will get a resultant row in the result set for each player - you would need to add the player column to the select list so that you can identify each row.) You would also sum(...) as '...' each column/field in ONE query, not separate queries for each column/field. You also would not use a players name in any of the variable names or alias names in the query. You would use generic variable names like $query, $result,... and alias names like 'gli', 'goals', ... Edit: If you are doing this for just one, two, or a few players, you would still use GROUP BY player and in the WHERE clause use WHERE player IN('adam','bill','bob') The point of all of this is to get all the data you want, in the order that you want it, using one query (or as few queries as possible.)
  4. The upload error number is 8. Unfortunately, there is little documentation for the meaning, but it is likely that you have the Suhosin hardened php patch installed on your server (or newly installed on your server) and it is what stopped the upload from working.
  5. Your code is not checking if the upload worked before accessing the uploaded file information. You need some upload error checking, reporting/logging, and error recover logic in your code. For debugging purposes, to see what exactly is in the $_FILES information, add the following lines of code to your processing page - echo "<pre>"; echo "FILES:"; print_r($_FILES); echo "</pre>";
  6. php causing a crash under windows is usually due to having files of mismatched versions or type (non-thead safe v.s. thread safe) of php and it's .dll files. Did you get all the .dll files out of the same php package? About the only other things that come to mind would be to search the php bug reports and examine the php change log, starting at the next higher version number, to see if there has been anything fixed that seems related to your error.
  7. Without the code you used with array_map/trim, it's not possible to tell you why your code didn't work.
  8. array_walk cannot be used with built in functions because it does not return a value and for it to operate on the elements of an array the call-back function must be defined using a reference & to the passed parameter. array_map will work with built in functions or you would need to write your own call-back function to use with array_walk.
  9. The last code file you posted is calling the function that uses $conn before your code has created a database connection in $conn. You are also not testing if a form was submitted before you attempt to use any of the $_POST data from the form. That will just cause errors any time the page gets requested when there is not a form submission.
  10. 30719 (in php5.3) is E_ALL. The two settings appear to be correct and should report and display all php detected errors. Perhaps there are no php detected errors in the code you are trying or they are hidden in the 'view source' of the page in your browser or you are using AJAX to request the page and unless your ajax code literally outputs the content it gets from the server, you won't see any error messages that php outputs on a page. What sort of problems are you having with some code? If you post the code that duplicates the symptom, along with a specific statement of the symptoms when you try it, someone can probably help determine what it is or is not doing.
  11. FYI - You should be using mysql_real_escape_string not mysql_escape_string Just a guess, but if your browser is requesting the page twice (I seem to recall a previous thread of yours concerning an INSERT query running twice, once with data and once without), the first time with $_POST data and the second time without $_POST data, the second time would UPDATE an empty value into the post_text column that would replace the actual text that was just UPDATEd. And I know that I asked this in one of your previous threads, but why are you not validating that a form was submitted and that $_POST['posttext'] is not empty?
  12. So, the code you posted that has the INSERT query is the thanks.php page? Did you ever determine why the data was being inserted 4 times (the things I mentioned generally only cause data to be submitted twice)? What that just due to testing your page two times, then looking and seeing the data four times?
  13. The detection and handling of each statement that produces an error probably takes about 10 times longer than if the statement did not produce an error. A statement that would normally take 1ms, probably takes around 10ms. The actual reporting/display/logging of the error is just the last step in the error handling code that always gets executed every time an error is encountered as the code runs. Add to this the extra time when your script on any page ends for the actual write/append to the error log file (individual error messages are likely buffered, unless there is a huge quantity of them.) This would at most add a fraction of a percent to the execution time of a page. Then there's your time spent trying to open and find relevant entries in a huge log file. The quicker you find and eliminate the errors that are occurring when the script runs normally, the better for finding and fixing the errors that happen abnormally due to actual problems in the code (or hackers trying to break in.)
  14. If you want the specific rows - http://dev.mysql.com/doc/refman/5.5/en/example-maximum-column-group-row.html
  15. Browsers can request a page twice (FF does this when firebug add on is running and when the default page encoding doesn't match the actual web page, IE does this in relation to getting the favicon.ico file) and some web hosting behind a proxy can request a page twice and some URL rewriting can cause a page to be requested twice along with some javascript in your form. How come your current code is NOT testing if a form was submitted before using the data, like the code that was given in one of your previous threads? Edit: It's likely that the confirm button code is causing the page to be requested/submitted to twice. How about posting that relevant code as well?
  16. Your page contains a fatal parse error on line 89 due to a missing ) on line 88. Also, the syntax for a foreach() statement is - http://us3.php.net/manual/en/control-structures.foreach.php 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 php will help you by reporting and displaying all the errors it detects. You will save a TON of time.
  17. After you explode the line, you can get a count of the number of elements. If the missing field is always the last one, you can add a blank/default value onto the end of the exploded elements. Alternatively, you should already be listing the field names in the query. When one field is missing, you could build a query that does not contain that field name and simply leave that field and missing-value out of the query.
  18. If you goal is to log someone in for the duration of one visit to your site (one browser session), you would use a session variable to remember that they have logged in. If your goal is to remember that someone is logged in across multiple visits to your site, read this post - http://www.phpfreaks.com/forums/index.php?topic=346586.msg1635843#msg1635843 Storing the actual username and password in plain text in cookies has at least one major security problem (anyone with access to the computer or to the data packets going back and forth can see and get the actual password) and just testing for the existence of a cookie to treat someone as being logged in will allow anyone to become logged in because they can simply set a cookie with any value. Storing a unique id, that you generate on the server (and regenerate as needed), in a cookie virtually eliminates the possibility that someone can generate a value that will match an actual user (it is still possible to intercept that value and impersonate an actual user, but that is a different problem.)
  19. See Example #3 at the following link for how you would loop over the array of uploaded files - http://us.php.net/manual/en/features.file-upload.post-method.php The if(){} statement inside that loop tests if the file was successfully uploaded. You would put (or call) your code to process each file inside that if(){} statement.
  20. Output <pre> </pre> tags around the print_r/var_dump statement.
  21. You need to start with a day in the month that always exists, than apply -1 month, -2 month, ... mktime is actually easier to use. You can list the first day of the current month, then subtract 1, 2, 3,... from the month parameter. Edit: like so - <?php for($x = 1;$x <=6;$x++){ echo date('F Y', mktime(0,0,0,date("n")-$x,1,date("Y"))); echo "<br />"; }
  22. Make a 'composite' of the year and week (you will need a leading zero on the week so that the format will ALWAYS be the same length) - WHERE CONCAT(year,week) BETWEEN $StartYear$StartWeek AND $EndYear$EndWeek Edit: You can use the mysql LPAD() function to give a leading zero on the week - WHERE CONCAT(year,LPAD(week,2,'0')) BETWEEN $StartYear$StartWeek AND $EndYear$EndWeek The $StartWeek and $EndWeek also must have a leading zero to always give two digits, which you can do directly in the sprintf() statement.
  23. Your php code using one query - <?php require("include.php"); $con = mysql_connect("$db_host","$db_username","$db_pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("chalmers_db", $con); $heading = null; // remember the last heading $result = mysql_query("SELECT title, date, content FROM blog ORDER BY date DESC"); while($row = mysql_fetch_array($result)){ if($heading != $row['title']){ // a new heading detected, start a new section here... $heading = $row['title']; // save the new title $date=date('m-d-Y',strtotime($row['date'])); ?> <!--start accordionButton div--> <div class="accordionButton"><?php echo "{$row['title']}, $date";?> </div> <!--end accordianButton div--> <?php } // handle each piece of data here... ?> <!--start accordionContent div--> <div class="accordionContent" align="justify"><?php echo $row['content'];?> </div> <!--end accordionContent div--> <?php } ?>
  24. I'm going to guess that some of the titles in $title probably contain some sql special characters that need to be escaped before being put into the inner query. Faux Edit: There's actually no need for two queries. You can use one to accomplish the same thing. Just detect when the title changes to close out a previous section and output a new heading. Real Edit2: Visiting the link in the 1st post in the thread confirms that there are ' in the titles that fail.
  25. The mysql query cache will cache the result for you -
×
×
  • 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.