Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Assuming that your cart data is stored as an array in a session variable named 'cart' - $_SESSION['cart'] = array(); // clear cart by making it an empty array For anything else, you would need to provide information about how your cart data is actually stored.
  2. To detect and output a new month heading or just a break in the output, you would need to 'remember' the month (name or number) and detect when the month (name or number) changes. You can get the month (name or number) using date() with one of the month format specifiers. The function you found takes a second parameter to specific the end date. You would just produce a date one less than the current date and supply that as a parameter when you call the function.
  3. And the actual format for that date is thus -
  4. <?php $Profile['display'] = '1|0|1|0'; foreach(explode('|',$Profile['display']) as $key=>$value){ echo "<input type='checkbox' name='profile[$key]' " . ($value == 1 ? 'checked="checked"' : '') . ' />'; }
  5. Please everyone, check that your file(s) uploaded successfully before you attempt to use any of the uploaded file information. Otherwise, you will end up with blank screens or error messages that don't match the actual problem or follow-on error messages that don't have anything to do with the problem.
  6. You need to actually find out what the ['type'] element is. Also, have you checked for upload errors prior to that point, because if the file didn't upload properly, the ['type'] element is probably empty. For debugging purposes only, add the following code to your form processing page, immediately after the first opening <?php tag - echo "<pre>",print_r($_FILES,true),"</pre>"; exit;
  7. AFAIK, both the phpmailer and swiftmail classes are coded to current depreciated/strict php standards.
  8. ^^^ But, that's NOT what you are doing where the problem occurs. You stated you are on the process.php?ID=123 page and you are including page.php into process.php to redisplay it and you want the 123 $_GET['ID'] value to be available in the page.php code. That's the answer you have been shown. At this point, I've got to ask, have you even looked at the php.net documentation for the include statement so that you know what it does?
  9. INSERT queries don't return result sets, so there's nothing to fetch. What exactly are you trying to accomplish, because performing two INSERT queries on the same table for different columns does not make any sense.
  10. If process.php uses include "page.php";, $_GET['ID'] will have the value in it that process.php was requested with and the page.php code will do what you expect.
  11. UPDATE queries don't return result resources. mysql_num_rows and mysql_result are only used with SELECT, SHOW, and EXPLAIN queries that return result resources. UPDATE and INSERT (REPLACE) queries return either TRUE (the query executed without any errors) or FALSE (the query failed due to an error.) You can use mysql_affected_rows to determine if UPDATE and INSERT (REPLACE) queries actually change any rows. Have you actually read any of the php.net documentation for the php functions you are using? That's where all the information that I just posted was learned.
  12. When you include php code into another file (through the file system), the included code becomes part of the main file (at the point where it was included) and it has the exact same variable scope as the main file. Any variables that are present or that you set in the main file - $_GET['ID'], $ID, $ToDoID,... are already available to the included code.
  13. You should NOT be opening and closing your database connection inside of your functions. It takes a relatively long time to open a database connection. On any page that needs a database connection, you need to open the connection once in your main program scope and leave it open until you no longer need it or more simply let php close it when the script on the page ends. If code inside your function(s) needs a specific database connection, you need to pass the connection link resource into the function as a call time parameter (so that you could, if needed, use multiple different database connections.)
  14. If that code produces the result you have defined that you want, then the answer would be yes. Programming is the ultimate do-it-yourself task (had to be very careful stating that), because only the programmer knows what he intended his code to do and only he knows if he was successful when he observes the result when he tests his code.
  15. Yes for the 2nd and 3rd parameters. However, the first parameter is for the session cookie lifetime. That does not exactly define how long the session lasts. That defines how long the session id cookie will remain valid after all instances of the browser have been closed. Since the session also involves the session data that is stored on the server, if your intent is for a session to remain valid for two hours after the browser has been closed, you would also need to extend the session.gc_maxlifetime setting a like amount (on a shared web server this will require that you store the session data files in your own folder so that only your session.gc_maxlifetime setting will affect the files.)
  16. Reply #2 in the sticky post on HEADER ERRORS - READ HERE BEFORE POSTING THEM will probably help - http://www.phpfreaks.com/forums/index.php?topic=37442.0
  17. Are you sure the file itself, before you upload it, is actually a valid jpg/jpeg image file? Have you tried a different type of image file? @laffin, the $src_size data is from a getimagesize statement. Edit: I just tried the code you posted for a known good .jpg source file and it did create an expected resized .jpg image in the appropriate destination folder. I would check to make sure your sonic.jpg is actually a .jpg file (browsers will open mis-named images correctly, php functions are not going to be as forgiving.)
  18. When exactly do you get that error message? When you are resizing the image or when you later try to place the resized image on a web page? What is the code you use to invoke the script you posted? What is the code you use to place the resized image onto a web page? Edit: The reason I ask this is because you don't output a content-type header unless you are dynamically outputting the image to the browser, not when you are saving it to a file.
  19. You can make custom ORDER BY terms using any mysql statement that produces a value. The following should work (you might need to change the DESC to ASC) - ORDER BY 0 IN (exhib_date_year,exhib_date_month,exhib_date_day) DESC, exhib_date_year DESC, exhib_date_month DESC, exhib_date_day DESC
  20. I think your question is - how do I display the current cart? <?php if(empty($_SESSION['cart'])){ echo "There are no items in your cart!"; } else { // cart is not empty $items = implode(',',array_keys($_SESSION['cart'])); // get a list of the item numbers // get the rows matching the item id's $query = "SELECT * FROM events WHERE id in ($items) ORDER BY some_column"; // order the data the way you want it to be displayed $result = mysql_query($query); while($row = mysql_fetch_assoc($result)){ // your code to display the information about each item in the cart // Note: $_SESSION['cart'][$row['id']] contains the quantity of each item that is in the cart } }
  21. It's likely that the host-name/subdomain (www. vs no www.) in the URLs are changing back and forth (between having and not having the www. on them) and the session id cookie only matches the URL variation where it was set at and when you are redirecting around, you finally end up going between pages that all have the same host-name (or lack thereof) in the URL. If this is the case, here are some things you can do to fix the problem - 1) You should set up a .htaccess redirect to force all URL's to goto a single variation of your domain, 2) You should be constant in your code to always build links/redirects with the same variation of your domain, 3) You should set the session.cookie_domain setting to be .yourdomain.com (with the leading dot . ) to get the session id cookie to match all variations of your domain. Also, if this has to do with the session only working within one /folder/ path, you need to set the session.cookie_path setting to a '/' (it is by default) so that the session id cookie will match all paths of your domain. (This is like the 4th time in the past week or so where I have posted this, you guys must all be in the same programming class.)
  22. What still does nothing? The only thing that few lines of code is for is to -
  23. I notice that I left out an intended array index in the example code, but then again, that is what 'like' means. All the $_SESSION[$item_id] need to be $_SESSION['cart'][$item_id] so that all the cart related data is grouped together under a unique index name to distinguish it from any other possible session data.
  24. Reply #2 in the sticky post on header errors will probably help - http://www.phpfreaks.com/forums/index.php?topic=37442.0
  25. Yep. More time wasted by php due to a lazy-way short-cut.
×
×
  • 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.