Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,449
  • Joined

  • Days Won

    174

Everything posted by mac_gyver

  1. does a phpinfo(); statement show the expected/correct values for the relevant settings?
  2. max_execution_time is the time limit of your .php script. your php script isn't invoked until after the file has been uploaded to the server and php (the language engine, not your .php script) has done things like check the various size limits, check for errors, and move the file to the temp upload file location. take a look at max_input_time - http://us2.php.net/manual/en/info.configuration.php#ini.max-input-time
  3. your database connection details should only be known to your code and your database. you should not be using external submitted $_POST data as your database connection user and password. these values should exist only within your php code as either variables with assigned values or as defined constants.
  4. there's an unusual color change in the code highlighting that's due to a missing double "
  5. the best method of storing a cart is to store it in a database table as this allows you to directly join the cart contents with the product information using one query when you need to display the cart information. to add, subtract, or delete items from the cart you use appropriate database query statements.
  6. after you sort your built up array of url parameters by their keys, php has a function that builds query strings from an array, it even handles urlencoding for you - http://us1.php.net/http_build_query
  7. the answer is yes, all the variables the code is using that aren't specifically created/defined within the code, come from $_POST variables.
  8. did you read the latest reply in your previous thread? if the 'number' element you are showing represents the item number and you are going to need to reference the entries in the cart by their item number, use the item number as an array index, not as a separate element in the stored array. once you do that, your code would be - $_SESSION['cart']['content'][2]['sizes'] = 2;
  9. the age of something is the difference in years between the current year and the year of birth, subtract one if the birthday (month/day) hasn't occurred yet in the current year. an example - $dob = '1993-05-12'; // standard yyyy-mm-dd format $today = date("Y-m-d"); $age = substr($today, 0, 4) - substr($dob, 0, 4) - (substr($today, 5,5) < substr($dob, 5,5));
  10. the error means you are trying to use $result as a string (echo it, concatenate it...). since the posted code doesn't contain anything like that anywhere, let alone line 11, the posted code doesn't correspond to the error message. the error is either from some other file or the code you posted wasn't saved/uploaded to the server. note: mysqli_connect_error() does NOT have a call time parameter. you use of mysqli_connect_error($link) may cause an error unto itself should a connection error occur. also, why are you making a database connection in two places in your code? once would be enough.
  11. in general we only want to see relevant code. as long as this isn't more than a few hundred lines, go ahead. if we are talking 1000's of lines of code, no. Please use the forum's bbcode tags (the edit form's <> button) around the posted code.
  12. you need to use a complete opening php tag <?php
  13. you may want to consider that this is the 21st century, computer storage is large and cheap, and each size or color of an item can be given a different id (identifier.) your cart needs to store the item id and the quantity - $_SESSION['cart'][item_id] = quantity; $_SESSION['cart'][1] = 1; // item id 1, quantity 1 $_SESSION['cart'][45] = 2; // item id 45, quantity 2 you wold manipulate the quantity in the cart using the item id as the array key to test for and access the cart entry. to display the cart contents, you would retrieve all the item id's at once (see array_keys()), run one database query to get the information for the items in the cart, pre-process the retrieved information to store it in an array using the item id as the array key (has the same structure as the cart), then as you loop over the cart contents to display it, use the item id from the cart to access the retrieved information about each item.
  14. if the $b_first, ... variables later in the code represent the same values (form data) as the code already posted in this thread (it would take knowing what the code between those two points is doing), then yes, either they would need to be replaced with the corresponding $_POST variable or you could assign the post variable to the named variable at some point in the code - $b_first = $_POST['b_first']; (which method depends on how many places the variables like $b_first are used.) please be advised that there are other changes in php that accompany the change that resulted in the $b_first, ... variables from external data (post, get, cookie) to no longer exist. i recommend that you read the php migration guides in the php.net documentation appendix to see what exactly has been changed over time in the php versions that you might need to address in your code.
  15. you seem to have a misunderstanding on what programming help is and what programming is. the forum section where you posted this has a description of - Do you need help with some code you wrote? what we do in this forum section is to try and help with errors and problems with code you have written. you are expected to supply the programming, we are only here to help with errors or problems with the code after you cannot figure out the problem yourself. where you are at, of having a statement of what you want your system to do, isn't even a question. it's a statement. having a statement of what you want is only the first step in designing a system. we can only answer questions, specific questions. you must next break the problem down into the steps that will accomplish what you want, define what data you will have/input at each step, define what you want the user interface to be at each step, and define what data/result each step will produce (to serve as input to the next step.) once you have sufficiently defined everything for each step, you are ready to sit down and design, write, and test the code that will produce the user interface you have defined, get/accept the input you have defined, perform the processing you have defined, and produce the result you have defined for each step. so, from a programing help forum standpoint, where are you stuck at when you tried to move beyond just having a statement of what you want?
  16. if the 500 server error is occurring on the form processing page (the address in your browser hasn't changed), it's likely that a fatal php runtime error has occurred further down in the code. add the following two lines of php code, immediately after the first opening <?php tag, to get php to report and display any errors it detects - ini_set("display_errors", "1"); error_reporting(-1);
  17. the main reason the op's result doesn't match the expected is the array index/offsets he used in the code don't match the data. offsets: 0 = time 1 = phase a voltage 2 = phase b voltage 3 = phase c voltage 4 = phase a current 5 = phase b current 6 = phase c current 7 = phase a pf 8 = phase b pf 9 = phase c pf 10 = freq for the values the code claims to be displaying, the offsets used would be 0, 1, 4, and 7
  18. the current demo download (not just the nopcart js files) contains a checkout form similar to the one you posted, with name attributes like - name="b_first" (i.e. no leading $ on the names.) are you sure you didn't add those $ to the form field name attributes recently? in any case, for a form field with a name attributed of - name="b_first" the corresponding php variable would be $_POST['b_first']
  19. unless the form code you posted is part of a php echo statement, the name="$b_first" attributes don't make any sense as the php variables they would cause to be submitted would contain the $ as part of the name. what version of this cart software is this, so that someone could download it to examine? and where did you down load this from, as the NOPDesgin site i found has a purely javascript cart, no php involved.
  20. it's the php code that needs to be changed.
  21. see post #2 in this recent thread - http://forums.phpfreaks.com/topic/288224-guestbook-problem/
  22. you have marked this thread as solved? i'm going to guess that you actually have two rows in your database table, one as lower-case and one with the capitalization you expect. a database query will normally match any letter case, so, if you are entering your capitalized username, it can match an all lower-case row in your database table.
  23. if you are just interested in updating the mysql_ functions, using the equivalent mysqli_ functions will result in the least amount of modifications to the code. you will however need to learn the correct mysqli_ syntax (the mysqli_select_db, mysqli_query, mysqli_close, and mysqli_error all require the database connection variable as a parameter.) for global $HTTP_USER_AGENT, use $_SERVER['HTTP_USER_AGENT'] for eregi, you would use preg_match(). the biggest change is the addition of delimiters around the search pattern. however, there are other changes that accompany the depreciation of these functions, such as the removal of magic_quotes, which attempted to escape external data for use in database queries. you would currently use the mysqli_real_escape_string() function (or use prepared queries.) i recommend that you read the php migration guides in the php.net documentation appendix to see what exactly has been changed over time in the php versions that you might need to address in your code.
  24. php is a server-side scripting language. all the php code you have on a page runs when the page is requested. your button and the onclick() event exists in the client-side (browser) code. to do what you want will require that your client-side code make a http request to the server and pass it either a post or get value that it can test to decide to call your php f() function code. also, don't create database connections inside of functions to run just the code in that function. your application should create one database connection and pass it into any function/class that needs it, as a call time parameter.
  25. the following single query will produce all the data you have shown in the above code - $query = "SELECT p.product_name, AVG(r.effect_rating) as effect_rating, AVG(r.taste_rating) as taste_rating, AVG(r.price_rating) as price_rating, ROUND(AVG(r.effect_rating + r.taste_rating + r.price_rating)/3,1) as overall_rating FROM products p LEFT JOIN rating r ON p.product_id = r.product_id GROUP BY p.product_id"; if you are using more columns from your products table than you have shown in the code, you will need to add them to the select list in the query. products that don't have any ratings yet will produce a row with null values for the four ratings, which you can address in the query (using COALESCE()) if you want and produce zero values for them.
×
×
  • 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.