Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,449
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. without knowing what your code is doing, there's no way to answer your question. the method that's using the memory, determines how to free up the memory when it's done or of using a different method that doesn't consume as much memory in the first place.
  2. you do realize that the php script didn't end. it ends when the very last statement on the page has finished running, be it an actual php statement or some in-line html. what sort of problem are you trying to find and solve?
  3. you would pass the data into the function in an array, with the array containing at least the table column name/value pairs, and optionally the data type as well so that the different possibly types can be treated appropriately in the query.
  4. How exactly are you determining the memory usage after the end of the php script?
  5. the following is from the Cast Functions and Operators section of the mysql documentation - this is of course is really bad if the field is a decimal data type and you are trying to avoid floating point conversion errors in the first place.
  6. the data is a hexadecimal value, apparently padded to the full length of all possible fields. you would need to know what the individual bits, hex characters, or groups of hex characters mean in order to store/retrieve/test specific information in the value. you can retrieve/test any hex character(4 bits) or group of hex characters using a SUBSTRING() function in the query. i've not used any of the mysql database bit instructions, but you can probably also use bit_and/or/xor statements to test or set/reset individual bits in the value. this is basically packing multiple values into one database column, rather than normalizing the data and storing each piece of data as a row with a key/value in a table. i.e. saving some storage at the cost of more complicated/slower code/queries and requiring altering the code and data if any thing needs to be added, where as, for normalized data, to add any choice, you simply add a row of data.
  7. if you are getting actual error messages, posting them would be helpful. if you are not getting error messages and the symptom is that session variables don't work, you need to set php's error_reporting to E_ALL and display_errors to ON, preferably in your php.ini, or alternatively in your script, immediately after the first opening <?php tag, and before all other php statements, to get php to help you by reporting and displaying any errors it detects.
  8. i have marked this thread solved for you to help prevent others from spending time trying to fix things in an abandoned thread. as stated in the thread you started after this one, the following logic does not mean that data was not found, it means the the query failed with an error of some kind - using your database library's error reporting function (mysql_error() in this case) would have pointed to the part of the query where mysql found a problem.
  9. your code is using mysql_real_escape string() and mysqli query statements. since it's unlikely that your code is making both a mysql and mysqli database connection, it's likely the mysql_real_escape_string functions are failing, which would be producing a number of php erors, and returning a null/false value. in this case, your select query would match zero rows and your logic is skipping over the insert query. please set php's error_reporting to E_ALL and display_errors to ON to get php to report and display all the errors it detects.
  10. i kind of though that might be what you were after, but your example (before the edit) didn't show that. you would still use OR in the where clause (which is the same as using the IN() comparison operator), but you would use GROUP BY ... to consolidate the matching rows together, so that you can use HAVING COUNT( ... ) = 2 to just match those that have exactly two of the checked options. i'm not sure it logically makes sense to have more than one 'all' choice at one time, but as long as the COUNT( ... ) terms produce the result you want, it may work. to test, add the COUNT( ... ) terms in the SELECT list, and temporarily remove the HAVING term.
  11. your customer table should only have information about the customers. if what you are trying to do concerns what a customer ordered (which you haven't stated), you would have an order table that relates the customer_id with each item_id in each order that customer placed. you would also have an item/product table that relates each item to the manufacturer, in a manufacturer table, using the manufacture id. since these tables would now have related information stored in them, your query would JOIN them using the appropriate id fields.
  12. when you pick 'all' for the Topic (or for the Document Type) that means you want all records regardless of the Topic. That means that the Topic value is a "don't care" value, i.e. match everything in the Topic column. the way to do that is to just leave the AND (issue_area.identifier = 'aging' OR issue_area.identifier = 'health') out of the Where clause.
  13. your example contains no relationship between the tables, therefore, they don't belong in the same query. if your Customers table had, me, angus macgyver in it, your Manufacturers table had Mack Trucks in it, and your search $criteria was 'mac', you are stating the result should be - myid, angus, macgyver, Mack Trucks. that makes no sense.
  14. queries work by finding rows that result in a logically true WHERE clause. when you use OR - (doctype.identifier = 'case_study' OR doctype.identifier = 'whitepaper') ... this it a TRUE value for rows with case_study in them and for rows with whitepaper in them. the rows that have a case_study value result in a logical TRUE OR FALSE expression, which is TRUE. the rows that have a whitepaper value result in a logical FALSE OR TRUE expression, which is TRUE. when you use AND - (doctype.identifier = 'case_study' AND doctype.identifier = 'whitepaper') ... this can never be true for any row(s) since there cannot be any row(s) that are both case_study AND whitepaper at the same time. the rows that have a case_study value result in a logical TRUE AND FALSE expression, which is FALSE. the rows that have a whitepaper value result in a logical FALSE AND TRUE expression, which is FALSE. your 'all' queries should leave the entire term out of the WHERE clause (to produce the fastest query execution.)
  15. moving this thread to the Application Design forum section.
  16. A) moving this thread to the php help forum, as it has nothing to do with Regex B) one & in a query statement is a bitwise AND operator and is likely resulting in a value that matches every true value for an id and since your code assumes there will be only one row, you get the first row out of your table. use the AND logic operator (or use &&) in your query statement. edit: in the following code, a false $result doesn't mean that the data wasn't found, it means that the query failed due to an error. if (!$result) { die("Error: Data not found.."); }
  17. the solution will likely involve JOIN'ing the related tables. if the tables aren't related in any way, they would need a separate (unrelated) query. rather than posting a query that doesn't do what you want (that doesn't show the relationship between the tables or what the desired result is), if you post some sample data and the result you want for that data, along with what relationship there exists between the tables, someone can help.
  18. some points about the code - 1) the user messages should be unique and descriptive. they are currently the same message and vague. the message if the new password and the confirmed/retyped password don't match should clearly state that those two passwords don't match. the message if the email/old password was not valid/not found should clearly state that either or both the email/old password are not valid. 2) you need to ALWAYS have logic in your code to test if your database queries work before trying to use the data from that query. if your SELECT query is failing due to an error, there will be zero matching rows and the current logic will report that the Passwords do not match. that's not true. there may in fact be a matching row, but you cannot tell because the query didn't work at all and the code cannot perform the requested action. only after the query has executed successful, would zero matching rows mean that the email/old password were valid/found. 3) when you originally stored the passwords in the table, did you perform any hashing of the password? if so, you must apply that same hashing method to the old password when you test if it matches the existing password in your table and and you must apply that same hashing method to the new password when you update/store it in the table.
  19. then your file has likely been saved by your editor with the utf-8 Byte Order Mark (BOM) characters. either save your file without the BOM characters or don't save it as a utf-8 encoded file at all (if it doesn't contain any urf-8 encoded characters.)
  20. the line number where the error message reports that the output occurred at is the last line of the output. moving the opening php tag down just added intentional output before the opening php tag. put the opening php tag on line 1, with nothing else on line 1 and what error do you get?
  21. In order to pin down what might be causing the output on line 1 of your index.php file, only put the php opening tag on line 1, with no other php statements on line 1 by also putting the include statement on line 1, you cannot tell if something before the opening php tag is causing the output or if something in the include file is causing the output. and get rid of the output buffering statements. you should only use them when you WANT to buffer output, not to try to fix problems in your code, and in this case there's nothing in the body of your code that is even producing output, so they had no effect.
  22. someone posted a suggestion - what did you try toward accomplishing that suggestion? you have a point in your code where you know the query matched the username/passwword. just use an appropriate database fetch statement to retrieve the row from the result set and assign the name value from that row to a session variable. echo that session variable on any page you want to display the name. there's bunch of things in the last posted code that need help - 1) don't use ob_start and ob_end_flush in your code unless you want to buffer output. there's nothing in that code that needs those and typing them in took up some of your time and added clutter to the code. 2) while it's true that php variables that are inside of a double-quoted string get replaced with their value, if the only thing in a double-quoted string is a php variable, the double-quotes are not needed and typing them took up some of your time and added clutter to the code. 3) you need to test if a form has been submitted before using any of the form data. this prevents errors from being produced when the page gets requested not due to the form. all your form processing code should be inside of a conditional statement so that it only runs when you know you have a form submission. 4) you should test if the submitted username and password have something in them before using them in the query. there's no point in running the query if the user didn't enter one or both of the values. 5) you are running stripslashes() after you have escaped the string data. that undoes the escaping and allows sql injection. the only time you should use stripslashes() on form data is if magic_quotes_gpc is ON and you would do it before you then use mysql_real_escape_string on the data. 6) storing $password in a session variable doesn't mean anything and is not being used. you have already authenticated the user, you don't need to carry his password around in the code. again, this is just more typing that didn't need to happen and cluttered up the code. 7) assuming there is unconditional code on the page somewhere after the header redirect, you need an exit; statement after each header redirect to prevent the rest of the code from running.
  23. image manipulation requires a huge amount of memory and processing time because you must perform operations on the uncompressed image, pixel by pixel. if you had php's error_reporting set to E_ALL and display_errors set to ON, you would likely be getting errors alerting you to where and what is failing. after you complete the processing for any one image, you need to call imagedestroy( ... ); for each of the three image resources you have created to free up the memory used by them (or re-use the same variables as there's no reason to have code with variables like $im1, $im2...)
  24. the only loop you would (should) have is the one looping over the data to build the links. to find/retrieve the matching element in the xml data, you would use an xpath query to search for it - $preowned = simplexml_load_file('file.xml'); $ADID = isset($_GET['ADID']) ? $_GET['ADID'] : false; // the ADID to search for // test if there is a search term if(!$ADID){ echo 'No search specified'; } else { // search for the element with the given ADID value $result = $preowned->xpath("/root/AD[ADID=$ADID]"); if(empty($result)){ echo 'Not found'; } else { $preownedinfo = $result[0]; // get the first (only) element // display the information from the element that matched the ADID search } }
  25. @objnoob the mysqli query method doesn't return the number of affected rows. you must be thinking of the pdo exec() method.
×
×
  • 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.