Jump to content

mac_gyver

Staff Alumni
  • Posts

    5,381
  • Joined

  • Days Won

    173

Everything posted by mac_gyver

  1. that may be, but is the php language engine 32 or 64 bit? that statement concerns the form fields, not the <form tag. that sounds like it's one of the third-party flash based file unloaders. care to share which one in case someone has some specific knowledge about it and your symptom that could lead to a solution?
  2. a post method form that has no name='....' attributes in the fields or has only empty name='' attributes in the fields will also send a CONTENT_LENGTH of zero. is there any chance that you are dynamically producing the form, either via php or javascript, or are using javascript to submit the form?
  3. the methods we have shown in this thread are for the type of query you posted at the start of this thread, that is testing if there is a user row matching the id and to fetch that row if there is, i.e. a query that will match at most one row. if you are running a query that can return any number of matching rows, you need to write the code differently. you would need to test the number of rows, then loop over the result set if there are rows. as an alternative, since you should be separating your database dependent code from any html markup, would be to simply fetch all the rows, even if there are none, into a php array. then use that array any place you need to access the data. you can find how many rows the query matched by using count() on the array. you can loop over the array using a foreach loop to process the rows.
  4. you must be specific, by showing what data you expected, what data you got, and what the actual code is that you are using.
  5. normally, the Content-Length is the value that the browser sent in the request when it starts to submit the form data, even if that value is greater than the post_max_size setting. i'm guessing that you either found a bug in php or you are on a 32bit system, the post_max_size setting is greater than a 32bit signed integer (2,147,483,647), and the math that php is doing to check the Content-Length against that setting is failing and resulting the a zero being listed for the Content-Length. the fact that the limit is being reported as a negative number supports the 32bit signed integer limit possibility. also, afaik, when the Content-Length is greater then the post_max_size setting, php tries (wishful thinking) to abort the upload. it may be that the browser/client you are using respects this, and then sends another post request with a Content-Length of zero. what is your post_max_size setting (what exactly are you setting it to and what does a phpinfo() statement report it being) and are you doing this on a 32bit php installation?
  6. when you successfully prepare a query, you get a mysqli statement object. you can only use the properties and methods that are part of a mysqli statement object. see this link for the documentation for those properties and methods - http://php.net/manual/en/class.mysqli-stmt.php you would need to use the ->num_rows property. you will also need to call the ->store_result() method before you can call the ->num_rows property (all the extra logic needed when using mysqli prepared statements is yet another good reason to use PDO instead.) since your query will/should at most match only one row, it will be more efficient if you just attempt to fetch the row. the ->fetch() method will return a true value if the query matched a row.
  7. lol, you did a var_dump() on the values and looked at them, but didn't think it would be helpful to show us what they were? i'm going to venture a guess, the $id is probably a zero, which is considered to be an empty() value. if so, you should not be using a zero as an id (identifier), especially since the column in your database table defining the ids should be an auto-increment integer column, which won't normally start at zero.
  8. no you don't. the html you posted at the top of this thread is a mess. it has two nested opening <form ...> tags and aside from the hidden form field, the form fields don't have name='....' attributes. you did give a name attribute to a <td ...> element that looks like it belongs in the submit button and there is no closing </form> tag. to do this thing called programing, you must first learn the basics. if you don't know the correct syntax for a <form ....> ... </form> at all, you will never get a form to work for your data. unless you can get one form field to submit to your php code, there's no point in writing out the html for more than one form field (and i as stated, you should let the computer write out multiple same meaning form fields.) you need to read a book, or take a class, or study up-to-date tutorials in order to learn the basics of writing forms and writing php code to process those forms, because you cannot do this just by throwing things together that you may have seen somewhere.
  9. some tips - 1) you would dynamically produce the form, rather than writing out all that repetitive markup. you would either allow the user to enter (an input box) or select (a select/option dropdown) the number of fields to produce or you would display a base number of fields and have an 'add' button that would dynamically add more fields. 2) form fields need a name='...' attribute to cause the data to be submitted. for sets of data, you would use an array for the name so that you can process the data using php's array functions. see this link for using an array for form fields - http://php.net/manual/en/faq.html.php#faq.html.arrays 3) if the names of the cards are specific (i.e. the user cannot make up card names), you would want to provide a way of letting the user select from the existing card names. by requiring the user to type in a card name you will have all kinds of problems with misspelling and making it too hard for the user to enter data. 4) to display the card names for selection, you would either display all them at once, ordered by category and/or name, or if you have a large number of card names, provide a search box, category selection menu/links, or use pagination to limit what's being displayed at one time. in short, define your user entry form so that it easy for the user to pick/enter the data, give the form fields array name's so that the data will be submitted at all and it will be submitted as arrays of data, then it will be easy for you to write the php code that processes the submitted data.
  10. not only that, all the radio buttons in the same group must have the same name so that the browser will cause them to operate as a group of radio buttons. giving each one a different name makes them completely separate radio buttons. in one of your previous threads, i suggested storing the price values separately (something you had asked about doing in an even earlier design based question), so that when you retrieve the product/price information, you could just loop to produce a radio button for each stored price. and in that earlier design thread both Barand and i (mostly him) gave you detailed help about how your data should be organized. a good data design, results in less code and less work for you, not more code and work. if you had stored the pricing based on the user type, you wouldn't even need these radio buttons. based on what you are trying to output, all you should need to do is write a JOINed query for the products you want to display and the price for those products based on the 'type' of the selected user, loop over the rows that the query matches, display the product name, display that user's price for the product, and output a form input for entering the quantity for each product. instead you have threads using select/option menus that contain one value to display the product name, hard-coded logic to display a radio button for each non-null price, questions about dynamically adding form fields and using javascript/ajax. you are making this harder than it is.
  11. it shouldn't even be that. just echo the product name next to the radio buttons it belongs to.
  12. 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)?
  13. 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.
  14. 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.
  15. 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.
  16. 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.
  17. 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.
  18. 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.
  19. 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.
  20. 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.
  21. 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.
  22. 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.
  23. 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, ...
  24. 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.
  25. 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?
×
×
  • 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.