Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. From the standpoint of doing this all through a database, having a table (either a permanent one or a temporary one) that holds a contiguous range of dates that spans the date range of your report that you can join your data with, is how this is usually done. Assuming you have a start and end date already that you are using to get the data, take a look at this link - http://www.richnetapps.com/using-mysql-generate-daily-sales-reports-filled-gaps/ I would personally use a TEMPORARY table in the fill_calendar() procedure so that you don't need to worry about making sure that it contains a correct range of dates. Just call fill_calendar() with the same start and end date that you are using in your query to fetch the data.
  2. It is fairly likely that $ProductID is not set and if ($i == $ProductID) { is FALSE. What makes you think $error should be a 1? You also don't need the foreach() loop because $var will only consist of one element, $var['ProductID'], because that is all your SELECT statement is returning.
  3. You should be learning php, developing php code, 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. (Confirm the actual settings using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using.) You will save a ton of time. There would have been an undefined index error message in your code concerning $_GET['ID'] that would have alerted you to the fact that is not being set because it does not match the ?id being put on the end of the URL.
  4. A) You should be learning php, developing php code, 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. (Confirm the actual settings using a phpinfo() statement in case the php.ini that you are changing is not the one that php is using.) You will save a ton of time. There would have been an undefined error message in your main code concerning $logo that would have alerted you to the fact that it does not exist in your main code because you are setting it inside of a function and it only exists inside of that function. B) The two lines of code you posted in the first post, that you then expected everyone to be able to tell you why it did not work IS DEFINITELY NOT the actual code that does not work. Posting lines of code out of context, in this case way way out of context, just wastes everyone's time and almost always prevents getting a solution. C) The point of functions are that they (optionally) accept input parameters, perform a (one) useful operation that your application needs, and returns the result that they produce. The purpose of your GetGuide() function is to produce and return $FGuide. The code in the GetGuide() function that is testing $_GET['channel'] for the purpose of setting $logo has nothing to do with producing and returning $FGuide and the code setting $logo should either be part of your main application code (right before where $logo is used) or it should be put into its' own function.
  5. Define: "it wont work" For all we know the php code is functioning correctly but you don't have the correct path to the image so you are getting a broken image displayed when the browser renders the html.
  6. Rather than just bumping a thread that did not receive any replies, why not take the time to provide additional information, clarification, and an example of what you mean. Probably why no one replied is because no one knows exactly what you are asking.
  7. Please read the documentation for what you are doing - http://us2.php.net/manual/en/function.date.php "now" for a format string would give: Numeric representation of the month, without leading zeros (1-12), ISO-8601 year number, and numeric representation of the day of the week (0-6). So, today (Nov. 27, 2009 where I am located) would give 1120095
  8. Because the type="file" value can only be set by the browser's file select dialog box, you cannot use standard methods of adding fields by rewriting all the values. You must insert/add fields. Here is a link to script that shows how to do this - http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
  9. Use the mysql DATE_FORMAT() function directly in your query to get a DATE into any format you want - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format
  10. Your code is dependent on register_globals being ON to magically populate $cmd and $id from the $_GET variables on the end of the URL. Where ever you found or learned that code, it is 7 years out of date because register_globals were turned off by default in php4.2 in April of the year 2002 and no new code, books, or tutorials should have been written after that point in time that relied on register_globals being on. You should also be learning php, developing php code, 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. You will save a ton of time. There would have been undefined error messages concerning $cmd and $id that would have alerted you to the fact that they are not being set.
  11. Or if there is a file download link that allows an arbitrary filename to be specified on the end of the URL.
  12. Your mysql_query() failed to execute. Echo mysql_error(); on the line right after the mysql_query statement to find out why.
  13. Either your code that is setting $user_id is adding the space or you actually have a space in your data. Edit: In fact, I'm going guess you have some code that looks like this - $user_id = " {$row['user_id']}";
  14. If you post your code (between bbcode tags or ) and error in the forum, you will find that you will get more and faster replies.
  15. There are two ways you can do this for the format you have shown - 1) Use the mysql STR_TO_DATE() function in your query, 2) Explode the string on the / character, then form a new string with the fields in the correct format. Unfortunately, the strtotime() function does not understand DD/MM/YYYY, so you would need to alter the string before you could use strtotime() on it. When using the / for a delimiter, you would need to supply a mm/dd/yyyy. See this link for a definition of what strtotime can parse - http://www.gnu.org/software/tar/manual/html_node/Calendar-date-items.html#SEC116
  16. There is an extra $ in the following line - return $this->$variable1; It should be - return $this->variable1; I'm assuming that you are developing and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON so that php will alert you to problems is finds (there would have been an error on the line posted above that would have helped you in finding the problem with that line of code.)
  17. Benchmarks using loops of 10,000 echo statements have shown that putting a variable inside of a double-quoted string is slightly faster than using concatenation. If my memory is correct, a few 1/100 of a second for a loop of 10K. You would need to benchmark if that or a sprintf() is faster. Assigning one variable to another just to put the second variable into a string, when the first variable could be put into the string directly, would always be less efficient than just putting the original variable into the string.
  18. Your mysql_select_db() function call has no error checking logic on it, so how do you know if it is working or failing? Something like the following would be in line with what you doing in the rest of the code - mysql_select_db($db_name,$myconn) or die("Could not select database: $db_name" . mysql_error()); Do you know for a fact that your error_reporting/log_errors/error_log setting are set so that all php detected errors are being logged? For debugging purposes, I would recommend adding the following two lines of code immediately after your first opening <?php tag in your main file - ini_set("display_errors", "1"); error_reporting(E_ALL); The following code in your main file won't do anything because if the connection fails, your code dies before reaching it ($myconn won't ever be false at that point in the main code) - if (!$myconn)
  19. You likely got a fatal parse or fatal runtime error and nothing was output on the page in response to the http request. If you learn php, develop php code, and debug php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini, php will display all the errors it finds. You also might have a problem in a .htaccess file. Did you do what the error suggested -
  20. Unfortunately, the php parser needs help finding the start and end of array variables when they are contained within a double-quoted string. One way to accomplish this is to surround array variables in {} when they are in a double-quoted string. This will allow you to leave in the quotes that are around the associative index names so you don't need to use different syntax for array variables inside and outside strings. If $row_details['....'] is the result of an assignment of the value returned by a mysql_fetch_xxxxx() instruction, then yes. If you are having a problem, it woud take seeing the code that is execuiting the query up through the code you posted. That is referred to as pagination. There are countless examples posted around the Internet - http://www.phpfreaks.com/tutorial/basic-pagination Short-version: You use a LIMIT clause in the query to determine which 'group' of 5 rows you want and setup links to cause the page to query for and then display the correct group of rows. The query itself returns the number of rows you want, so you just put your display code inside of a while() loop.
  21. The simplest system is to record (in a database table) each vote, with the member id, datetime of the vote, and what they voted for. Then it is a simple matter to query for the count of votes in the time period you are interested in and if that count is less than the limit, allow a new vote.
  22. Since all browsers handle letter-case of form field names the same, best guess is that the actual problem was due to using a image as a submit button.
  23. The error means that you provided an empty string to a query function, probably a mysql_query() function.
  24. If you open, using a programming editor, the downloaded files that failed, you will probably find some php error messages, particularly due to calling ob_clean() when there is no output buffer in use. You don't need any of these lines of code - ob_clean(); flush(); exit; The filename portion of the 'Content-Disposition: attachment; filename="..." header should be enclosed in quotes to make all browsers happy.
  25. Probably because the mysql extension is not enabled. Remove the @ from in front of the mysql_query() (there is no reason to ever put an @ in any code, you want to see all errors during development and testing and on a live server you would have display_errors turned off anyway) and for debugging add the following two lines of code immediately after your first opening <?php tag - ini_set("display_errors", "1"); error_reporting(E_ALL);
×
×
  • 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.