Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,529
  • Joined

  • Days Won

    189

Everything posted by mac_gyver

  1. it shouldn't even be that. just echo the product name next to the radio buttons it belongs to.
  2. finally, some information from you that helps, that you should have supplied in the first post in this thread. 1) that IS an error message. it's being produced in your code when the visibleMenu() method returns a false value (unless you have have that same error message in other places in your code and it's actually coming from somewhere else and not the call to the visibleMenu() method.) 2) the visibleMenu() method will return a false value when - if( empty($id) ) return false ; if ($visibol > 1) return false ; 3) since, $visibol is being set by your code to either a 0 or a 1 right before calling the visibleMenu() method, that means that $id is probably empty. 4) $id is coming from - $action = (isset($_GET['action'])) ? $_GET['action'] : null; $id = (isset($_GET['id'])) ? $_GET['id'] : null; $controllerAdmin = new controller_admin($action, $id); this means that there is probably no $_GET['id'] in the url. there is apparently a $_GET['action'], otherwise the code where the errore nel cambio dello stato is at wouldn't be running. 5) this is the code producing the url - if ($risultato['menu_visibol'] == 1) { $action = "?menu&action=novisibol"; $text = "novisibol"; $class = "novisibol"; } else { $action = "?menu&action=visibol"; $text = "visibol"; $class = "visibol"; } and this - <td><a title="<?php echo $text ;?>" class="<?php echo $class ; ?>" href="<?php echo $action . '&id='.$risultato['menu_id']; ?>"><?php echo $text ;?></a> </td> so, do the links on your page have an &id=some_value in them and that same part of the url is present in the address bar of your browser on the page where you get the errore nel cambio dello stato message (in case you have some url rewriting that's not carrying over that value)?
  3. you are likely running up against a relaying restriction on your mail server, due to the neither of the TO: or FROM: address being hosted at the sending mail server. i'm betting that for the case where it sends the email, the TO: address is hosted at the sending mail server and for the case where it doesn't send, the TO: address is not hosted at the sending mail server? if you turn on php's full error_reporting/display_errors settings, you will likely be getting an error that points to the problem. the email is NOT BEING SENT FROM the person who entries their email address in your form. the email is being sent FROM your sending mail server (even if you are sending it to an address at that same mail server.) the From: email address must be an address hosted at your sending mail server or you need appropriate DNS records at the domain being put into the From: email address that says that your sending mail server is authorized to send email for that domain. only the REPLY-TO: address should be the email that was entered in your form.
  4. there are at least a dozen different things that could cause your code to not do what you want, ranging from a database connection that is failing, to invoking the page in a way that isn't causing the php code to be ran. you have to tell or show us what output your code is producing and what exactly is wrong with that output in order to narrow down the possibilities. you also put the debugging line of code that parkerj suggest in the wrong place. you stated that the UPDATE part of the code is where the problem seems to be, yet, you put his suggestion into the SELECT part of the code.
  5. with the mysqli_report set, all that will do is reporting errors/throw exceptions. to display or handle the reported errors, you need to either put a try/catch block around your code and handle the thrown error yourself, or you need to have php's error_reporting set to E_ALL and display_errors set to ON so that the reported mysqli errors or the uncaught exception will be reported and displayed.
  6. it's pointless to tell us that something does not work. we already know that or you wouldn't be posting on a programming help forum. we don't have the ability to run your code with your data on your server and we are not sitting right next to you to have seen what you saw when you ran your code. you have got to tell us what error or other symptom you are getting that leads you to believe that your code isn't working.
  7. this is the second time someone has questioned this. i don't think the OP has planned how his page is actually going to be used.
  8. do you really have four different data definitions stored in one table or is this an exercise to see how you would solve a made up problem? any performance problem is due to the queries and due to the number of overall queries. you would want to make sure that each query is as efficient as possible and that you run a minimum of different queries. are the queries that are using LIKE '%some_value.%' actually trying to find exact matches? if so, you should be using = comparisons. will the queries using TOP 1 only match at most one row in the table or can they match multiple rows but you only want one? do you have indexes set up in the database tables so that finding information would be as efficient as possible? so, how would i (probably) approach doing this. i would query for all your main data at once, loop over each row and split up the four different datastring formats to come up with one common set of data for each existing row, without performing any of the other select queries. insert this now, split up, common set of data into a new table. to retrieve any related data, just JOIN this new table with your TRIANGULATION, ROAD, and account tables.
  9. it sounds like you need to use/write a content management system, where the different content making up the pages is stored in a database table, the menu is dynamically produced based on the content that's been stored in the database table, and you have one physical page (index.php) that dynamically outputs each different logical page, when it gets requested with a page identifier as part of the url.
  10. here's a point to ponder. if you allow multiple of any one item to be added to your cart, which you should, make sure that you provide a way of allowing the same or different engraving on each of those same items. you may want to make the entry of the engraving a separate step, where you display all the engrave-able items and allow entry of the engraving for each one.
  11. the tutorial you are following has 2-3 times too much code because the design of the cart is not efficient. it's also running a database query inside of a loop, which is killing your database server with queries. the code example that Barand posted does show you how to add the engraving input to the cart. you can modify his code to work with your cart definition or it would be better to modify your cart definition to match what he suggested. your current "add to cart" code is about 20-30 lines of code. most of that would be replaced with the few lines that he posted. you would still need to detect if $_POST['pid'] is set and cast/validate the pid value (which your current code isn't even doing) and validate the engraving value. similarity, all the other code blocks, except for the 'empty cart', can be simplified to just a few lines of code, if you simplify the definition of the cart. for the code that's retrieving and displaying the product information from the database, with the simplified cart definition, use array_keys() to get all the product id's at once, implode() that to make a comma separated list, then use that in ONE database query, using an IN() comparison in the WHERE clause to retrieve all the product information at once. you can then loop over the rows retrieved from the database and display the contents of the cart. you would use the id from the database rows to reference the quantity and engraving values stored in the cart.
  12. you have the wrong idea about what programming help is. we are not here to fix up the errors in your code for you. we are here to provide guidance and to point you in the right direction. if you are not at the point in your programming career to be able to take information about what is wrong and find and fix the problem yourself, you are trying to do something that is beyond your current skill set. writing (or finding and making changes to) an entire application requires that you first learn enough of the php language so that you can write error free code, then learn enough basic programming skills so that you can put the php language statements together in a meaningful way.
  13. it sounds like the browser is only used to trigger the script, not to provide any input, and that you probably run this script on a regular (scheduled) basis? if so, you would use a cron job/scheduled task to run the script. When the script finishes, it can do anything you want - send an email, update/insert data into a database table indicating when it finished and with what status, log values indicating the same type of info, ...
  14. that particular error means that php reached the end of your file while it was still expecting some closing php syntax. this is usually caused by a missing } but it can also be caused by a quoted string that isn't closed or even using short opening php tags when short opening php tags are not enabled.... you will need to go through your code looking for things that are not matched up. your code does have at least one serious problem. each header() redirect needs an exit; or a die; statement after the redirect to prevent the rest of the code from running while the browser is performing the redirect. the header() doesn't stop the php code. all anyone needs to do is ignore the redirect and they can stay on your page, because all that code still runs. your code also could stand to be organized better. this will reduce the total amount of code you have to write, to debug, to find missing }'s in, ... the biggest things that would help would be - 1) to put all the php code that processes form data and modifies server-side data near the start of your file. 2) put all the code that retrieves data needed to display the page next. 3) have only ONE html document, everything from the <!DOCTYPE tag through to the </html> tag, and have that last in your file. for the different content that you are repeating the html document for now, you would produce the dynamic part of that content and store it in a php variable, then echo that php variable in the ONE single html document.
  15. the WEST abbreviation is correct for your time zone - date_default_timezone_set('Africa/Casablanca'); echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T'); results in this - this suggests that your stored data is incorrect. what's the code that's storing the data? perhaps it is altering the value before storing it?
  16. you're welcome. putting lines of code together so that they accomplish a stated goal is fundamental to this thing called programming. i can guarantee that you learned much more by actually looking at your code and fixing it yourself, than what you would have by someone telling you where to put your fingers on the keyboard and what to type.
  17. if you have the hashed password stored in your database table, how can this part of your query - AND password = '$password' ever be true?
  18. add the new column to your table and run one UPDATE query that populates the new column from the existing column's values. if your existing data contains the commas and spaces, the format-string you use as the parameter in the STR_TO_DATE() mysql function must contain those same characters. that's why a correct design is important, so that you don't have to keep going back and fixing things.
  19. one of the reasons for the yyyy-mm-dd format for a DATE data type is because that format is required in order to compare dates by magnitude. other reasons for using a DATE data type include being able to use the mysql DATE functions on the value, the most efficient data storage, and the quickest queries. you need to store your dates as a DATE data type, with that format. to insert dates that have a different format into a DATE data type, you need to reformat them. you can either do this in your php code or you can use the mysql STR_TO_DATE() function in your query.
  20. dynamically adding form fields is typically used when adding empty fields for data entry, such as adding a set of fields to enter the data for each additional person in a family or adding a new car to your insurance coverage... it is not used to reveal existing information, as that just adds extra clicks to the process and makes for a bad user experience on your site. if what you are wanting to do is make the select/option menu contain all the possible products (less ones that have already been picked up to that point), that's not what your code is currently doing and still makes for a 'click happy' bad user experience on your site. if what you are wanting to do is provide a way of selecting among all your products, see my reply in your other thread.
  21. making a select/option menu that has only one choice, repeated for each product, makes no sense. what is the purpose of the select/option menu in your code? you would typically display all available products at once, ordered by category and/or name, or if you have a large number of products, provide a search box, category selection menu/links, or use pagination to limit what's being displayed at one time. the one-time non-product information for the order would normally be entered as a separate step, not as part of the product selection. you should not store the three prices in separate columns in your products table. multiple prices should be stored in another table, one row for each price, tied back to the products table using the product id. you can then store any number of prices for any product. when you JOIN the two tables to display the information, you will only get a row in the result set where there is a price. your code to produce the (three) radio buttons would simply loop over however many rows the JOINed query returns and produce that number or radio buttons. any time you find yourself repeating code, that only differs in the value it uses (such as your 3 radio button logic), it's a sign that you should be using a loop of some kind rather than writing out the code n number of times for each possible input value. before you move up to using jquery/ajax, you need to be able to produce the client side and server side code that accomplishes your task, since you will still need all of that client and server code when using jquery/ajax. jquery/ajax isn't required to make certain types of pages work. they only allow you to dynamically do things in the client without refreshing the page. without using them only means that when you perform an action in the client, the resulting output completely comes from the server.
  22. the following is equivalent, without the extra $myarray that's causing all the data to be stacked together, to what you are showing - while ($row = $result->fetch_assoc()) { file_put_contents("message/{$row['id']}.json", json_encode($row)); }
  23. yes, your errors are due to the debugger. php code debuggers generally work by adding a layer of output buffing to send the debugging information to their client module. you should generally only use a debugger to debug why your code isn't doing what you expect (that's why they are called debuggers), not as the primary method of running your code.
  24. php include/require statements, unless you specify the syntax for a url (protocol, domain, path, file - i.e. http://your_domain/your_path/your_file.php), operate on files through the file system, where url get parameters - ?some_name=some_value have no meaning. however, you would in general not want to use a url, because it is slow (your web server makes a http request back to your own web server), you only get the OUTPUT from your file, not the actual php code, and the two php settings that are required for a url to work are turned off by default due to the security problem of this allowing unvalidated external values being used to specify included files to allow a hacker to include their remote code onto your server and run it on your server. if your goal is to retrieve some information based on an id and make that information available to the 'calling' code, you would write a function that accepts the id as a parameter and returns the data to the calling program.
  25. because you haven't posted any actual output from your code, there's a chance that the error is in your interpretation of the result. also, unix timestamps are not reliable, since an actual conversion between different number systems is required to use them. the following is from mysql's own documentation for it's unix timestamp based functions - why not just store a mysql DATETIME value?
×
×
  • 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.