-
Posts
5,450 -
Joined
-
Days Won
175
Everything posted by mac_gyver
-
what range of zero count dates do you want to include? the current year? current month? current week? between the lowest and highest dates with count values, and if so, what overall range, because your query could match data from as long ago as you have data stored, 10 years, 20 years? you would typically retrieve the data into an array using the date as the array index, then produce and loop over the date range you want to display, testing on each date being looped over if there is an entry in the array of fetched data, getting it if there is, otherwise displaying a zero.
-
the form processing code and the form should be on the same page, so, there's no 'going back' to the form, because if you need to redisplay it upon validation errors, you are already on the page where the form is. to cause the form to submit to the same page it is on, simply leave the entire action="..." attribute out of the form tag. the form processing code should - detect if a post method form was submitted. keep the form data as an array variable, then operate on elements in this array variable throughout the rest of the code. trim all the input data at once. by keeping the data in an array variable, you can do this with one single line of code. validate all the inputs, storing validation errors in an array, using the field name as the array index. after the end of all the validation code, if the array holding the errors is empty, use the submitted form data. after using the submitted form date (which could cause user/validation errors in itself), if there are no errors, execute a redirect to the exact same url of the current page to cause a get request for that page. if you want to display a one-time success message, store it in a session variable, then test, display, and clear that session variable at the appropriate location in the html document. to allow the user to go to a different page, provide navigation links. if there are errors at step #6, the code would continue on to display the html document, where you would test and display the contents of the array holding the errors, then display the form, populating the form field values with any existing data. apply htmlentities to any values you output on a web page to help prevent cross site scripting.
-
if the rename() call is failing, there would be a php error message. do you have php's error_reporting set to E_ALL and display_errors set to ON, preferably in the php.ini on your system, so that php will report and display all the errors it detects? what is the actual file name used, so that someone could determine if something about it is not permitted or if it's actually being moved to somewhere you are not expecting?
-
all that did was stop the code from being executed, since the form(s) are post method forms and the submitted data will be in $_POST, not $_GET. if you haven't studied (class, book, online tutorial) any fundamentals of php programing, you won't be able to debug any problems in code, nor will you be able to understand and make use of any replies in help forums. what learning resources are you using to come up with this code?
-
Problem allowing users to download files from my website
mac_gyver replied to foxclone's topic in PHP Coding Help
the OP has been told this multiple times. the OP has a database table with the downloadable file information in it and has also been told to use the id (autoincrement primary index) from this table as the value in the link, which can then be validated via a database query, which he/she has acknowledged seeing and has stated will be implemented. -
Problem allowing users to download files from my website
mac_gyver replied to foxclone's topic in PHP Coding Help
i told you to open the downloaded file in your programming editor to see what is in it. whatever you are using to translate our replies into your native language is not working. -
Problem allowing users to download files from my website
mac_gyver replied to foxclone's topic in PHP Coding Help
if you open the downloaded file in your programming editor, you will probably see a clue as to the problem. -
seems like a (trick) question on a quiz? if you can only modify the posted code, the simple answer would be to build each <option></option> list (4 places) with only a single choice, with fixed value (hour/minute) you want, that's pre-selected.
-
I'm encountering an error when creating a multiuser login
mac_gyver replied to Bramdon3000's topic in PHP Coding Help
you easily have 2 times too much typing in that code, and burred somewhere in all that you have a mistake with an else statement. you need to start with the basics and keep it simple. your login system should only identify who the user is, with one session variable to hold the user_id (autoincrement primary index.) it is also not up to the user to specify their role when logging in. aside from a parent registering their children, the role should be determined completely by data stored only within your system. you should query on each page request to find any other user information, such as a username or user permissions/role. here's a list of things that will greatly simply the code and other issues - every header() redirect needs and exit/die statement after it to stop php code execution. don't use $_REQUEST. use the correct $_POST, $_GET, or $_COOKIE variable that you expected data in. don't copy variables to variables for no reason. you should trim() all input data before validating data. validating separate inputs is not mutually exclusive, i.e. don't use elseif. validate all separate inputs at once. after the end of all the validation logic, simply test if the array holding the errors is empty to decide if you are going to use the submitted data. only put try/catch logic in your code for insert/update queries to handle duplicate or out of range errors. in all other cases there's no point in doing this since the user on your site cannot do anything about a database error. don't store plain-text passwords. use php's password_hash and password_verify. simply supply an array of the input values to the PDO execute([...]) specify the default fetch mode when you make the database connection so that you don't need to specify it in each fetch statement. don't use a loop to fetch data from a query that will at most match one row of data. just directly fetch/test the row of data. if you were able to fetch a row of data, you know that the conditions in the WHERE clause in the query are true. there's no point in having logic to test these same conditions. setting regular variables then performing a redirect, does nothing. if you want to display a one-time success message, store it in a session variable, then test, display, and clear this session variable at the appropriate location in the html document. when conditional 'failure' logic is much shorter than the 'success' logic, invert the condition being tested and put the failure logic first. this will make your code easier to read (which will help avoid the current error.) the only header() redirect you have inside the post method form processing code should be to the exact same URL of the current page. this will cause a get request for that page. this will prevent the browser from trying to resubmit the form data should the user reload the page or navigate away from and back to that page. if you want the visitor to be able to navigate to other pages, provide navigation links. you should have a single home/content page. if the current visitor is not logged in, display the non-logged in content. if the current logged in visitor is an administrator, parent, or swimmer, display the the appropriate content. -
these statements are defining filesystem paths. on your development system this results in: SITE_ROOT being set to the folder - $_SERVER['DOCUMENT_ROOT']/job1212 and LIB_PATH being set to the folder - $_SERVER['DOCUMENT_ROOT']/job1212/include on your live site, the full URL of your web site has nothing directly to do with the filesystem paths (the document root value may in fact contain a portion of your domain/account name) that will be used by php to require those various files. what exactly is the filesystem structure within the document root folder on the live site for the main files and the include folder?
-
my 2¢. your offer table should hold the unique/one-time information about each offer. once you have inserted a row of data into that table it should only be updated in the case of a mistake in a value or its status changes, such as being marked as deleted. you need all the raw offer data to be stored in that table, giving you an audit trail, so that you can detect if a programming mistake, multiple form submission, or nefarious activity has inserted an incorrect offer. if a new offer supersedes or modifies an existing offer, that should be handled when the data is queried for or in the processing when it is fetched.
-
Call to undefined function Login_sucess()
mac_gyver replied to Ehsan_collboy's topic in PHP Coding Help
you have actually been give the answer - don't put function definitions inside of other function definitions. -
Call to undefined function Login_sucess()
mac_gyver replied to Ehsan_collboy's topic in PHP Coding Help
some other possibilities - it's conditionally defined - inside another function definition that hasn't been called yet or inside some conditional logic that didn't execute it's not within php tags at all it's using a short opening tag that's not enabled it's within a comment the OP needs to post the complete contents (including the opening php tag in the file) of redirect.php in order to either confirm or eliminate the various possibilities as the cause. -
Call to undefined function Login_sucess()
mac_gyver replied to Ehsan_collboy's topic in PHP Coding Help
@Ehsan_collboywhatever you are using to translate our replies into your native language is not working. 'defined at' in this means location, i.e. what file name is it in? this means how are you getting the function definition into the login.php code? typically, you would 'require' the file containing a function definition into any code that needs to call the function. -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
no one stated that was a solution. just as a test it caused one small part of the problem to no longer produce a php syntax error. if the ?'.'> exists throughout the templates, there's probably a reason for it, regardless of how bad of a reason it is. unless you actually find what's causing the problem and correct it, you will end up wasting a lot of time for nothing. given that you haven't read, translating as necessary into your native language, and followed all the instructions given or answered all the questions asked, i don't think we can help you. -
Call to undefined function Login_sucess()
mac_gyver replied to Ehsan_collboy's topic in PHP Coding Help
your snippets of code do not show us the necessary context that would allow anyone here to help. where exactly is the function defined at and how is it being made available to the code where it is being called? -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
the complete instructions you were given included - doing this will tell you, and us, what the actual run-time value is, which can be different from the php.ini setting. what is the current version you are trying this on? (guessing 8.0 based on the last php.ini path). if/when you down-grade to php7, repeat the phpinfo exercise and actually find the short_open_tag line in the resulting output to see what it is. back to the error and the code in question - that the application gets to the point of trying to operate on the php in a template file means that it has values for those php variables and constant, and the application is not completely broken. the php syntax error for eval'ed code usually states that it is from eval'ed code (don't know if this has changed), so this code is probably being required. php syntax errors in requeued code does run the main code up to the point of the require statement. assuming that nothing has been altered in any code up to this point, in an attempt to 'fix' the current problem, the only way this code could have ever 'worked' is if every instance of the ?'.'> (found in all the short-print tags with a php variable, but not in the short-print tag with a php constant) gets replaced with ?> before it is passed to the php language engine. my guess as to the reason for the ?','> would be that someone passed the template code through a validator and this kluge made it pass validation. the current problem could be simply due to some character matching difference, even the character encoding of quotes inside a string in a file, that is no longer matching the ?','> exactly and is leaving it as is. as a test, i manually changing all the ?'.'> to ?>, there is no php syntax error and the code runs. where exactly are you seeing that error message? is it output on a web page, and if so, what if anything else is output on the page, including in the 'view source' in the browser? OR are you seeing it in an error log file and the web page is blank? is this a public-facing web site that you can post a link to? -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
it apparently is a Chinese developed forum - https://en.wikipedia.org/wiki/Discuz! -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
to check what value php is using for the setting, create a .php script with a phpinfo(); statement in it and see what the line in the output shows for the short_open_tag setting. -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
there is apparently a “full_opening_tag” fixer as part of this tool - https://cs.symfony.com/ as always, make sure you have a complete, verified backup before making any changes to your code. -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
not to the core php language. up to date php5 code, that doesn't use any now removed features, has a good chance of working as is. -
PHP Parse error: syntax error, unexpected '<'
mac_gyver replied to thesunlover's topic in PHP Coding Help
the most likely cause are the short opening <? tags, on lines 1 and 15 in the posted code and everywhere else they are used, being disabled. you can attempt to make this 'work' by enabling them in your php.ini the ideal way to fix this would be to do a search/replace to change all the <? tags, which must be followed by at least one white-space character (which isn't shown on line 15, but then again you didn't follow my instructions for posting the code), but not the <?= tags, into full <?php tags.