Jump to content

PFMaBiSmAd

Staff Alumni
  • Posts

    16,734
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by PFMaBiSmAd

  1. You need to do two things - 1) Put in the 5th parameter in the mktime() function, the day, as the first day of the month (or at least a day that exists in every month), because it is currently using the current day of the month and when you execute that code in a month where the current day does not exist in the next month it will skip over the next month and give you the 2nd following month. 2) Do the date math inside the mktime() function so that it will automatically rollover the date correctly - $daysInNextMonth = date("t",mktime(0,0,0,date("m") + 1,1));
  2. Your first step will be to use an actual mysql DATE or DATETIME data type to store your dates and date/times in. Once you do that, you can perform greater-than/less-than comparisons and ordering in your query. The YYYY-MM-DD date format exists for several reasons, the most import one is that the fields that make it up are left-to-right, most significant digit to least significant digit, which is what is necessary to compare dates by magnitude.
  3. To start with, your query does not have any single-quotes around the string data values, so it is impossible that is your actual code that inserted the data you are posting as being the results.
  4. If someone has direct access to your source files on your server, it does not matter if they can see your mysql connection details or not. They can just read your msyql data files directly. Also, if you were to encrypt/decrypt (which md5 is not, it is a one-way hash) your database connection details, the key needed to decrypt them would be present in your source code and again, if someone has that level of access to your files, it does not matter. You are trying to make a non-problem into a problem.
  5. What makes you think putting your database connection information as php code in a .php file is not safe?
  6. You can typically use a session variable to prevent duplicate page requests. Set a session variable at the point where the first page request has successfully been processed and at the start of the page check if the session variable is already set and skip processing the page if it is set.
  7. A) So you didn't move the <select> ... </select> query/logic so it would only be executed once and the output reused where needed, B) You are fetching and discarding the first row from the result set in the following line of code- $row2 = mysql_fetch_assoc($result2); Why do you have that line of code in your program?, C) I either doubt the names of your columns in the categories table are 'id' and 'cat' and/or there is no data in those columns.
  8. Cannot really help you without seeing the code responsible for the symptoms and the actual 'view source' of the output would be helpful. If there are the correct number of <option> </option> tags but the value or the display text is empty, that would imply using a wrong variable name/index name in your code.
  9. I have not heard of any cases where Chrome will request a page twice, but either your browser (due to debugging tools or to apply default character encoding), some javascript in your browser (typically some validation logic submitting a form and the actual form being submitted by the browser), your web server (if you are rewriting the url and/or some cases of an add on domain), or your logic on the server is causing this.
  10. <?php $date = new DateTime(); $date->setISODate(2010, 30, 0); // July 25 echo $date->format("Y-m-d") . "<br />"; $date->setISODate(2010, 30, 6); // July 31 echo $date->format("Y-m-d") . "<br />"; ?>
  11. A ' has meaning in HTML and it will break the HTML on your page if you simply echo/output it. Any content that you output on a page (that is not intended to be html tags) needs to be passed through htmlentities with the second parameter set to ENT_QUOTES
  12. Also, why are you writing out all of that repetitious code where only the value is different and you have to write out more code to add another value? Just use an array - $revisions = array(); $revisions[] = "317"; $revisions[] = "474"; $revisions[] = "508"; $revisions[] = "525"; $revisions[] = "530"; $revisions[] = "562"; if(in_array($revision_p,$revisions)){ $search_query = mysql_query("SELECT * FROM snippets WHERE title LIKE '%$contents%' AND `revision`='$revision_p'"); } else { $search_query = mysql_query("SELECT * FROM snippets WHERE title LIKE '%$contents%'"); }
  13. You have got two WHERE clauses in your queries. You can only have one. I suspect you wanted to form a logical expression using the AND keyword.
  14. Your page is probably being requested twice by your browser or you are doing something else to cause that code to be included twice... Are you using firefox with any debugging add-on tools?
  15. ^^^ The output from that query is static. You would not put it inside of a loop that is processing contents from your main query. You would in fact execute that query one time and form the <select> ... </select> menu in a variable, then simply echo that variable where you want it.
  16. If someone has direct access to one of your files, they have access to all of them and it does not matter where you put your included files. What makes you think php including files it needs is not safe? There are 10's of millions of php based web sites including files now.
  17. Like the error states, $post_data[$field_name] is an array at some point in time but you cannot use trim() on an array. If the data that $post_data[$field_name] refers to was always an array, then your code always produced that error but it was being hidden and what was changed on the server simply caused this existing php error to be reported and displayed. If that OOP class is something that you created, you would need to modify it to detect if an array is being used and use appropriate code when it receives an array.
  18. That code isn't even using mysql_query() so it cannot be the code you were using that produced the error you posted in Reply #14. In fact, it is probably the original code you stared with and it produces the error message in the title of this thread. When your problem is a moving target of randomly changing code and errors that don't even match the code you provide, no one really wants to try to chase down what you are changing in it. You have had both the mysqli and mysql errors explained and been told that you cannot mix mysql and mysqli functions in one script. You must pick one way or the other and all the database related code on any page must use the same type.
  19. A quick experiment shows that an include() statement is evaluated at runtime and the content in the included file is parsed/tokenized/interpreted at that point in time. Create a main file (a.php) that outputs something and includes a file (b.php) that intentionally contains a fatal parse error - a.php - <?php echo '1'; include('b.php'); echo '2'; ?> b.php - <?php a parse error; ?> Running this produces the output from the first echo statement, followed by the parse error in the b.php file - Edit: Also by putting the include() statement inside of an if(){} statement that is first true (produces the parse error), then false (no parse error and produces the expected 12 output from the echo statements in the main file) confirms if and when the code in an include statement is parsed.
  20. That's just the raw php code in the file. If you do a 'view source' in your browser, you will see all of the php code. Either php is not installed on your web server, you browsed using a file system path to the file instead of a URL so that the web server was completely bypassed, the file name does not have a .php extension, or there is some other reason why the php code is not being seen as php code on your web server.
  21. Someone already told you what the problem is - The solution would be to use the same name in the function call as in the function definition.
  22. The function name you are using in the function call is not the same name as your function definition and if you get rid of the @ in front of it, you would probably get an error that would point out the mismatch in the names. Don't ever put an @ in your code. They don't fix problems, they hide problems. There is no need for @ in code. On a live server display_errors should be OFF and on a development system display_errors should be ON.
  23. grk101, we only see the information you supply in your posts. Your code is retrieving the records that correspond to a specific id. Your code is getting that id from $_GET['id'], a GET parameter on the end of the URL. Since that does make sense as a method to display records to allow them to be edited (though if this was a real application, you would need to check if the current visitor is logged in and is permitted to access the records with that id) we must assume that you intended your code to work using this method or you would not have written it that way. It is up to you to provide a way in your application of visiting the page with the code you are showing us so that the expected GET parameter is present on the end of the URL or you need to change the way your application works if you intended to supply the id using some other method.
  24. <?php } while ($items = mysql_fetch_assoc($items)); ?> You are overwritting the result resource the first time your while() condition is evalueate. The second time, $items no longer contains a result resource. Since you are using $row_items in your actual code, I suspect you meant to use $row_items = mysql_fetch_assoc($items). You will find that using a do/while loop requires more lines of code to accomplish the same thing as using a regular while(){} loop and in this case would have likely prevented this error in your code because you would not have needed to type the $row_items = mysql_fetch_assoc($items) twice.
×
×
  • 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.