-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Edit to the above: I just examined your form code closer and you are using the POST method but you are also building the URL with the data on the end of it, so I am not sure exactly what you are receiving.
-
You can and should test your php code by manually making a URL in your browser's address bar and submitting it - http://your_domain.com/score.php?id=123&rating=456 Only after you have completely debugged your php code should you try to submit data to it using Ajax. You can use a tool like firephp to debug ajax based applications - http://www.firephp.org/
-
Why are you using stripslashes on the data before you use json_decode? You would only want to do that if the data got escaped prior to that point in the code.
-
Edit: I started writing this about 5 replies ago. New lines gotten from where? A keyboard typing into a form? From a copy/paste from a Word document? Also, how do you know the data is - u00a? How are you looking at or displaying that value? Without all your code (the form and the from processing code from the start of the file through to that query) that duplicates the symptom, no one here can directly help you with what could be causing the problem. I could easily name 12 different things that could be altering the data or causing it to be displayed like that, from javascrpt in your form to the database table definition to a browser debugging plug-in, but no one here is going to spend time guessing what your relevant code is, to either eliminate or confirm your code as the source of the problem.
-
Several different points have been discussed in this thread. Exactly which one did you get stuck on when you tried?
-
The mysql DATE type exists for a few reasons. The format used is YYYY-MM-DD (or YYYYMMDD when treated as a number) because that format permits dates to be sorted and compared using greater-than/less-than comparisons. The DATE type also has the minimum storage requirements and it allows you to use a few dozen built-in date functions to operate on dates directly in your queries. You need to get any submitted date into the YYYY-MM-DD format when you put it into a query. In your case, you can get the datepicker to do this for you. You should always validate all submitted data to insure that it is what you expect, in case someone is feeding your script unexpected data in an attempt to trigger errors or to break into your script or database. You can format a DATE type any way you want when you retrieve it by using the mysql DATE_FORMAT() function in your query.
-
Did you configure it to either use a primary dateFormat with a mysql date format or to use the altField with an altFormat with a msyql date format?
-
See Example #3 at this link - http://www.php.net/manual/en/features.file-upload.post-method.php
-
Yes, you can put settings in the php.ini to avoid needing to add lines of code to set them in each individual script.
-
The mysqli->query() method, by default, performs a store_result() (transfers the result set from the database server and buffers it in memory.) There's no point in calling store_result() after using the mysqli->query() method. You also wouldn't use both store_result() and use_result() (leaves the result set on the database server thereby tying up the server and preventing other threads from updating any tables from which the data is being fetched) on the same result set.
-
The session cookie is the session ID cookie, that carries the session id. A secure connection refers to a HTTPS connection.
-
Your posted code works as expected. Did you try just the code you posted to see if it produces the problem? I notice that you are reselecting/redisplaying all the previous form field values except for the two that are not working. Are you sure you are not resubmitting the form after a validation error without selecting a gender radio button and the tos checkbox?
-
See the domain parameter at this link - http://www.php.net/manual/en/function.session-set-cookie-params.php
-
This topic has been moved to PHP Coding Help. http://www.phpfreaks.com/forums/index.php?topic=339910.0
-
There's almost never ever a case where eval needs to or should be used.
-
Specifically - <?php $str="word1-word2_word3 word4"; $str = preg_replace("/([^\W_]+)/e", "ucfirst('\\1')", $str); echo $str; ?>
-
I would use preg_replace with the 'e' modifier to get it to call ucfirst for each word found.
-
Just use an array - foreach($_POST as $key=>$value) { $val[$key] = new validation ($key, $value, $val[$key], null); $val[$key]->validate(); $rs .= $val[$key]->error; } Also, by using eval, you will need to validate all the post keys and values you put into it to prevent php code injection into your script.
-
Since there is no built-in print_array() function, it's likely that your user written print_array() function is wiping out the data. It's also possible that your actual form is reusing those field names (the last occurrence in the form wins) or your actual form is invalid html or you have some php code that is wiping out the values. Without the full code that duplicates the symptom, no one can directly help you find the problem.
-
Skipping over making a connection, if there already is one, isn't relevant to the OP's problem. The code he posted, no matter how many times it might get called within one instance of a script, isn't the cause of the error he is trying to troubleshoot. Your code is also incorrectly using the $db as the 4th parameter to mysql_connect, so multiple instances of your db class within one script will create a new connection every time instead of reusing an existing connection.
-
Database connections within one script that use the same credentials reuse the first/existing connection without making a new connection unless you specifically tell mysql_connect() to make a new connection (see the 4th mysql_connect parameter.)
-
I would add to what the182guy posted. On a live site, you should continue to use mysql_error() to LOG any query errors that are occurring. In a real application, when an error occurs, you should produce and display a USER error message (Sorry, you currently cannot log in to this site due to an error). You should also log all the available information about each error so that you can find and fix what is causing the problem. If you use trigger_error in your error handling logic, php will take the information you supply as the first parameter to trigger_error and produce an user generated error message that includes the file and line number (of the trigger_error statement) that can be logged by setting the log_errors setting to ON.
-
Since most tables would be designed correctly, a majority of the queries would generally need to select all the columns, so a majority of the queries could be written using *. When you need to select only a subset of the columns from your correctly designed table, you would list only those columns. Do what is needed, depending on what data you are trying to retrieve. For those of you with incorrectly designed tables, with images/files stored in the row or tables laid out like spreadsheets or tables with duplicated data in them, don't automatically use * because you will be retrieving unnecessary data that will add overhead to your script.
-
carrying form variables through to a third script
PFMaBiSmAd replied to ikkyopaul's topic in PHP Coding Help
I recommend that you change your UI (User Interface). Rather than typing in each name, you should either - A) Have a dropdown select menu that lists all the current names so that you just pick the one you want, or B) Display all the names at once (or use pagination if you have more than you care to display at one time) with a checkbox (or similar) next to each name so that you can simply go through and mark the attendance for all the students at once, rather than repeatedly going through your set of forms for each student. Edit: I would also just do this all on one page. You select the date (using a date picker) and display and enter the attendance on one page. To allow for the possibly of 'editing' existing information, when the date is changed, I would submit the page (processing any newly entered data) and retrieve and display any existing data for the newly selected date.