Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,356
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. you would write a SELECT query to retrieve the password field, FROM the correct table, WHERE the username is equal to = the posted username, applying either your database library's string escape function to the posted username or using a prepared query, to prevent errors or to prevent sql injection. if that's a little less than you expected, it's because what you are asking, form and run a query that retrieves a specific column from a specific row in a database table, is a basic skill that you need to learn first, before you can attempt to do it for your data.
  2. the array that the database retrieval code is storing the results into is $products. if 1077 is the index value that corresponds to your SMX 800E example, you would use echo $products['1077']; this is why copy/pasting code is not learning. the code that gets posted is only an example to look at, and in just about every case is untested, and can contain syntax errors, hastily typed variable names, logical errors...
  3. @asif456, this is why programming help forums are not here to find or to give you programming related things you want or need. we don't know exactly what you are looking for, nor do we know your level of experience and understanding. programming help forums are for helping programmers with code they have written. topic locked.
  4. but, to get the prices from a database table and list them for all the products on the page, YOU WILL BE CHANGING THE ENTIRE PAGE. you might as well dynamically produce the page and save the time it would take you to add php code in 40+ places on the page.
  5. the http response for the download request must only consist of the header statements and the content of the file you want to download. what you are seeing in the downloaded file is the content of the file and the html that's being output on your success.php page, making the file invalid.
  6. in your download.php code, you would also need to verify that the requested file belongs to the logged in user.
  7. in your code, $results will be an array, not an object. if you use echo '<pre>',print_r($results,true),</pre>;, you can see what the structure of the array is.
  8. it would be up to you to find code examples at your level of understanding. all a blog is, are - forms, form processing code (that stores submitted data in appropriate database tables), navigation/search/sort code to list or limit entries and pick display order, and code to retrieve/display the correct contents from those database tables in the correct order. you would also need a log-in system with access permissions, to control who can access the forms and the form processing code, a lot of validation and security to prevent nefarious visitors from doing things they shouldn't or to tell legitimate visitors what was wrong with what they did so that they can correct it, and error checking logic on everything so that your code will let the visitor know when the site isn't going to produce any result and to log (or display during development) all the information about each error so that you can find and fix problems.
  9. so, you used a site/form creator that includes ads as part of its terms of use and you are trying to fix your site that broke when you attempted to get rid of the ads? it's not the purpose of programming help forums to help you bypass or disable features of software that you agreed to when you used that software. topic locked.
  10. there's no limit to the number of terms you can have. as pointed out, you likely had a typo and as also pointed out, you don't (ever) need to write out a statement that has that many terms in it.
  11. the particular message occurs when your massive isset(...) && isset(...) statement is false. the purpose of that statement is (should be) to test if a form was submitted. it doesn't need to test if every field is set, because all text/password/textarea fields will be set. so, just test if one field isset(), such as a hidden field that identifies that your registration form was submitted, which is what the $_POST['reg'] appears to be for. next, DRY (Don't Repeat Yourself.) You have a ton of code repeating the inclusion of the header/footer files. You should only have those ONCE. lastly, you should validate all the inputs at once and output all the errors at once so that the visitor doesn't need to repeatedly submit the form to find out each error in turn. your elseif() logic validating different fields should be completely separate conditional tests. to accomplish validating all the inputs at once, you would make an array to hold the error messages and then simply test if the array is empty at the end of all the validation. if it is empty, no errors. if is not empty, loop over the elements in the array and echo them to display the error messages.
  12. the answer to your question of can you use the logged in username (you should actually use the user's id, an auto increment column in your user table that corresponds to the user name, since this will be much faster than using a text string in queries. this is the id that trq mentioned in the first reply in this thread) as a filter in a query is yes, but this does require that you understand some basics about php, such as php variables, and to understand something about the code you are using, so that you know at what point in that code a variable exists. if your login script, which i am assuming is accessed via the session.php file, makes $login_session available, then you can only use $login_session after the point where you have included session.php. you have mentioned 'in dreamweaver' a couple of times. you do know that dreamweaver is just a tool, and a poor one when it comes to server-side php code. you should not be relying on a tool to do your work for you. a tool is something that you use to accomplish a goal.
  13. post the error message you are getting and post an example of an input data value causes the error.
  14. the reason for the error on the mysqli_fetch_all() is because it's another one of php's screw-ups that is only present in a specific case that you won't generally have any control over.
  15. are you 100% sure that the fetched array contains this 'missing' row? there are two possibilities - 1) you query is not matching that row, possibly because the where clause is false 2) your php code, doing things like testing for empty() values is skipping the display of that row, because an element of that row or of the join with the contact information resulted in empty or null values. if that row is in your fetched array, what does using var_dump() on that one row show?
  16. the syntax error is because your source code contains an error. you are using the Ternary operator on the line where the error is being reported. the Ternary operator doesn't use an if(). next, the best, general purpose method to use to highlight/change words in text, based on database entries would be - 1) get a unique list of words from all the content you are going to display on the page. this would require that you retrieve the rows from your pagination query. if you store these rows into an array, you can simply loop over this array later when displaying the information. as you are retrieving the rows from the pagination query, split them on the white-space/word boundaries and add all the words to an array. then use array_unique() to reduce this array to just the unique list of words. 2) using the unique list of words from step #1, run a query against your banned word table to get just the entries from that table that are found in the unique list of words from the content. you can implode the unique list of words and use WHERE word IN('word1','word2','word3', ...) comparison in the query. 3) retrieve the list of matching bad words into an array, then when you have the full list, implode that array using a | character. this makes a regular expression OR'ed pattern of all the found bad words. 4) as you loop through the content (the first array from step #1) to display it, you can use a preg_replace() statement, with the regular expression pattern from step #3, to find and replace any bad words with the replacement string.
  17. ^^^ except that the stated age of something depends on if the birthday has or has not occurred yet in the current year. the age is the difference in years, subtract one if the month and day are less than the current month and day.
  18. you have got to be kidding. since your only purpose here is to get someone to do this for you, topic locked. i recommend that you post in the freelancing/job offers forum section and hire someone to do this for you.
  19. parse errors that show up when moving between systems are usually due to using php's lazy short open <? tag, that's not portable between systems since it relies on a configuration setting, instead of using full opening tags <?php
  20. apparently, your Windows system has php4. the things you are trying to use, mysqli and PDO, were added to php in php5 and only exist in php5. if you are not going to use the at least the same MAJOR version of php that you used to developed your code, you shouldn't expect your code to run.
  21. the last ever update of php5.3 was just released. you should be using the latest php5.5 or 5.4, especially if you are learning php.
  22. the code base you found to use for your game is poorly written and NOT documented. it was originally written as part of a classroom assignment to learn basic programming, queries, and problem solving. it's not how a game would be written because it's not efficient , not organized, not secure, and doesn't use any 'best methods' of programming or html design. and since there's no useful comments in it, we don't have any idea which code is executed when "you get caught committing crimes such as stealing cars". in fact, there's noting in that code that contains any of those keywords in variables, queries, or comments. so, does the code you posted even contain any of the code that gets ran as the result of getting caught committing crimes? if YOU cannot determine and tell us which section of that code is the relevant section that is ran when "you get caught committing crimes such as stealing cars", WE cannot help you.
  23. no one here is going to try and figure out nearly 1300 lines of code, half of which is careless blank lines. you are going to have to at least narrow down the problem and post just the relevant section of code. i recommend that you start by looking for the correct rand(...) statement(s) that are involved with the action(s) you are asking about. once you find the correct place in the code, i recommend that you create defined constants or php variables that define/hold the values and put these values into a configuration file that gets included or in a settings database table that gets queried so that any time you need to make a change like you are asking about, you can do it in one consolidated place and not have to find and edit the actual code responsible for carrying out the operation. just about every hard-coded number in the code now, that determines a level, a reward, a random value, a time,... should be pulled out and made a defined constant or a php variable.
  24. your page controller is using a get parameter pg=file. the pagination logic is adding its own page and ipp get parameters. the easiest way of letting each different piece of your code independently manipulate the get parameters when building links is to use http_build_query(). if you search this forum for http_build_query, you will find a number of examples. basically, the pagination code will use any existing $_GET parameters (pg, search/filter terms...), set only the 'page' and 'ipp' values that it is responsible for, then build the query string to put onto the end of the links using the resulting set of combined data. some security issues in your code - 1) you should NOT use extract ($_REQUEST); this will allow hackers to set any of your program variables to anything they want. it also makes more work for you, the programmer, because you must now keep track of which program variables are magically appearing in your code, due to the extract(), to insure you don't overwrite anything, now or when you make changes to the code in the future. use the proper external variables ($_GET, $_POST, $_COOKIE) and forget about magically populating php variables. 2) your login check code needs an exit; statement after the header() redirect to prevent the protected code form running. without the exit;, all a hacker needs to do is ignore the redirect and he can still access your pages. 3) you MUST validate that the pg=file value is only a permitted, for the current visitor, and valid page. because you are using the value in an include statement, again, a hacker can include ANY file on your server, so he could include an administrative file, even though he isn't an administrator on your site. 4) in some versions of php, $_SERVER['PHP_SELF'] also contained the submitted query string, which can contain arbitrary cross site scripting code and should not be used or if used care must be taken when you echo it out on a page to render any html/javascript/css in it, inoperable.
  25. the error means that your query failed due to an error of some kind. you would need to use mysqli_error($con) to find out why.
×
×
  • 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.