Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,448
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. the name of the $db->loadObjectList() method hints that it returns an array (list) of objects. what is it supposed to return (array, single object, true/false if it fails...) and what is it actually returning? also, you should be using one joined query to get the related information, not two separate queries.
  2. to prevent duplicates, you would test if any submitted food item is already in the array before trying to add it. in fact, for a nicer user experience, you could dynamically build the <option></option> list by checking if each item has already been selected and either not output it in the <option></option> list or make it disabled in the <option></option> list.
  3. the connection details for any database connection (or how many different simultaneous database connections there are) is application level information. remembering or finding each class file that has application level information hard-coded in them to edit just because you moved where code is being ran at, is brute-force time-wasting make-work programming. by hard-coding where connection details are stored at (an include file name) or directly what the connection details are (external-variables/defined constants or local assignment statements) or using a static method of another class, inside of a class, you cannot use the class for more than one database connection at a time because multiple instances of the class all use the same database connection information. if your solution to this would be to copy/paste the class to a different name or to shuffle-around (making,overwriting,remaking) instances of a class, that's most definitely NOT the point of using classes for anything. dependency injection should be used to get application level information into any instance of a class.
  4. unless your ajax code displays everything that is sent back from the php code or you are directly examining the response sent back to the client, you won't see the php produced errors and there may not even be any php errors if the problem is in your php logic. Ajax adds a extra layer to your code that makes debugging harder. before you can use Ajax to accomplish a task, you must be able to perform that task, error free, without using Ajax and be able to debug what your code is doing. get a normal html form working with your php code, then add Ajax.
  5. the objects that are in the array are instances of your Photograph class, one for each row that the query matches, with the properties set to whatever data is in the row from the query, and whatever methods your class has.
  6. your for(){} loop doesn't have any {} so the only statement being executed inside the loop is the $sql = " ... "; statement and you just end up with the last $sql statement. however, for what you are doing, just use an (one) INSERT ... SELECT query (no loop is required) -
  7. a form field of any kind won't do anything unless it is inside a form tag or you use a js event with it. why not just use a <a href=''></a> link with a css button or an image for the button?
  8. a url like - paintings_detail.php?name=conscious will set $_GET['name'] the easiest fix would be to add $name = isset($_GET['name']) ? $_GET['name'] : ''; to the start of your code, repeat for any other get data. if your code was also relying on register_globals for any post, cookie, files and session variables, you will need to fix more things in it to get it to work.
  9. you probably have a non-printing character as part of your submitted form data that doesn't match anything when the query runs in the php code but when you copy/paste the echoed query statement, that non-printing character is stripped out. what is your code that is building the form?
  10. the query you posted in your code and the query where the error is occurring at aren't even the same ones queries. condition is a reserved mysql keyword - http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html either change the column name to something else or enclose `condition` in back-ticks.
  11. you would create functions or call built in php functions for each different type of validation. since you may have different requirements for each form field, i would make an array that lists the validation function names that you want to call in the order that you want to call them. then for each field, get the list of validation functions out of the array and dynamically call them using variable functions - http://php.net/manual/en/functions.variable-functions.php your code would loop over the expected form fields, getting the field name, then access the list of validation function names from the array and dynamically call each validation function and test/store the result. you could also expand upon this so that the array holds the corresponding error message and when a validation step fails, get and store the corresponding error message that you want to display.
  12. you need to use mysql_error() to find out why your query is failing. for debugging only, add - echo mysql_error(); on the next line after your mysql_query() line. it's likely because your data contains special sql characters that are breaking the sql syntax and you are not escaping (see the mysql_real_escape_string() function) the string data being put into the query or the programming gods are upset because you are using non-helpful variable names like $var1, $var2, $var3 that don't indicate the purpose of the variable.
  13. echoing mysql_error() or using mysql_error() in the die() statement will tell you why the connect/select_db statement is failing.
  14. the mysql_connect() statement will always run (assuming the function is defined.) if the connection fails, the function call will return a false value to the calling code. do you have any logic in your code to test if that function returns a false value?
  15. the display_error and log_errors settings apply to any type of error that is being reported due to the error_reporting setting. if display_errors are truly off in your php.ini and you are getting any of the of type of php error message (fatal, warning, or notice) being displayed, it means that either display_errors is not actually turned off of that your script is turning it back on. the error_reporting setting determines what is reported. the display_errors/log_errors settings determine what happens to the report of those errors.
  16. so it appears that these text strings have been this way for a while and you want to fix them? it looks like a version upgrade or a template/theme didn't completely install (or mixed version of files were used.) you cannot find where they are defined at because they aren't. they are either leftover from an old version of oscommerce or from a template/theme that was installed. they are used in the content but where they are defined at doesn't exist. the easiest fix would be to just define them yourself, rather than to find where all of them are used at (it's in different files depending on where on the page they are at) and change the name to what they should be (assuming they are still being used in the current version.) i would put them into catalog\includes\languages\english.php. in fact, define('HEADER_TITLE_CART_CONTENTS', 'Cart Contents'); that is in catalog\includes\languages\english.php is what NOW_IN_CART looks like it should be.
  17. if you are still working on why only one (that last one) piece of information is being displayed, it's because your display code isn't inside of your while(){} loop. your display code is after the end of your while(){} loop and is only running once, after the while(){} loop has finished and it is using the last values fetched into the variables.
  18. if this is a third-party script, there should be comments in at least the main index.php file that identifies it. the specific NOW_IN_CART value is more like a language/template setting and would likely be defined in a file in the includes/languages/ folder. what exactly are you trying to accomplish? if it's a setting like a site/store name, there's probably some global setting to do it and you shouldn't need you to find and edit files to change it. there's likely some sort of administrative page to do it on.
  19. define("NOW_IN_CART","what ever it is currently displayed as");
  20. it would help if you provided the name of this os commerce script in case someone familiar with it knows the answer. there is either a configuration file (config.php or similar) that contain define() statements or the values are stored in a 'config' database table and the defined constants are being dynamically created.
  21. you probably have some code like - if($accesslv=3){} that is assigning 3 to the variable instead of code like - if($accesslv==3){} that is comparing 3 with the variable.
  22. you need to execute the prepared query before you can fetch anything from the result set.
  23. the function has its own local program scope and the main program's $db variable doesn't exist inside of the function. you have two choices - 1) pass the instance of the database class in $db into the function as a call time parameter, i.e. if (user_exists($db, 'junkomatic') === true) { 2) create a class and use dependency injection to get the instance of the database class in $db into the instance of your class.
  24. the $values[] = " ... " statement would be - $values[] = "('$RemedyTicketNo[$index]','$PhoneNumber[$index]','$Createdate[$index]', '$Category2','$Category3','$Status','$Date','$Severity','$BanType','$XiD')"; the corresponding $sql = " ... "; statement would be - $sql="INSERT into tbl_main (ars_no,phone_number,create_date,category_1,category_2,status,resolved_date,trouble_type_priority,ban_type,employee_id_name) VALUES " . implode (',',$values);
  25. i'll bet the error changed to - Access denied for user 'root'@'localhost' (using password: NO). that's not the same error you were getting before (yes it matters if the username in the error changed or not.) if the message didn't change to that, then your script is not using the correct config file. did you create the aqw database first? the root user should automatically have access to any database that exists and if you are doing this for a real site, you should not use the root user, but create a specific database username with a password to use.
×
×
  • 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.