Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,510
  • Joined

  • Days Won

    185

Everything posted by mac_gyver

  1. one example would be so that each user could have his own settings.
  2. not if the values are dynamic, such as custom styling stored in a database and are being retrieved using php code.
  3. just telling us that something you are doing is not working, doesn't help us to help you. you haven't even posted your code that is linking/including the .css file, so we have no idea what any of your code is doing. when you browse directly to the .css file, is the output in the browser what you expect?
  4. based on your other recent thread about including a file containing your connection, you are apparently now calling a 'connect_db' function inside of each of your database related functions to open a connection and based on post #8 in this thread, closing that connection after you use it each time. that's most definitely NOT how to manage a database connection in your application. creating a database connection takes a significant amount of time, so of course your code is noticeably slow. the correct method is to create one database connection in your application code and pass it into each function that uses it. you would normally pass this in as a call time parameter, in the same way that the procedural mysqli_ functions accept the mysqli connection as the first call-time parameter in any function that needs it. there are other methods to pass a database connection object into functions, but they are not general purpose.
  5. what significance is there to what box any item is located in? isn't it enough that you have an item in your inventory?
  6. is your query that gets the total number of matching rows that goes into producing the number of pages also using the same JOIN?
  7. if you have a form with more than about 5 fields in it, you would want to dynamically produce it rather than typing-out/copy-pasting code 50 times. you would define the fields somewhere (array, database table) and use php code to produce the form by looping over the definition.
  8. the basic logic would be - <?php $infile = 'in.csv'; // a file for testing only $csvfile = 'out.csv'; // another file for testing only $tempfile = tempnam(".", "tmp"); // produce a temporary file name, in the current directory // modify the values to match your data structure define('IN_SKU',1); // define the offset of the incoming sku column define('IN_QTY',2); // define the offset of the incoming quantity column define('OUT_SKU',1); // define the offset of the outgoing sku column define('OUT_QTY',2); // define the offset of the outgoing quantity column // read incoming sku/qty if(!$handle = fopen($infile, "r")){ die('could not open incoming file'); } $in_data = array(); $header = true; while(($data = fgetcsv($handle)) !== FALSE){ if($header){ $header = false; continue; } $in_data[$data[IN_SKU]] = $data[IN_QTY]; } fclose($handle); // process data, updating the quantity with any incoming quantity if(!$input = fopen($csvfile,'r')){ die('could not open existing csv file'); } if(!$output = fopen($tempfile,'w')){ die('could not open temporary output file'); } $header = true; while(($data = fgetcsv($input)) !== FALSE){ if(!$header && isset($in_data[$data[OUT_SKU]])){ $data[OUT_QTY] = $in_data[$data[OUT_SKU]]; // modify qty if exists in the in_data } fputcsv($output,$data); // write the line to the output $header = false; } fclose($input); fclose($output); unlink($csvfile); rename($tempfile,$csvfile); echo 'done';
  9. here is how i would do this - 1) open and read all the "in" data into an array with sky as the index/key and the quantity is the array value. close the file as you no longer need the file handle. 2) open the existing "out" file for reading and open a temporary file for writing. 3) in a loop, use fgetcsv to read each line from the existing "out" file into an array, one line at a time. using the sku element of this array, get the quantity from the array made in step #1 and store it to the correct quantity element of the current line's array. write the array to the temporary output file made in step #2. 4) when done looping through all the lines in the existing "out" file, close all open files and if there have been no errors, delete the original "out" file and rename the temporary file to the original "out" file name.
  10. you can save all the data using one statement - $_SESSION['post'] = $_POST; you would reference any specific value using - $_SESSION['post']['windows']
  11. i've looked at your code and all the form elements in the repeat section need to be made into arrays - i.e. add [] to the name = " ... " attribute. name="product_name" becomes name="product_name[]" this will submit an array of data for each field that you can loop over in the server-side code.
  12. unfortunately DreamWeaver must have thought it would be funny to put part of the sql syntax in with the data values and part of it in the actual sql statement. you need to remove the single quotes from round the %s that are in the sql statement or stop using DreamWeaver's functions in your code and write you code yourself. the direct answer to your title is don't depend on DreamWeaver to write code for you. programming is a 'brain-on' activity. you must know the meaning of every character that is in every line of code. what it means, why it is there, and how it contributes to the goal your code is trying to achieve. the reason only the last set of data from the form is inserted is you have no server-side php code to do anything but to insert just one row. i'm not even sure your client-side code is producing anything that you could loop over. your first task would be to debug and make sure your client-side code is sending the data you want. add the following debugging code in your server-side script to display what is actually being submitted - echo '<pre>',print_r($_POST,true),'</pre>';
  13. what have you done to troubleshoot the problem? what does $_SESSION['security_code'] contain?
  14. in one of the other help forums where you posted this, someone showed you specifically how to reference the ['browser'] field of the array. exactly where are you stuck at in doing this basic task? what have you tried?
  15. php dynamically produces dynamic web pages. so, yes, if you want to style the output that php produces, you use css, the same as if you weren't using php to produce the web page.
  16. you need to target the method being used to post the spam. i.e. make it easy for your actual members to make legitimate posts. make it harder for the spam to be posted/displayed. if you allow unregistered/unlogged in guests to post (i.e. a shout-box, comments without first having an account), of course you will get 1000's of spam posts. only registered/logged in members should be allowed to post anything. if this is occurring from your registered/logged in users, you need to disable their account as soon as possible after they begin posting spam. if it is too easy to register new accounts, you need to make it harder to use automation to create new accounts. the registration must be verified via a link sent to the supplied email address and you must have a ban system that can ban specific accounts, email addresses, and ip addresses or address ranges. next you need to target the specific form that the spam takes. if the spam are links and/or keywords, you need to add a module that prevents posting links by members that don't have some minimum number of posts and a module to detect/filter common spam keywords. if the problem is so bad that a large percentage of new accounts are spammers, you need to (at least temporarily) fully moderate (don't display the comment until approved by a moderator) all posts for all members that don't have some minimum number of posts. i'm sure there's some module that does this.
  17. php is a web server scripting language. you must have a web server installed (Apache is the easiest to use) and php installed on the web server. there are all in one packages with Apache/php/mysql bundled together that you can install on any current computer.
  18. your code has a fatal parse error/syntax error (all syntax errors are fatal and your code doesn't even run) on line 22. if you look at line 22 you can probably figure out what is wrong with it. before you spend any more time working on your code, do yourself a favor and set php's error_reporting to E_ALL and display_errors to ON in your master php.ini so that all php errors will be displayed. you will know if these settings are successful when the code above produces output like - Parse error: syntax error, unexpected '{' in your file name.php on line 22 lastly, the mysql_ database library is not recommend for new code (its being depreciated, soon to be removed) and all new code should be written using the mysqli or pdo database libraries so that you don't need to rewrite your code in the future when the mysql_ functions are removed from php.
  19. sans means without.
  20. the problem is that your table name contains a special character that makes it look like it's a subtraction problem. A) you should not use special characters in a table/column name unless you know how you would make it work with that special character in the name. B) you should NOT make a separate table for each user.
  21. the current error is because mysqli_error( ... ) requires the mysqli connection resource as a parameter.
  22. the OP's code is pretty much just some thrown together gobbledygook that doesn't search for what was entered or output anything at all even if it found it. even the 'pagination' isn't using pages.
  23. if you test your query you will find that date values the same as $to_data with times greater than zero on that date are not matched. the code that barand gave you using date(created) BETWEEN '$from_data' AND '$to_data' is what you should be using.
  24. this thread reads like the page is being requested twice, once with and once without the get query string on the url or you have multiple different included/required files floating around. posting your entire form page would help (javascript/jquery you have on there could be doing this) and post the current php code. how exactly are you viewing the csv output that is showing the dates in the 05/03/2011 format? setting php's error_reporting to E_ALL and display_errors to ON may also help with the debugging.
  25. you must condition/validate/limit all external data before using it. in the case of a negative page number, that passes through the math in your code and produces a negative starting row number in the LIMIT clause, which is invalid and produces a query error. since the query doesn't run at all, you are getting an error when you try to use the fetch statement. this also indicates you don't have any error checking logic for your query. if your query fails with an error, don't continue running code that tries to use the result from the query. you need to insure that the page number is greater then or equal to 1 and you should also insure that it is less than or equal to the maximum page number (this condition won't produce an error, but the query won't ever return any rows.)
×
×
  • 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.