Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. floatval
  2. ^^^ You can only put php settings in a .htaccess file when php is running as a server module. It is highly likely that php is now running as a CGI application. Start by removing or commenting out any php settings in your .htaccess file and see what you get.
  3. Do you mean die ?
  4. Add the following two lines of code immediately after the first opening <?php tag to get php to report and display all the runtime errors it detects - ini_set("display_errors", "1"); error_reporting(-1); Also, if you browse directly to the .php pages, it will be easer to see the actual output and debug whatever is going on.
  5. Why do you need to pass the path through the form? If it is always images/slideshow/, just use that value in the php code. If you do need it to be one of several choices, either - 1) User a numerical index to path relationship and only pass the numerical index through the form. That way someone (hacker) can only pick one of the possible values by suppling the index number. Your php code would get the actual path from the supplied index number. 2) If you still want to pass the actual path, such as images/slideshow/, through the form, completely validating it means that you test if the submitted value is only and exactly one of the possible paths. For your extension validation, you should use a white list of permitted values, rather than try to use a black list, since you can miss some possible values and they could change over time or be different on different servers.
  6. Your VenueCode is a string and would need to be enclosed in single-quotes within the query statement. (edit: which Pikachu2000 pointed out above.) I also notice you are doing a less-than-or-equal-to date comparison with a date() format of "Y-m-d g:i a". The less-than part of that won't work for a couple of reasons - 1) The g (12 hr time w/o leading zero) and a (am or pm) produce values that are not ordered by magnitude (i.e. 1 pm will be less-than 9 am, 11 am is less-than than 8 am, ...). The hours needs to be 24 hour with leading zero and the am/pm is not needed. 2) Your EventOnSaleDate column is apparently a mysql datetime data type (YYYY-MM-DD HH:MM:SS) (if it's not, it needs to be for a greater-than/less-than comparison to work) and you would need to use a date() format of 'Y-m-d H:i:s' in order for a greater-than/less-than comparison to work.
  7. The leading slash / on your location value refers to the root of the current hard disk. I doubt that is where you intended the uplaoded files to be put and the /images/slideshow/ folder probably does not exist starting in the root of the disk. You should have php's error_reporting set to E_ALL and display_errors set to ON in your master php.ini on your development system so that all the php detected errors will be reported and displayed. You would be getting a 'directory or file does not exist' error message. Also, you should not accept the location through a form field, without completely validating it, since that would allow someone to upload a file to ANY location on your server and do things like replace your main index.php file. You also need to validate the filename in $_FILES['uploadedfile']['name'] to only allow files of a particular file extension to be uploaded (you would not want .php files to be uploaded and you can fool getimagesize with image data in a file that also contains php code.)
  8. Nope. That's not what is different between the different mysql_fetch_xxxxx functions. You need to read the php.net documentation for the functions.
  9. $row and $array are just two different names you have chosen to use as variables names in your code. They are both arrays.
  10. Actually, just post all your current code, starting from where you are forming the mysql query statement through to the end of the <select></select> menu code.
  11. You already have an active thread for this issue. Stick to that thread so that you don't lose the information about what it is you are doing, where you are getting the data from, and what solutions you have already been given. Edit: if your current problem doing this is actually getting the data from the database, you would need to post the code responsible for getting that data from the database. The code you posted has nothing to do with getting the database value.
  12. Of course you can. Did you read the documentation for range
  13. If you only want to keep a specific number of recent items, you would push the values onto the end of an array and only keep the last n items - <?php $n = 5; // number of recent items to remember if(isset($_GET['id'])){ $id = (int)$_GET['id']; if(!in_array($id,$_SESSION['viewed'])){ $_SESSION['viewed'][] = $id; $_SESSION['viewed'] = array_slice($_SESSION['viewed'],-$n,$n); // keep last n entries } }
  14. You would use a session variable ($_SESSION['viewed'][n] = true;, where n is a product id) to remember the product id's that the person has viewed. To display the product information, use array_keys to get the list of id's from the $_SESSION['viewed'] array.
  15. In order to find the maximum sum, you would need to iterate over each range of dates and maintain a sum for each date, then simply find the maximum. <?php $data[] = array('2012-02-21','2012-02-24'); $data[] = array('2012-02-21','2012-02-26'); $data[] = array('2012-02-23','2012-02-29'); $data[] = array('2012-02-24','2012-02-27'); $data[] = array('2012-02-26','2012-02-28'); $arr = array(); foreach($data as $range){ while($range[0] <= $range[1]){ $arr[$range[0]] = isset($arr[$range[0]]) ? $arr[$range[0]] + 1 :1; $range[0] = date('Y-m-d',strtotime($range[0] . '+ 1 day')); } } arsort($arr); $peak = current($arr); echo "Peak: $peak";
  16. The code you posted at the start of this thread contains a number of problems - 1) You would never unlink the existing image until you know you have successfully uploaded and saved a new image. 2) You are not actually testing if the image uploaded without any errors ($_FILES['image']['name'] will be set for some of the possible upload errors.) 3) You are not actually using the result of any of the validation tests to prevent the following logic from running. 4) Your unlink code assumes that the existing image is a .jpg, but your logic allows jpg/png/gif images to be used. 5) If you are going to save the new image with a unique name, you would need to get the actual old image name from the database to use in your unlink statement. Doing this would address item #4 as well. 6) You should use move_uploaded_file to process the uploaded file. 7) You are executing the UPDATE query without knowing that the new image was successfully processed.
  17. Because nothing you have tried worked, except refreshing the page, I'm going to guess that you have some code, such as your session_start/login check code, that contains an error in it that is preventing the code you did post from processing image the first time the page is submitted. Refreshing that page causes the form to be submitted a second time and the logic is now satisfied and actually processes the image the second time around. Post your whole form and form processing code, less any database credentials, that would be needed to duplicate the problem. ^^^ That is invalid php. You are making and echoing a quoted string. You cannot put php code inside the string. You must concatenate any php code with the string and you wouldn't use php tags with it, just the dot . operator. I can only only guess that any further code you tried did not actually output a random number onto the end of the URL in the <img > tag. Did you look at the 'view source' of the resulting page to see if there was a random number?
  18. The mysql_connect statement, inside that function, the way it is coded now, is reusing the existing main database connection because the hostname,username, and password are the same. When you use mysql_close inside that function, you are actually closing the main connection. You would need to set the 4th parameter of the mysql_connect statment to true to form a new connection that you could separately select the slow_execution database without interfering with the main database connection and the currently selected database on the main connection.
  19. They might be for a different database, but are they the same hostname, username, and password as the main database connection?
  20. Are the database connection details you are using in that code the same as for the main database connection?
  21. Your function needs to return the value from the mysql_query() statement so that the calling code will get the result-resource/true/false value back.
  22. I forgot to ask, but what is the max_execution_time setting and are there any set_time_limit statements in the code? Php should be stopping execution on a page request after the max_execution_time/set_time_limit has been reached (edit: assuming that the web server has actually passed control to the php language engine.)
  23. There are too many different things that could cause page generation times to vary - server disk spin-up time on drives not configured to run continuously, disk errors occurring, disk caching problems, php bytecode cache problems, backup programs running and locking database tables or code files, replication running and locking data/files, concurrent usage exceeding the available server processing/memory resources, DOS attacks, applications intentionally locking database tables and not releasing them, available memory/memory allocation/memory page file/disk swapping, poorly written code, code that loads a huge number of files and they are not already present in the disk cache, lack of database table indexes, ... You need to find the actual cause. However, once you have optimized the code, you can at least eliminate the code as being the source of the problem. If your page generation time is solely being calculated in the php code, then the issue is likely on the server and not an Internet connection problem. A page taking 381 seconds to generate would indicate a fundamental problem, such as an operating system problem, disk problem, web server problem, php bug/code bug, mysql server problem. ^^^ You do realize that term in your query will match data for all years. If/once you have more than one year of data, that query will give you combined results for the selected month for all years.
  24. Why not do a search and replace using your programming editor, on either just the files for one offending page or on all the files in the application, to change mysql_query statements to your debug_mysql_query function call? ^^^ I hope you are actually correcting the logic that is doing things like that, so that you have one query that gets all the rows you want, then you simply iterate over those rows? Edit: Why aren't you working with an off-line copy of the application code and database to test and prove the changes you are making? You shouldn't actually be using the online active application and data for making changes and testing. Prove each change on a development system, then make that change to the actual application.
  25. The output_buffering setting in the master php.ini likely got turned off, either due to a reinstall (and someone forgot to set the settings as they previously were) or a php version upgrade (and someone forgot to set the settings as they previously were) or a syntax error was introduced in the master php.ini, which causes any settings after the point of the error to take on their default values (output_buffering is off by default when not specifically set to any value.)
×
×
  • 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.