-
Posts
5,448 -
Joined
-
Days Won
174
Everything posted by mac_gyver
-
Notice: Trying to get property of non-object
mac_gyver replied to ChrisCwmbran's topic in MySQL Help
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. -
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.
-
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.
-
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.
-
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.
-
FOR loop keeps iterating over last item
mac_gyver replied to stevieontario's topic in PHP Coding Help
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) - -
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?
-
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.
-
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?
-
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.
-
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.
-
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.
-
echoing mysql_error() or using mysql_error() in the die() statement will tell you why the connect/select_db statement is failing.
-
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?
-
E_Warning and paths revealed...
mac_gyver replied to robertboyl's topic in PHP Installation and Configuration
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. -
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.
-
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.
-
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.
-
define("NOW_IN_CART","what ever it is currently displayed as");
-
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.
-
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.
-
simple user_exists function using PDO connect to mysql
mac_gyver replied to junkomatic's topic in PHP Coding Help
you need to execute the prepared query before you can fetch anything from the result set. -
simple user_exists function using PDO connect to mysql
mac_gyver replied to junkomatic's topic in PHP Coding Help
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. -
inserting to sql from textfield and textarea doesn't work
mac_gyver replied to cainam29's topic in MySQL Help
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); -
Need help! Getting errors for setting up a AQW private server
mac_gyver replied to homework's topic in MySQL Help
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.