-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
Since your question/problem, that you never provided the asked for clarification of, doesn't seem to concern any actual php code, error, or symptom that you want help with, moving this thread to the misc forum section...
-
Programming help forums can only help with specific problems, specific errors, or specific questions. Do you have a specific problem, specific error, or specific question about some php code you wrote? If so, post the relevant code, a statement of the symptom, the error message, or the specific question you want help with. Posting your list of requirements and asking if someone can help, is not a specific question that a programming help forum can or will answer.
-
Your query does not have a FROM table_name term in it.
-
You have a spelling error in your form tags (both the opening and closing tags.)
-
Most cheep web hosts use disk caching to try and get as many accounts onto one server as possible. This caching occurs in the operating system for the files that the web server reads. There would generally be nothing you can do that will affect such a cache, the concept being that you don't use a live server for actively making changes to your site. You only put final/finished code onto the live server. There are many all in one Apache/Php/Mysql packages (xampp by by apachefriends.org is probably the most popular and current) that will install everything you need on a local computer for development purposes. Just make sure that you set php's error_reporting to E_ALL (or even better a -1) and display_errors to ON in your master php.ini so that php will report and display all the errors it detects during development and testing. I also would recommend making sure that output_buffering and short_open_tags are turned OFF in the master php.ini so that the code you develop will work on just about every live server you will encounter.
-
If you want to apply the function to each row of data that is retrieved, of course you would call it inside the loop.
-
The single-quotes around 'Date' make it a string, made up of the characters - D, a, t, and e. You don't put single-quotes around column (or table) names.
-
array_walk_recursive is recursive for arrays. The function definition that you pass it will never receive an array as data, so you don't need the extra is_array logic inside the trim_all function.
-
I believe the form submission on our website has been hacked....
PFMaBiSmAd replied to JenCollette's topic in PHP Coding Help
Here is some code to use. 1) I recommend trimming all the $_POST data at once. This will address arrays in the code and make the code that loops over the data independent of the type of form field. You can either add a trim statement in your existing stripslashes_deep function definition or add the following new code near the start of your code - function trim_deep($value) { $value = is_array($value) ? array_map('trim_deep', $value) : trim($value); return $value; } $_POST = array_map('trim_deep', $_POST); // trim all the post data 2) Replace the existing foreach(){} loop with the following - //process the $_POST variables // loop over all the expected fields foreach($expected as $key){ $temp = isset($_POST[$key]) ? $_POST[$key] : ''; // value or default to empty string if(in_array($key,$required) && empty($temp)){ // a required field is empty $missing[] = $key; // flag the field as missing } if(in_array($key, $expected)) { ${$key} = $temp; // all expected fields are converted to named program variables } } 3) The special handling for an empty $needs array needs to be changed to - //set default values for variables that might not exist $needs = !empty($needs) ? $needs : array('None selected'); -
Get the Temporary Directory of the Uploaded File?
PFMaBiSmAd replied to Glese's topic in PHP Coding Help
You rename the file when you use the move_uploaded_file statement to move the file to the destination. $target would contain the destination folder and the final name for the file. -
I believe the form submission on our website has been hacked....
PFMaBiSmAd replied to JenCollette's topic in PHP Coding Help
As long as $_POST['send'] is set, your code will execute the two mail() statements (which I just confirmed on a copy of the code you posted.) Your code to test for 'required' fields doesn't actually test anything. If no $_POST[some_key] key/values exist, that code doesn't have anything to loop over (it actually just loops once for the $_POST['send'] key/value.) You need to loop over the array of required fields in $required and test if the corresponding trimmed $_POST[key] is empty or not. -
I believe the form submission on our website has been hacked....
PFMaBiSmAd replied to JenCollette's topic in PHP Coding Help
You would need to post the .php code for the page that processes the form data. -
The light-blue number_format text are links to the php manual section for that function. I recommend that you look at the example code at that link.
-
number_format returns the formated string. You are not using the value that number_format returns. Your function is returning the original value that is still in $TotalSalesTax.
-
Your original issue is that you need some white-space after the LIMIT keyword. The additional single-quote that Spring added on the end resulted in an odd number of quotes, which would be a php syntax error. Also, the second number in the LIMIT clause is not the ending row number, it is the number of rows, so, it will remain 30 (unless you want to change the number of rows.) Only the the first number, the starting row number, changes. It's usually less error prone to use overall double-quotes when building a query. You can then put php variables directly inside the query string - $sql_quest = "SELECT id, username FROM user ORDER BY id ASC LIMIT $my_int_value,30";
-
Getting errors when trying to upload an image
PFMaBiSmAd replied to runnerjp's topic in PHP Coding Help
You should not be editing the class code. That makes it 'hard coded' to do only one thing, instead of being general purpose so that it can be reused without needing to edit/test it just because the location needs to change for a different application. -
The first error is because your query failed due to an error of some kind. The second error is because of the first error message being output to the browser. You do need to always have error checking logic for each query statement, not just for development, but for final live code (so that you know if/when a legitimate visitor manages to trigger an error or a hacker attempted/succeeded in breaking into your script.) The following post shows suggested logic to test SELECT/SHOW queries - http://www.phpfreaks.com/forums/index.php?topic=348757.msg1645481#msg1645481 For INSERT/UPDATE queries you would do much the same, but use mysql_affected_rows instead of mysql_num_rows. In the error handling portion of that suggested logic, you can use mysql_error (either echo mysql_error() or use trigger_error) to get php/mysql to tell you why the query failed. However, in looking at your query statements, at a minimum, they are failing because your table and column names are enclosed by single-quotes, which makes them string data instead of table or column names.
-
You need to have php's error_reporting set to E_ALL, not 0, to get php to help you when developing and debugging php code. You also need to have display_errors set to ON (to output the errors to the browser) or log_errors set to ON (to send the errors to the error log file.) Also, which if any of your user error messages are you getting and what have you done to determine where your code and data are doing what you expect and where they are not?
-
There are no actual quotes around the values in the array. The var_dump simply shows them that way to indicate where the string value being displayed starts and stops. There's no need to do anything with the array values to use them. If you were converting to json, you might need perform a type conversion, but it is not needed for what you are showing in this example.
-
If $ID is an md5 value, it is a string and needs to be enclosed in single-quotes in the query statement. If tableID is a column in your table, you cannot use php's md5() function on the value, you must use mysql's md5 function on the value inside the query statement. $query = mysql_query("SELECT * FROM table WHERE md5(tableID) = '$ID'");
-
Best guess is that your code is not putting the correct value in to the $s variable.
-
Getting errors when trying to upload an image
PFMaBiSmAd replied to runnerjp's topic in PHP Coding Help
You supply the path as part of the filename parameter when you call the ->save() method. -
Is that the ONLY form on the page? Also, if the action of that form is login.php, how is that accomplishing a password reset?
-
Getting errors when trying to upload an image
PFMaBiSmAd replied to runnerjp's topic in PHP Coding Help
The name of your form field isn't uploaded_image -
Your 'reset' form is probably invalid HTML. To get help with any code, you need to post enough of your code that reproduces the symptom.