Jump to content

ginerjm

Members
  • Posts

    6,906
  • Joined

  • Last visited

  • Days Won

    99

Everything posted by ginerjm

  1. 1 - you didn't post your code with tags as per the rules. 2 - you appear to be saying this is a JS problem. How about posting (with tags) in the JS forum instead?
  2. Turn on error checking and see if $user has a problem. That's got to be it.
  3. Way to hard to decipher your writing and understand what you are trying to say. And of course, properly posting your code would help us.
  4. As the manual tells you (hint) MySQL_fetch_array returns what amounts to two arrays - one with associated indices and one with numeric ones. If you don't need both of those, save resources and pick either MySQL_fetch_assoc or MySQL_fetch_row. BUT OF COURSE YOU SHOULDN'T BE USING ANY THAT IS NAMED "MYSQL_*" since those functions are deprecated, slated for extinction, soon to be gone and generally frowned upon by the community in the know. And from this latest post it appears that you are seeing that your problem is less with the loop than the statements being placed within it. BTW - PLEASE follow the forum rules and use tags to wrap your code in. On this forum that is the 'code' and '\code' wrapped in < and > symbols.
  5. Once again - it is in your code. If you don't understand how some functions work, either read up on them or don't use them. Somewhere in your code (and I'm not going to try and understand it again) YOU are outputting the data NOT in the way you think or want to do it. A good portion of any programmer's life in any language on any platform is spent in figuring out just where he/she went wrong. Time for you to expend some of that part of your life. Try and simplify your code. Break it up into distinct parts and make those parts finto unctions. Fine tune them until they do EXACTLY what you want and then put it all together with one set of code that initializes things, calls the functions to build those things and then outputs those things. Hate to be blunt like this but you really have to get a handle on what your code is doing and where you are doing it wrong.
  6. Good luck in your goals. Really.
  7. As for #1 - At the top of the page click on Rules and TOS. Go to Forum Guidelines. Read all of them, but most specifically #4. Warnings - I have no idea what netbeans gives you but apparently no proper php error checking. I'll post it here for you since you apparently didn't research the php manual. error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); Place at the beginning of any script you are developing. Errors? So many..... Major error is your use of php inside (or should I say outside of php) html code. You can't start a heredocs block in the middle of html which you do. Also I searched the manual for alternate syntaxes and could not find one that supports the following: $theResults: <<<EOD The only syntax uses an = sign, not a colon. If this is working for you, then perhaps the authors of the manual need to correct themselves. And while I'm discussing the chunk of code (html) you are not in php mode here so how do you expect the echo "$theResults"; to work? BTW - you don't need the quotes here. I'm sure once you turn on error checking as above you'll get plenty of messages in place of the blank page you currently receive.
  8. Whatever do you mean by "simple loops" and that you need 'more advanced tutorials'??? LOOPS ARE SIMPLE! That's all there is. As KevnM says perhaps your 'problem' is not the loop but the code inside that gets executed upon each iteration. All a loop does is repeat a set of code for you. As KM says, break down your task into ONE execution of the code you have and make it work on ONE set of data until you're happy. Now wrap it in a looping construct and you have it. That's all there is. I find it impossible to believe that you have written any kind of code from start to finish that did not involve a loop of some kind. I also worry about the state of college level teaching of CSI if you could get a degree without understanding this concept. I apologize (kind of) if you found my last post too much to handle, but I think we all agree that your inability to pick this up from all the help that has been provided is mind-boggling and I let myself go into frustration mode. And - you don't have to quote back to me my entire post (as the rules state) when you have an issue or question about it. Really - we can all read it in its original spot.
  9. 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.
  10. #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.
  11. 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.
  12. 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.
  13. 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.
  14. 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.
  15. 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!!!
  16. 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.
  17. 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.
  18. 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.
  19. 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?
  20. 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?
  21. Why don't you do some research on handling forms?
  22. 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?
  23. ErrorCode is a function hence: if($dbh->errorCode() == '42S02')
×
×
  • 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.