Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,370
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. unfortunately, some versions of browsers (IE/Opera for one) have/had this problem. this can also occur when submitting the form via javascript. the submit button isn't a "successful" form field when the the form is submitted by means other than clicking on the submit button and the submit field isn't included in the form data. in those cases where you need to identify which of multiple possible forms was submitted, using a hidden form field or testing for a field name that is always submitted addresses a type = submit field that may not be sent with the form data. also, unfortunately, the OP's code in this thread was using name='login' in the form, but was testing for isset($_POST['submit']) in the php code.
  2. it's not really possible to program by randomly putting things into your code. you must know what each line of code does, so you will know how it contributes to what you are trying to accomplish, know if it even belongs in the program, and know where it belongs in the flow of the program logic. the code you posted in reply #3, was using the CheckPassword() method in the correct logical location and you were including the PasswordHash class definition in the correct logical location, relative to trying to use it. you were however missing the line that created an instance of the PasswordHash class and you were using the wrong php variable as a parameter when you called the CheckPassword() method. everything you changed after that point, from where you added it, to adding a call to the HashPassword() method (hashing the password is done when the password was stored during registration, not when trying to log in) makes it appear that you are not even looking at what you are doing, similar to trying to put together a jig-saw puzzle without looking at the picture on the box and what portion of the picture is on the piece you are trying to find a location for. so, best advice, slow down, actually learn what each statement does, look at and think about what your code is doing at each step, so that you can put in other statements at the correct place so that they will have meaning for what you are doing.
  3. the correct logic to check the password is to call the CheckPassword() method (after you have created an instance of the PasswordHash class in $hash_obj), with the correct values. in your code that had/has this call, the second parameter you are using was/is $stored_hash. however, there is no variable $stored_hash in your code. your code is using $password_hash. beyond this, due to the number of changes you have made to the code, if you cannot get it to work, post your current code. btw - php has built in password hashing functions - password_hash()/password_verify(), that you can/should use instead.
  4. have you done any debugging to make sure that the $_FILES data is what you expect? also, there are at least three problems with what you are showing use in that code - 1) you should validate that input data exists and is what you expect before using that data. your code should never get to the point of running a query unless you know you should be running that query. 2) isset($_FILES["fileField"]) that $_FILES element will be set, even if there is no valid uploaded file. if a user doesn't select a file and likely for some of the possible upload errors, what you are testing in the isset() statement can be true, but the ['name'] element that you are using can be empty. this is actually related to the above item. you shouldn't be testing for data at the point of using it in a query. by the time you get to the point of forming and running the query, you should have already determined if there's data present. 3) "all other text fields update fine". unless you removed lines of code from what you posted, that implies you are repeating similar code for each field and are running a separate query for each field. that is a database killer. you should update all the fields using one query (note: if none of the values being updated have changed, mysql doesn't actually update the record.)
  5. without knowing where and how this is being produced, where and how you are viewing the incorrect value, and what sort of processing might be occurring between those two points, it's impossible to tell. could be due to a programming problem changing the value or copy/pasting part for that value from somewhere that has some character encoding that looked correct where it was copied from, but isn't actually the charters they appeared to be or some type of character encoding issue with the method you are using to view the value.
  6. since the output, that's causing the problem, is occurring on line 1 of the file and the only php code on that line is the php tag, you either have something in the file before the php tag or your file has been saved with utf-8 encoding and the BOM (Byte Order Mark) characters by your editor. insure that there's no characters before the first php tag and insure that your editor is saving the file without the BOM characters.
  7. this is some confusing code and probably doesn't work because the output being produced is not valid. the markup you are producing, particularly the javascript, is being repeated for each main row you are looping over. you need to separate the concerns/responsibilities in the code. the data retrieval logic should all be together, come before any markup, not contain any html/javascript/css markup, and just store the retrieved data in a php array. the code building the page, starting with the <!DOCTYPE ... tag, should just take the data from the data retrieval logic and loop over it as needed to build the sections/views on the page. the things that only exist ONCE in the markup, such as the jquery javascript <script> ...</script> tags, should not be inside of any loop. next, you should never run database queries inside of loops. the data you are retrieving is related, as in the R in RDBMS. the correct way of retrieving related data is to run one query that JOINs the tables to retrieve all the related information at once. and here's the most confusing part from your code (we only see what you post, so it must clearly tell us the story of what you are doing), you are looping over the result from each of the queries, but i suspect that each query, except for the main one, only matches one row? OR can there be multiple timesheets per workorder, based on what appears to be a variable for totaling the time? you should also be using css instead of inline styling and the msyql_ database functions are obsolete and will be removed from php in the not to distant future. you should be switching to either the msyqli_ or PDO database library of functions (having all your database retrieval logic together, on in your case, where you should only have one query, will make switching to a different set of database functions easier.) in short - run one query that gets the data you want, retrieve and store that data into an array, then, in the code that's producing the page, loop over the data, building the markup needed to display that data. this will reduce all your code, make it easier to debug each concern/responsibility (which makes it easier for us to produce test data if we need to run your code to help with it), and make it clearer to us what you are doing.
  8. once you get past the query errors (see Barand's reply #5), you are using the page part of pagination incorrectly. the logical page number from the link - 1, 2, 3.... needs to be converted to the offset value for the query statement by subtracting one and multiplying by the rows-per-page/limit value. since the offset value is now a calculated value, it doesn't need to be a bound parameter in the query statement. likewise, if the limit value is defined in your php code, it doesn't need to be a bound parameter.
  9. you need to use dates with a YYYY-MM-DD format, so that you can do greater-than/less-than comparisons. your dates should be stored in the database using a DATE data type, which will give them that format. this will let you retrieve only the rows that have a start to end date range that matches the year-month you are trying to display. next, just store the retrieved data directly in one php array, with the id, start date, and end date. as you loop over the days in a month to display the calendar, you will form the current date with a YYYY-MM-DD format. for each day, you will then loop over the array of data and retrieve the id(s) where the current date is between the start date and the end date. edit: an alternate method would be to expand the start date to end date into individual dates within the range and for those dates that correspond to the year-month being displayed (dates before and after the current year-month would not need to be stored), store the id as an array element for each day, using the date as the main array key. this would result in an array that looks like - $array['2015-06-01'][] = some_id; // some_id is booked on the 1st and 2nd of this month $array['2015-06-01'][] = someother_id; // someother_id is booked on the 1st of this month $array['2015-06-02'][] = some_id; as you loop over the days in the month, just loop over any sub-array of id's, if present, that have a main array key matching that current date.
  10. sorry if this is all negative, but the php coding help forum section is for getting help with code you have written. the application related help forum sections all have sticky posts/rules about not posting requests looking for specific applications. the main reason that programming help forums are not good at finding things for you is because we don't know your requirements or your coding skills. the only person who will know if an application meets your needs or if it is simple enough that you will be able to troubleshoot it if it doesn't work, is you. if you have a problem with a php application you have found, that you cannot solve yourself, you either need to ask for help on the author's web site, or you can post in the phpfreaks third party php scripts forum section, but since we are not likely to have specific experience with any particular script (and you won't be able to post copyrighted code anyway), we can only offer general troubleshooting help.
  11. in programming, a simple typo in a variable name, can cause your program logic to loop forever, because the code is no longer testing the correct variable. if you cannot find the problem in your code that is causing this, you will need to post the code that reproduces the problem.
  12. @ the OP and for all the other current threads where all that is being posted is an urgent list of what you want. a list of what you want is nice start for a RFQ (request for quote) to hire someone to do this for you. it is not however what programming help forums are about. programming help forums are not free programming services. they are also not for getting unpaid research assistants to find things for you. they are for getting help with specific programming questions (how to create an entire application is not a specific question) or getting help with problems and errors in code you have written. the internet was created for publishing and researching information. everything you are currently doing has been done before, countless times. there are literally 10's and 100's of thousands of code examples posted on the internet showing how to use php to dynamically create forms, test for and validate submitted form data, create database connections, insert data into a database, retrieve information from a database, update information in a database, and delete information in a database. if you haven't found code examples that do what you want, you haven't done your part researching the information.
  13. the other thread about retrieving data based on an input id, is just the first step in the U (update) part of a CRUD assignment. this thread seems to be asking about a part of the same U process, but skipped the first step of retrieving the existing data to populate the form fields. this looks more like the C (create) form was just dumped here without having any code to populate it with existing values.
  14. unfortunately, someone in one of the OP's other threads made a suggestion that would have produced a trimmed copy of all the input data at once, and paved the way to processing all the form values as a set, instead of writing out repeated code for each separate input value -
  15. this sounds like another current thread, where someone just posted what they want and expected someone to do everything for them, especially since the OP in this thread is copy/pasting this question on multiple help sites. first of all, your question about how to do this task isn't a mysql database question. you may be using a mysql database, but until you have a sql query statement at all, you don't have a mysql database problem. next, processing form data and retrieving and displaying database information is what php was created to do and there are 100's of thousands of examples posted on the web for you to find, examine, and learn the basics from. in short - where exactly are you stuck at when you tried to do this? programming help forums are not here to find, give, or write code for you. without knowing what sort of problem you had when you tried this, the answer could range from a) you need to buy a good php/mysql book and/or take a programming class to z) you have a logic or syntax problem in your code that we could help with if you posted your code and told us what sort of error or symptom you got from that code.
  16. sounds like the OP just wants someone to do his or his group's assignment for him/them.
  17. until you execute() the query, there's nothing for rowCount() or fetchAll() to use and are likely throwing php errors. also, why are you using a prepared query when the sql statement doesn't contain any input values? did you actually write this code or copy it from somewhere? i ask that because i reviewed two of your older threads that also use PDO statements and you previously got the prepare/execute/rowcount statements in the correct order for a SELECT query. programming requires that you actually learn what each statement does so that you can put them together in a meaningful way each time you use them.
  18. any particular web hosting may have restrictions on how to send email through their mail server (and may not even supply a sending mail server, your friend that can send emails may be sending them through some other mail server.) what is your free web host's name and have you checked their FAQ section on sending emails? common problems would be a mail server that's set up to require smtp authentication or problems with the From: address (or lack of) being used in the email headers.
  19. different flavors, colors, or sizes of something are different things, each with a unique id.
  20. the first error is because there is no ?id=value present on the end of the url when you requested the page and $_GET['id'] doesn't exist. for variables that may not exist, you need to test if they do exist before referencing them. php has a function, isset() that can be used for this. the second error is actually related to the first one. without any id value, the sql query statement becomes "SELECT * FORM article WHERE id=" which is syntactically incorrect and produces a query error. if you had error checking logic in your code (which you should always have) to test if the query ran without any errors, you would be getting a mysql error at that point in the sql statement. you also have a typo in the FORM keyword in the sql statement. it should be FROM so, two recommendations - 1) for variables that may not exist, test if they are present before trying to use them, and if they don't exist, take an appropriate action, such as not running the code that's dependent on the variable existing. 2) always test for database query errors before trying to use the result from the query. and related to this, even if the query runs without any errors, it may not match any rows in the database table. you should also test if the query matched any rows before trying to fetch and use the data from the query. edit: as an additional note: all external data cannot be trusted. you must validate not only that it exists, but that it contains an expected value or that you render any nefarious value in it, inert. edit2: and you should also test if the database connection and select_db statements worked (you can select the database at the same time you make the connection.)
  21. 1) for the user email, how do you know it doesn't work and what part of it doesn't work? your statement could mean anything from a php error at the mail() statement, to the values being missing in the message or the link not being a clickable link. you should also be testing the value returned from the mail() function call and logging your own error message if it is false (you should also have php set up to log all the php detected errors.) 2) for the $email_user variable, your code is setting that from the result of a SELECT query statement. it will be a result resource if the query ran without any errors and a false value if the query failed due to an error, which since the query contains an sql syntax error, will currently always be a false value. is the $email_user supposed to be the $email variable already present in the code or are you trying to retrieve something from the SELECT query? if you are trying to retrieve something from that SELECT query (that you don't already have present in the code), you will need to fetch the row that the query matched before you can reference the values in the php code.
  22. actually, the OP is triggering the error with an intentional typo in the file name. not sure what the question about this is, but the first message, the Warning, is because the file could not be found. the second message, the Fatal error: is because a require()/require_once() statement that fails also throws a fatal run-time error.
  23. where exactly are you stuck at when you tried to do this? programming help forums are not here to find, give, or write code for you. without knowing what sort of problem you had when you tried this, the answer could range from a) you need to buy a good php/mysql book and/or take a programming class to z) you have a logic or syntax problem in your code that we could help with if you posted your code and told us what sort of error or symptom you got from that code. the thing you stated you want, will require that you lean enough html, php, and mysql to do the following steps - 1) create a form or link(s) that let the user pick which item he wants, that submits the corresponding id value as a get request to the display page. 2) on the display page, detect and validate the id value that was passed in the get request. 3) create a database connection, checking for connection errors. 4) form and run the sql query statement to retrieve the correct row using the submitted id value, protecting against sql injection in the id value and checking for query errors. 5) check if the query matched a row and if so, fetch the row. if not, display a message to the user. 6) if a row was found, display the data from the fetched row the way you want it to be displayed.
  24. at this point i don't think we know what exactly you have or what's being ran. you stated you installed xampp and Vertrigo. afaik, those both would have attempted to install Apache/Mysql/Php and either would have produced installation errors or perhaps installed two different apache/mysql servers using different port numbers. when you are running the phpinfo(); statement to find the php.ini and the mysqli information, how exactly are you invoking the .php script containing the phpinfo() statement? through phpdesigner or are you using your browser with a url something like - http://localhost/your_php_file.php ?
  25. actually, if your UPDATE query contained another SET term of - user_id = LAST_INSERT_ID(user_id), your second query of SELECT LAST_INSERT_ID() would return the user_id value. edit: and you don't actually need to explicitly run the second query, you can just call the lastInsertId.. function/method of whatever php database library you are using.
×
×
  • 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.