Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,450
  • Joined

  • Days Won

    175

Everything posted by mac_gyver

  1. It's a safe bet that nothing being hosted on or through an amazon web services server should be making requests to your web site. however, doing a whois ip lookup for two of those ip addresses, gives the following information - http://www.whois.com/whois/54.174.55.230 and http://www.whois.com/whois/54.174.62.56 these are apparently for a company named hubspot. those two whois lookups have different abuse contacts. get the whois lookup information for each of the different ip addresses you are getting requests from, then do two things - 1) provide the abuse contact(s) with the ip and datetime information about the requests. they should be able to determine for that set of ip addresses and datetime, what is sending the requests (perhaps they have a bot/proxy running on their system(s).) 2) find the range of ip addresses that each of the ip addresses is part of and assuming you are using an Apache web server, add an entry in a domain root .htaccess file that blocks (deny) requests from that entire range. repeat for any other ranges of ip addresses.
  2. the character-encoding for the first link/page is - utf-16le, which is treating characters as consecutive 2byte/16bit entities. the character-encoding for the second link/page is - utf-8 just changing the character encoding that the first file is saved with may fix the problem.
  3. you are actually doing two things - 1) recording who, what book_id/title they have borrowed/returned, how many they have borrowed/returned, when they borrowed/returned them (not just when they promised to return them.), and 2) being able to track actual inventory of books. before you continue to try and write any code or queries, or do things that other people tell you, which may not take into account all the requirements that only you know about, you need to sit down and do some 'thinking through the problem' and figure out what data you need to record and how you will query to get the results you need. the following is my thinking through this problem, and assumes that you are not going to serially number each book (which you stated in the previous thread that you weren't doing), which would make this like a discrete resource reservation system, i.e. a room booking system. without a serial number for each book, this is like a shopping cart/order system, except that you expect all the items to be returned (or accounted for if not returned.) so, someone visits the library, picks out some number of one or more different books, and goes to the check out desk. this should create a record for this transaction (order) that assigns a unique id, that will be used to refer to everything that's part of this transaction, who the person is, and any other unique information about each transaction. then, for each book_id/title that's part of a transaction, you would enterer a record in a second (order details) table that assigns a unique id (for reference purposes), the transaction_id, the book_id, quantity (i would store a negative quantity when a book is borrowed, a positive quantity when a book is returned, so that you can directly SUM() quantities to find inventory levels), date (or datetime if you are actually using the time part) that the quantity of book(s) was borrowed/returned, a scheduled/promised return by date (or datetime if you are actually using the time part) - this could be different for each book_id/title and could be extended by any amount upon request, and any other information you need for each book_id/title that's part of a transaction, such as status/memo fields. when book(s) are returned by a person, you would enter more records in this details table, using the same transaction id, book_id, a positive quantity, so that they offset the number of books that were borrowed, the date (or datatime) they were returned (the scheduled/promised return date is not used in this case.) the only use of a date (or datetime) in a query would be to find out if any books are over due or to determine when books should be available. to find out what books a person (still) has checked out, you would just query for the data for his transaction(s), group by the book_id and sum up the +/- quantities. to find out the available quantity of any book(s), you would write a query that groups by the book_id, regardless of the transaction, and sums up all the +/- quantiles for each book_id. to record initial books on hand, books added, books lost/damaged/sold, books found by others, ... you would enter records in this same details table, with + or - quantity. the status/memo field(s) would be used to mark the record with this type of extra information about a transaction. if you have any requirements that are not covered by this suggested method, you need to sit down and think through what data you need to store or calculate and how you will query to get the results you need.
  4. a slightly more dynamic slant on doing this - // dynamically build the query string part of a url, from whatever part(s) it is made of - $q = array(); $q['PartID'] = $row['PartID']; $q['Color_ID'] = $row['ColorID']; // add any other key/value pairs here.... $qs = http_build_query($q,'','&'); // build urlencoded query string, with properly encoded & $label = htmlentities($row['PartID'],ENT_QUOTES); // use html entities on any content // this is just the <a></a> link part of what you are outputting, which appears to be incomplete/broken in your code echo "<a href='Part_Color.php?$qs' style='text-decoration:none;'>$label</a>";
  5. for time being, forget about "individually without refreshing the page." you have to be able to write the program logic that does what you want first, and us just posting code isn't going to help you learn how to do that. start by making this all one page, but using just html and php (your page should work, even if someone has disabled javascript - you can output a submit button for your form(s) using a <noscrpt> tag.) then, you can add things like on change events and ajax requests after you have gotten all the code written and working. it sounds like you are making the U part of a CRUD (Create, Read, Update, Delete) exercise. the first step is to define the steps that accomplish the work flow. wouldn't these be something like - 1) list the available stages, with a way of selecting one. 2) if a stage value has been submitted, as a get parameter (you are controlling what is being displayed on the page), (safely) use the value to retrieve the record(s) that match that stage, display them, each as an individual (based on your stated goal) 'edit' form for updating the values. 3) if an edit form has been submitted, as post data (you are altering data values at this point), (safely) use the submitted form data to update the correct record. 4) repeat until you have updated all the records that you want or you pick a different stage value. you would basically use this list as comments in your code and write the code that implements each of these steps of the work flow. the code on your page should be laid out as suggested in this - http://forums.phpfreaks.com/topic/297824-database-issues-and-working/?do=findComment&comment=1519095
  6. doing an exact, equal, comparison with dates doesn't make any sense. would the query you tried match any other row(s) in your database table for that id_item? it sounds like you don't know why you added the start and end dates/times, but whatever reason you have, you would need to make use of <, <=, >, or >= comparisons, not just = comparisons.
  7. the OP should have that already in this table, as this is pretty much just a continuation of another thread - http://forums.phpfreaks.com/topic/298896-pdo-with-array/
  8. i was going to try and provide some specific direction that would help you, but your code seems to be pretty much just a random, changing, collection of things you have seen somewhere. that you now have the code that's running the sql query statement, which isn't even using the same database api as your connection code, and no code to fetch the result from the query, after the form that's trying to use the data, shows that you either aren't looking at what you are doing or you have no idea what the statements mean. so, my only recommendation is - in order for you to retrieve YOUR data from a database or to process the data submitted from YOUR form, you will first have to learn how to do these tasks at all. you need to learn and practice the basics first, before you can do this for your data and your form. you would start by getting the entire process to work correctly for one instance of a form field type.
  9. by the time you get to reading or writing 'code that does something', you need to have already learned the basics of the php/sql languages, so that you can read the code/queries and get the gist of what they are doing. if the book just starts presenting complete code examples, that take more than 10-20 lines to do something, it's not a beginner book to use to learn the php/sql languages or to learn programming in general. if you need to learn the basics of php, to get you to the point of being able to read/understand what existing code does, make use of the php.net documentation. see the 'Language Reference' section, sub-sections - 'Basic syntax' through 'Functions', and 'Predefined Variables', followed by the 'Security', 'Features', 'Function Reference', 'FAQ', and 'Appendices' sections, followed by most of the other sections as you move into more advanced coding.
  10. the reference the OP is using to 'get', is likely referring to his get method code, i.e. the code that's responsible for displaying the page due to a get request (or a post request with validation errors and a need to redisplay the form.) this is about the n'th recent - I have this huge hard-coded form and I need to populate/repopulate the form fields with existing database data/data from the last form submission. if you have a form more than about 3 form fields, you need to use php to DYNAMICALLY produce the form (produce the form field, display any validation errors, populate the field with existing data) and DYNAMICALLY process the submitted form data. for an example showing how to do this, see my posts in the following thread - http://forums.phpfreaks.com/topic/298936-form-data-to-csv-using-php-code-problems/ to populate the form fields with either existing database data or data from the last form submission, see the use of the $data array in that example code and the comment in the code - // get request code would go here... if you are retrieving data to edit/update it, if the $data array doesn't exist at this point, the form hasn't been submitted. retrieve any existing data and store it in the $data array. at the point of populating/repopulating the form fields, you would just use the data values in the $data array. to populate/repopulate checkboxs, you have to output a checked attribute in the <input type='checkbox' ... checked> tag. dynamically producing the form makes this easy, because as your code is looping and producing the form fields, for a checkbox type, you would just test if the existing data for that checkbox matches the current checkbox you are producing, and output the checked attribute at the correct place. using this method, you don't have to write out the program logic for every form field. you only have to write the correct logic one time, for each different type of form field.
  11. the example data record you have shown should have a negative quantity, -11, since those books are checked out/not available. the SUM(quant) in the query should take the original record with 30 books, plus the -11 books checked out by that user_id, giving 19 available books. your separate date and time columns should be one DATETIME data type column.
  12. have you researched what the html syntax is that will cause an option choice to be selected, so that you will know what output the php code will need to produce? after you do that, you will need to write a php comparison statement that tests if there's an existing value from the form and if that value matches the current option choice value, and output the correct html to cause that option choice to be selected.
  13. right before the line with if(mail(.....)){... add the following debugging code - ini_set("display_errors", "1"); error_reporting(-1); echo CNT_TXT_WARNING_EMAILSENTOK; echo CNT_TXT_WARNING_EMAILSENTERROR; exit; assuming you are doing this on a server that allows ini_set() and error_reporting() statements, this should echo the actual corresponding messages without any php errors. if you do get php errors about undefined constants/assuming you meant a string..., it means that your defined constants don't exist, either because your include code isn't working or you don't have defined constants with exactly that spelling/capitalization and without potentially some non-printing/character-encoded characters as part of the definition or usage. lol, while the actual file name you use for an included file doesn't matter, why are you still using something like .php3 at all?
  14. here's another problem with your code - ...WHERE username = '$session->username'"; a username can be anything that you allow when the user registered, so, something like D'Angelo is possible. this will break the sql syntax and cause a query error. if someone is logged in, their username should only be used for display purposes. you should be using an integer user_id internally in your code. using an id will also make your queries faster, for a couple of reasons - the id column should be defined as an auto-increment column, this will/should automatically make it an index, and finding an integer value, either in the data or in the indexes, will be faster than finding a string, unless you use very short strings.
  15. ^^^ that appears to be what i surmised. please reread my reply in this thread. you may want to read my reply at the end of your last thread, where maintaining a count in a column can have race conditions that cause data to be lost, and the suggested methods to prevent this.
  16. i recommend that the OP reread (some of) the replies, particularly post #8 (that change applies to both of the statements you have in your code), and the suggestion to please post your current code where the header() redirect statements are at.
  17. @shan, that has nothing to do with any problem in this thread. the OP is already testing a form field that will always exist if the form has been submitted.
  18. that's because the syntax/code that shan posted is incorrect. the correct syntax is what Barand showed in post #8. please post your current code where the header() redirect statements are at.
  19. it would help if you state what it is actually doing, and where it is doing it. if you are only getting part of the message or it is being stripped of any non-ascii characters on the page that the header() redirect goes to, it's probably because you need to use urlencode() on any data you pass through a url
  20. edit ^^^ i'm not trying to write same/similar posts as you, but when i'm logged in, i cannot see (if not logged in i can see) the info at the bottom of a thread that says who, if anyone, is already viewing it and would potentially write a reply. you are apparently asking how to form a column name based on a numeric value, i.e. cn1, cn2, cn3, ... having a series of numbed columns is a bad database design, requiring extra php code and extra queries to just manage the data. whatever this represents either needs to just store the current value (which is what the pad_count already is) or you need a separate table to hold the key/value pairs.
  21. mysql_real_escape_string() requires a database connection to work. therefore, you are getting a null value in $score and should be getting several php error messages. so, three problems - 1) you need to have php's error_reporting set to E_ALL and display_errors set to ON in the php.ini on your development system so that php would help you by reporting and displaying all the errors that it detects. you will save a ton of time. 2) don't use any database escape string function until right before you put data into your sql query statement (it's actually better to use prepared queries anyways.) 3) the msyql_ functions are obsolete and will be removed from php soon. you need to learn using the PDO (the best choice) or the mysqli_ database functions so that what you are learning isn't already out of date.
  22. ^^^ and tell use what exact symptom or error you get that leads you to believe these 'aren't working' and do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would help you by reporting and displaying all the errors it detects? some possibilities - your files either got altered and now have a BOM character saved with them or a .htaccess file or local php.ini file got deleted that was setting some php settings (output_buffering, upload size settings) that are now no longer in effect and are preventing your code from 'working'.
  23. we only see the code you post. it is not missing a ; and does not throw a php syntax error due to that. if you set the php error_reporting/display_errors setting as i suggested, in the php.ini file, and confirmed that the actual settings got changed to those values, you would have been getting a php syntax error at the missing ;
  24. i'm going to guess that the value in your $id_itens variable actually contains double-quotes around it. if you are using print_r($id_itens) and it produced "11" in the output, the only way that can happen is if there are double-quotes in $id_itens. $var = 1; print_r($var); echo '<br>'; $var = '1'; print_r($var); echo '<br>'; $var = "1"; print_r($var); echo '<br>'; $var = '"1"'; print_r($var); echo '<br>'; output - 1 1 1 "1" instead of print_r(), use var_dump() as it also gives the length of whatever is in the variable. so, what is your code that is producing $id_itens?
  25. about the only remaining thing that could be causing this symptom, is if there's a file naming (capitalization matters on a case-sensitive operating system) or permission problem and the web server cannot find or access your file, combined with something preventing a http 404 or related error from being output. check the web server access and error logs to see if there are any errors that correspond to you requesting the file in your browser. this also raises a question, what url did you use in your browser when you requested the page containing the php code with the phpinfo(); statement in it? it should have been something like http://localhost/yourfile.php if nothing else, start over with a new file, with just <?php echo 'something here'; ?> in it, save it to the document root folder, and enter the url, http://localhost/your_filename_here.php in the browser and see what you get. short-answer - this is not that difficult. if you have one .php file that works, but others give no output from the php code and no php errors, there's something you are doing differently between the files that isn't correct.
×
×
  • 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.