Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. Each of the following are links to the relevant php.net manual section - fread fgets fgetcsv
  2. Where are you looking at to see the %2C value, because it should be decoded for you when php populates the $_COOKIE variable -
  3. What is the code block that works, right above the offending code, that you copied/modified to get the block of code that does not work, because seeing some code that works (I assume that means you tested it with a '0' value?), might indicate why the posted code does not work. Also, the offending code is inside of a class, seeing the working block of code vs the non-working might show something specific to oh let's say super-global variables, or perhaps specifically names super-global variables, that would give us some information to use to suggest things to find the problem.
  4. +1 ^^^ That's what I suspect as well.
  5. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=349747.0
  6. All your program variables from the form fields and the $PHP_SELF variable don't exist, because they are dependent on a setting that was turned off by default 9 years ago due to a huge security hole the setting opened. You need to have php's error_reporting set to E_ALL so that all the errors will be reported. Each of the non-existant program variables will be producing an undefined notice message. All of the form fields need to be accessed using $_POST['some_field_name'] To cause a form to submit to the same page, you can just use an empty action="" attribute.
  7. The original code contains that problem as well.
  8. It would help if you did a 'view source' of the page in your browser and posted the result.
  9. Your code isn't actually calling the mysql_query function. The light blue mysql_query is a link to the php.net manual page that shows several examples of how to form a query statement and call the mysql_query function.
  10. The same way someone suggested in one of your previous threads - http://www.phpfreaks.com/forums/index.php?topic=349042.msg1646845#msg1646845
  11. You would keep track of stock using a credit/debit balance system, the same as your checking account or credit-card account. You would not keep just a count, but keep information about each transaction that added to or subtracted from the total. The current total would be calculated by summing the added/subtracted amounts. The following addresses only the actual tracking of stock - When you receive/add stock, you would add a row to your `stock` table that list the who, what, quantity, when, where, why information - who add that stock, what it is (its id), quantity (as a positive number), when it was added, where it is at (in case you store same items in more than one location), and why it was added (stock replenishment, return restocked, ...) By storing and using the id, you would have just one `stock` table that contains the records for all items. When you remove stock, you would add a row for each item, listing who pulled the item, what (its id), quantity (as a negative number), when it was pulled, where it was pulled from (in case you store same items in more than one location and you want to track where items were pulled from), and why it is being deducted/pulled (shipped as part of an order, breakage, loss due to theft, shipped as a replacement to a customer, sample, ...) You would query for the current quantity in stock by summing the quantity column (plus and minus numbers) and grouping by the id(s) you are interested in (one specific id, a list of specific id's, all id's,...) All of this is separate from order tracking, where you would keep track of what items (by their id's) are part of each order and what the order status is (ordered, payment confirmed, released for shipping, shipped, received.) Any automation related to confirmation from your payment gateway would just change the status of an order. Each step in the order process would again be a separate recored in a table so that you can keep track of dates, payment confirmation numbers, who/what entered the information manually/automatically, notes associated with the status for that step,... You would query your `stock` table to find out if an item needs to be reordered because it is below your minimum stock level for that item and what sort of messages you display on your product page (quantity on hand, out of stock/back ordered) and while a visitor is adding the item to their cart and during order processing (you have selected more than the available quantity, do you wish to reduce the quantity or place the order with the selected quantity? , the following items are back ordered and will ship later...)
  12. You are opening $myFile inside your while(){}, so the output file will be recreated each pass through the while loop. Only information from the last line of the input file will remain in the output file. You should only open the output file once, before the start of the loop. When you explode each line from the input file, $column is an array of the elements in that line. Using a foreach(){} loop on $column, will iterate over each element in each line. $col is the (string) content of each element. Accessing $col[0] is actually accessing the first character of the content of each element. If you are just trying to write the first element of $column to the output file, you would not use a foreach(){} loop, you would just use $column[0]. What exact part of each input line are you trying to write to the output file?
  13. +1 (you should only store data that has an actual non-zero value.) The reason we always ask what exactly someone is doing, is because in programming, that is the best way of getting the quickest solution to a problem, without a lot of - well try this, no try that... replies. Several things you have shown or mention indicate a data/code design that you should optimize before you worry about using the array that the function returns multiple times on a page (or perhaps you actually mean across more than one page request since you also mentioned the session.) I suspect that your code can be made at least 5 times faster (and if you are performing a query in a loop, probably 10 times faster) and by knowing if you actually need the same resultant data available across more than one page request, someone can also suggest ways of storing and retrieving that amount of data. Also by showing exactly (code, sample data, result) what you are doing, some kind person here might actually test the suggestions they post so that you will know that the code will work for what you are doing.
  14. str_pad
  15. Do you have display_errors set to ON or log_errors set to ON? Is the php.ini that you are changing the one that php is using? The Loaded Configuration File line in the output from a phpinfo statement is the php.ini that php is using. Also, what does the phpinfo output show for the error_reporting and display_errors settings (something might be overriding your php.ini settings)?
  16. The first question would be, why do you need the privacy settings for all the users? If you do need all the privacy settings for all the users, you would not use a function that gets the settings one at a time, but a function that gets all the privacy settings at once. If you ever find yourself performing a SELECT query inside of a loop, there's probably something wrong with what you are doing. P.S. The SESSION keyword in the SHOW ... STATUS query should get the query count for the current connection.
  17. Did you restart your server so that the change to the php.ini will take effect? Also, is the php.ini that you are changing the one that php is using? The Loaded Configuration File line in the output from a phpinfo statement is the php.ini that php is using.
  18. Each image on a web page requires an <img src= .... tag... ummm.., just read this post - http://www.phpfreaks.com/forums/index.php?topic=349307.msg1648276#msg1648276 You cannot output the image data in your markup on the page. The browser requests the image (all media files) separately and renders it (or not, depending on the visitor's browser settings.)
  19. The & in the url are causing a HTTP 400 error back from google. Give the following a try - <?php $url = "http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=http://www.menuanalyser.co.uk/nutritional-report/11599"; $im = imagecreatefrompng($url); // Set the content type header - in this case image/jpeg header('Content-Type: image/jpeg'); // Output the image imagejpeg($im); You only use & encoding when outputting a link on a page to a browser, not in the actual URL that is requested.
  20. To build pagination links, without altering any other existing get parameters, see the code in this post - http://www.phpfreaks.com/forums/index.php?topic=348834.msg1646676#msg1646676 If you need to completely remove any specific key/value (i.e. filter) from a URL, simply unset the corresponding $_GET value before using http_build_query to build any link. See this post for an example - http://www.phpfreaks.com/forums/index.php?topic=346257.msg1634757#msg1634757
  21. You will have two problems - 1) If your server is set up correctly (securely) and using the default/common tmp folder for the session data files, the ownership/permissions of the session data files won't permit the files created under one domain/account to be accessed by the other domain/account. Also, if you are already using 'private' folders under each domain/account for the session data files, you would not be able to access the session data files created under one domain/account from the opposite domain/account. 2) The browser (using cookies for session id) or php (using the transparent sid (Session ID) management on the end of the URL for the session id) won't propagate the session id between different domains. Cookies are domain specific (due to the built-in security for cookies) and php simply won't due to the security implications - To solve #1, you must store the session data using a means that permits access by both domains/accounts. Using a database based custom session save handler would solve this problem. For #2, since you cannot change how browsers propagate cookies between domains and you probably don't want to rewrite part of php to get the automatic sid management to operate differently, you would need to rewrite the scripts on both of your sites to build any links that move between the two domains with the session id on the end of the URL, then hope that someone doesn't manually type a URL (without their current sid) or have a shortcut/bookmark saved (with no sid or an old sid) to go between the two domains as that would loose the session id and their login would not transfer to the different domain. Why exactly do you want to do this, since common actions by users (having a shortcut/bookmark saved or typing the URL) will cause it to fail? Hmmm. In typing this, I just thought of something you might try (still requires rewriting part of your login code and then making sure that a hacker cannot exploit it.) When someone logs in and gets a sid (or you ever regenerate a sid), you would need to store the sid in the user's row in your user table and then momentarily redirect them to a (blank) page in the opposite domain with that sid on the end of the URL. The page you redirect to would take that sid from the URL, find the matching row in the user table (to identify the user/get his userid), and then start a session using that sid so that you set a session id cookie under that domain with that sid. You would set any session variables needed to satisfy you login script, the same as if they had just manually logged in under the opposite domain. You would then redirect back to the starting domain. I think that by making sure that the sid stored in the database is unique and then matching the sid passed on the end of the url with one in the database table, that this is as secure as manually logging in on the opposite domain. Perhaps add a timestamp check to the user table as well - if the redirect/sid check in the opposite domain doesn't occur within a short time of when the sid was assigned and stored in the user table, then don't setup the session/automatically log them in on the opposite domain.
  22. You have a fatal parse error in - When developing and debugging php code you MUST have php's 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 that it detects.
  23. A template engine has absolutely nothing to do with how valid the resulting page is or how it looks in different browsers. It is still up to the programmer to make sure the html markup that he produces is valid and does what he wants in different browsers. The page at the link you posted has 67 errors and 32 warnings in the markup - http://validator.w3.org/check?uri=http%3A%2F%2Fwww.designtoprint.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0 All of those need to be corrected before you can ever worry about cross browser problems.
  24. In order to send multiple values from/through a form, the field names must be unique and there must be some way of associating each value with the item it applies to. By using an array for the set of fields, the fields are uniquely identified by their id and you can use php's array functions to process the data that gets submitted. I recommend putting just the code I posted into a .php file and trying it. Also, look at the 'view source' of the form in your browser so that you can see what it is doing.
  25. Here's a generic example of using an array as a form field name that you can adapt to your code - <?php // fake data (pretend this came from a database query) - $fake[] = array('id'=>'3','title'=>'apples','price'=>3.23); $fake[] = array('id'=>'1','title'=>'grapes','price'=>1.67); $fake[] = array('id'=>'2','title'=>'oranges','price'=>2.56); // form processing if(isset($_POST['update'])){ // pretend there is needed filtering, validation, and escaping logic here... foreach($_POST['price'] as $key => $value){ $query = "UPDATE your_table SET price=$value WHERE id = $key"; echo $query . '<br />'; // show the resulting query } } // form echo "<form method='post' action=''>"; // while(){ // your actual while statement would go here... foreach($fake as $row){ // loop over the fake data in place of the above while(){ loop. echo "{$row['title']}: <input type='text' name='price[{$row['id']}]' value='{$row['price']}'><br />"; } echo "<input type='submit' name='update'></form>";
×
×
  • 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.