Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. It's your code! You wrote it I presume. Put it where it will do you the most good. Your question was simply "how to retrieve the value..." and I told you.
  2. #1 - please use the proper tags to enclose your code on this site, as on other sites. You can find them in the rules of the forum at the top of the page. #2 - when developing in php, ALWAYS turn on php's error checking. Look it up in the manual and you'll learn about a valuable resource. #3 - I see at least two errors that will show up as soon as you turn on error checking, This is why you got a blank page - your script failed but did not display the errors that were occurring.
  3. $new_id = $_GET['id'];
  4. Try modifying your code like this: $my_id = "xyztest"; if (isset($_GET['id'])) { $id = $_GET['id']; } else { $id = $my_id; } $sql = "Select x,y,z from tablename where Id='$id'"; This will use the $_GET value if provided, otherwise your value. Of course you really need to add some code to secure yourself from injection by using prepared statements (mysqlI or PDO AND NOT MYSQL_* functions). Otherwise you're just asking for a hacker to invade your data.
  5. Some of your current (error-laden) code: if(isset($_POST['submit2'])) $name=$_POST["name"]; $quantity=$_POST["quantity"]; $price=$_POST["price"]; $sql_insert = "INSERT INTO order ('name', 'quantity', 'price') values ('name', 'quantity', 'price')"; echo "sucess!"; #1 - you have an if statement. In order to determine the statements to be run if that if is TRUE you need to enclose them in curly braces. You aren't doing that so only the first statement is run to set $name if submit2 was clicked. The real problem begins when the rest of those statements are run EVEN WHEN submit2 WASN'T CLICKED. Do you see that? #2 - your query statement is bogus. Where are the inputs you want inserted? Do you REALLY want to insert the words "name", "quantity" and "price" into your table? That's what your statement says and it probably fails since price is probably a numeric field and you are trying to put alpha chars into it. Same for the quantity field. How would you correct this? #3 - WHENEVER you run a query you really should check the result to be sure it ran. Programs are going to do whatever you tell them to do, and like little children they will do things you don't tell them to do. If that query fails your code is still going to continue to run along even tho things aren't happening like you planned. SO - ALWAYS CHECK THE RESULTS OF 'EXTERNAL' THINGS. This is true for running queries, opening files, copying files to other locations, etc. You can't just assume that everything happens all the time.
  6. Jadelantern, Can I ask what your background is? Have you finished school yet? Have you programmed in some lower level languages which don't treat loops the same way as higher ones do and perhaps you just don't recognize them now? How long have you been programming and have you ever completed a project? (It had to have a loop in it somewhere!) If my previous post doesn't make sense to you in some way as to shed some feeling of understanding, I'm afraid you really must consider some other endeavor.
  7. If you are having this much trouble with loops - with repetition being one of THE BASIC CONCEPTS OF COMPUTING - you may be in the wrong hobby/class/business. Really? You can't find a tutorial that explains the usage of whatever loop command you are trying to use? Really? You've read the php manual on FOR, WHILE, FOREACH and still don't get it? Either you are not trying, or you will run into lots more difficulties with programming as you reach farther into it. I'm sad for you One last attempt. Data is stored in groups such as arrays, lists, table records, etc. One grabs this data with some command and then tries to use all of it ONE piece at a time. That means you have to imagine being at your desk with a stack of paper in front of you with each paper having one piece of info on it. Your boss says go thru all this and do xyz with each piece of paper's info. So - what do you do? You pick up the first piece of paper (data) and then do all the parts of the xyz task your boss wants done. Then you do the whole process again - grab a paper, do the xyz stuff and repeat. That is a human loop, otherwise known as menial or clerical labor. Computers are great at this! They use the loop construct (For, While, Foreach) to do the exact same thing. A simple loop to process the 50 pages that the boss gave you: while ($page = mysqli_fetch_array($query_results) { // call a function to do something with the current page of data Do_XYZ($page); } The while loop in this case is processing the results of a query that produced (let's say) 50 records of data. The while loop will give you one of those records each time it loops and while you have that one record your code inside the loop does things with it. In this case that is a call to a function called Do_XYZ which is also passed the $page variable which contains the data to be worked on that time. When the query results run out that will end the loop because when the mysqli_fetch_array command has no more results it will return false which the while loop will evaluate as false and quit. (When the fetch DOES return a row into the $page variable that is interpreted by While as True.) It doesn't get any easier than this.
  8. DO YOU KNOW ANYTHING ABOUT PROGRAMMING? If not, why are you trying all this? What are those values? Where are you getting them? Ask yourself those questions and pursue the answers. Jeez!!!
  9. You have not defined the 3 value items in your query. That gives you the php error as well as the sql error for trying to use unknown vars. BTW - if you did not have those two lines at the top turning on php error checking, you wouldn't know this.
  10. I know I'm pointing out the obvious, but the email body is built entirely by YOUR code. No mystery - you just have to look at what you are doing. and correct it. The way I would construct the body would be to do this: $body = (a bunch of header text) then run a loop on my data and do this: $body .= (data from current row) $body .= (data from current row) $body .= (data from current row) After the loop, add the closing comments $body .= (ending text) NOTE the use of the (dot)= in each of those body statements (except the first). IMHO, all of this detail that you want to display is going to be pretty ugly unless you use an html email and embed it all in an html table in that loop.
  11. Add this to your error reporting: ini_set('display_errors', '1'); You are monitoring errors, but you are not Showing them. This will output them to your client.
  12. May I ask why one would want to do this? That is, you wish to grab certificate info from sites using a script rather than just letting the certs be referenced by web traffic as needed?
  13. it sounds like you don't have a clue about developing a plan, thinking it through, and coding it up. You've coded up so much so far and now you are looking for help? What happened to your plan? What happened to your coding skills? Or did you not write this yourself? You have received some good tips here that you have used to make some progress, what is wrong now? Why are you not doing some work to perhaps re-arrange your process, re-think your goals and making the major changes that you were told you might have to do? Do you really think that all we have to do on this forum is design your solution and write it for you?
  14. Why don't you do some research on handling forms?
  15. Sorry - but I don't call what you posted "jumbled up". It looks perfectly normal to me. Is this supposed to be in some special format? From what I can tell from your verrrry lengthy post this is what you expected. What did you have in mind?
  16. Much better choice IMHO
  17. ErrorCode is a function hence: if($dbh->errorCode() == '42S02')
  18. I'm sure my approach is as good as any and that it meets your goals. It is just a question of whether you NEED immediacy in the way the dropdowns react or not. Using my approach, as each level of drill-down occurs the client waits for the form submission and server response to occur in order to provide the next level of choices. Using JS and AJAX there is a similar cycle that just happens to occur without the screen refresh, just updates to screen elements that may or may not have been hidden. Using all JS and JSON to build things you get a more immediate response at the expense of your time and effort in developing it. It is all up to you.
  19. You do realize that even the SMALLEST cities have more than one zip code? IIRC cities use the first 3 digits to identify themselves - you might want to do some research on this.
  20. You could probably simplify your task a lot if you provided an initial set of dropdowns that the user clicks on to begin his process. Once he submits the form you build a new form with those selections displayed at the top and the necessary set of just-built dropdowns from which he can then refine his choices. Upon submission of that form you could then display a page that lays out for the user just exactly what he chose and seek approval of it and then post the data to your db. To do it actively, ie, without a submission, you would have to either use ajax to interact with the server behind the scenes, or use js to populate dynamic dropdowns from a large set of pre-loaded data. Depending upon the needs of your system and users, my idea will save you a lot of headaches and time since you won't have to load a lot of data via json and your queries will be more straight forward and smaller
  21. Can you post a small portion of the message body without losing its current jumbled format?
  22. You have a glaring error in your code. Where do you set the value of $spent?
  23. The general opinion of many is that w3schools is NOT what it appears to be. But..... As for your fears about sessions. It is my understanding that they do go away once ALL occurrences of your browser are closed down. Not just tabs, but the application itself should you have multiple browsers (of the same manuf) open. Sometimes I have noticed that if I re-open my IE within seconds of having shut it down, the session will be there, but if it is closed for 30 seconds or so, it is totally gone, so I'm not sure what you are concerned about.
  24. Have you read the manual?? Try this reference: http://us2.php.net/manual/en/function.session-destroy.php
  25. You need to assemble your quiz form so that the answers relate to a question number. Your attempt so far is completely wrong since you don't do that and since you are trying to gather the correct answers using the values of the selected answers from the answer table, rather than the question #. If you are going to write code, learn how to (try to) separate your html from your php as much as possible. Example: You begin your first piece of code with an html form tag, and then jump into php mode. Silly. Instead - do your logic, process your input, get your data, THEN build your output
×
×
  • 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.