Jump to content

DavidAM

Staff Alumni
  • Posts

    1,984
  • Joined

  • Days Won

    10

Everything posted by DavidAM

  1. Oops! typo; should have said: "The reference in the code should be: $store_array = $_POST['store_id']"
  2. At the risk of repeating myself ... Did you check the string carefully to see if it contained whitespace other than 0x20 (space character)? While the \s after "No" accounts for whitespace there, if there is a tab, newline, or even non-breaking space (0xA0) between the name and answers, I that will not be caught (and I'm not sure that "\s" will catch non-breaking spaces). They could even be nulls, though I'm not sure how the browser would render that. A hex dump of the string would help determine this, or var_dump(), or maybe htmlentities().
  3. The name of the INPUT field should use the [] array construct: <INPUT name="store_id[]" ... The reference in the code should not: $store_array = $_POST['store_id']
  4. INSIDE the loop are you assigning the customer data to variables for each row. OUTSIDE the loop, you are echoing the customer data. Since each pass through the loop assigns the (current row) customer data to the variables, it is OVERWRITING the data from the previous row. The ECHO statements, after you close the loop, only has access to the variables set in the last pass of the LOOP (the last record). Move the ECHO statements inside the loop. Also, your test to see if the query failed will echo "Error in SQL", but will then continue with the next statement trying to process the results, which will produce an error. It should probably be something like: $rs=odbc_exec($conn,$sql); if (!$rs) { # MAD query failed echo"Error in SQL"; } ELSE { # MAD query executed OK while(odbc_fetch_row($rs)) { $cscode=odbc_result($rs,"cscode"); ... $cszip=odbc_result($rs,"cszip"); # MAD moved ECHO's inside the loop echo "<tr><td width=\"40%\">Customer Number</td>"; echo"<td>$cscode</td></tr>"; ... echo "<td>$cscity $csst $cszip</td></tr>"; } #MAD END WHILE odbc_close($conn); } # MAD END IF {} ELSE { echo "</table>";
  5. Yeah, that would have been the next step. I suggested before the headers because the first two he has are going to force a file download which would make it more difficult to see the error messages.
  6. Is this output from an echo() call? Try using var_dump to see if there are actual delimiters in there (TAB, CRLF, etc), that you can explode on or match -- use explode rather than preg_ unless you need complex matching.
  7. It may be generating errors. Turn on error reporting at the beginning of the script error_reporting(E_ALL); ini_set('display.errors', 1); Then exit just before the first header. See if any errors or warnings are displayed. Make sure there is no output, even whitespace, before the headers and the object writing. Anything that gets sent will become part of the stream and the file will be invalid. Use the View->Source feature of the browser to see if there is any hidden output.
  8. Never worked with it. But it is likely that it is sending the raw PDF data with a proper Content-Type header. If you send any other output, then the data received by the browser is NOT a valid PDF file. If you want to modify or augment the output, you should probably load the HTML into a DOM object, do the updates in the DOM, generate the DOM to an HTML string, then load THAT string into the DOMPDF. Edit: Unless, of course, DOMPDF, has methods for allowing you to do the changes directly to that object.
  9. session_start is NOT needed for URL parameters ($_GET). It is only required for maintaining values between pages using the $_SESSION super-global.
  10. I don't see how a semicolon change would fix it ... Lines 14 & 17: You are ALREADY in PHP, you can't jump back into PHP, remove the <?= and ;?> characters and you should be OK since you are just trying to imbed a variable into a string you are echoing.
  11. DavidAM

    php error

    When an array element is referenced INSIDE double quotes, the rules are slightly different. $a = array('one' => 1, 'two' => 2); echo "First: '$a[one]' -- Second: '$a[two]'" . PHP_EOL; echo "First: '$a['one']' -- Second: '$a['two']'" . PHP_EOL; echo "First: '{$a['one']}' -- Second: '{$a['two']}'" . PHP_EOL; In this code, line 3 will work (without warnings), line 7 will work. Line 5 will produce the "unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING " error. PHP does not recognize CONSTANTS inside a double-quoted string, so the unknown constant warning will not be triggered by line 3. PHP requires curly braces for "complex" variable expressions inside a double-quoted string, as show in line 7 -- This is the recommended method for using arrays in double-quoted strings. Since we do not the context of that partial line of code, we really cannot answer the question. It could be an SQL statement, it could be an ECHO statement, it could be a misplaced double-quote on the end of some other invalid expression.
  12. DavidAM

    php error

    That appears to be only part of a statement. We can't really tell you much without more context. Post more code, several lines BEFORE the error line and several lines after. But PLEASE, PLEASE use ... tags.
  13. Each request to the server, whether it's GET or POST (or any of the others), executes a separate instance of the script. So, yes, there could be multiple instances of your script executing at the same time. Depending on how you are managing the data, it is possible for it to "get crossed". If you are writing to flat files, it is entirely possible that data can get lost if your code does not protect against it. If you are writing to a database, you are less likely to loose data. However, if you are inserting/updating multiple tables, you need to make sure you use the proper functions to keep the relationships intact. As to using Curl, it is just another request to the server, the server really doesn't know the difference and does not care.
  14. Who ever told you that? First of all, you are not opening two sources you have one source and one target. Second of all, there are countless well written programs that open multiple files. If you need data from one file to put in another file, there is nothing wrong with having both open at the same time. It can be more efficient and less likely to run out of memory should the source file grow unexpectedly. I've never used this library, but I see a couple of issues with the posted code. 1) Please use tags (not quote tags) when posting code 2) You are opening the same filename for both excel objects 3) You are not passing a value to the setActiveSheetIndex() method. I would expect it to take an integer (or perhaps a string of the "tab name"). You didn't really tell us what the problem is. "not working" is not a valid problem statement. Tell us what it does or does not do that is should not or should do. Also turn on error reporting and tell us what error messages you get.
  15. In your original code, you are redirecting BEFORE you set the "remember" cookie. Also, you are setting the "verifyok" element of the session to 1 or 0. So a test with isset($_SESSION['verifyok']) is going to be TRUE regardless of the VALUE in that element. I'm not sure if either of these is causing the loop, but they are going to cause some minor headaches at some point.
  16. You would have to send it to a script on the server, probably using AJAX. If it has something to do with a form that will be POSTed, then you can put a hidden field on the form and assign it a value indicating checked or unchecked; then process it with the rest of the form when POSTed.
  17. When a browser (or any other client) sends a request (such as "GET index.php"), it sends several headers. One of those indicates the type of response the client is prepared to accept: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8The "*/*" on the end indicates "I'll take anything you can give me", but the "q=0.8" indicates a preference value (i.e. I would rather have the stuff listed in the "q=0.9"). That message would indicate to me that a request was made without the "*/*" on the end, and the output that the WEB server found to send does not match any of the "Acceptable" types. Do you need to debug it? That depends on what triggered the error, and what you want it to do in that case. Is this a response you got through a standard browser request or are you reading this from the logs?
  18. If there is no requirement to edit the data outside of PHP, I would just use serialize and unserialize along with file_put_contents and file_get_contents file_put_contents($Filename, serialize($questions)); $questions = unserialize(file_get_contents($Filename);
  19. Then rename the two files, so the next time the process is run, you get the "new" file as input. By the way: if there is any possibility that the page will be submitted from two different users, or even browser tabs, at the same time, you will experience data loss. This is one of the reasons that a database is recommended for data processing.
  20. We have no idea how your database is laid-out and we have no idea what $this->User->delete() actually does, so we have no idea how to help. In a relational design with the requirements you describe, I would have the following three tables: Users: ID (Primary Key), detail user data Addresses: ID (Primary Key), detail address data UserAddresses: UserID (Foreign Key), AddressID (Foreign Key) Then the delete process would be: 1) Delete from UserAddress Where UserID = <the user being deleted> 2) Delete from Users Where ID = <the user being deleted> You would then have to deal with Addresses that are left with no Users assigned. Depending on your requirements, you might leave them, or use some process to "clean them out". I don't know why or where you have an "UserCount" column. In the design above, to find out how many Users are associated with any given address, you do a Select COUNT() query with a Join. You should not try to maintain a count field.
  21. (emphasis added) SELECT * FROM obs INNER JOIN patients ON obs.MRN = patients.MRN WHERE obs.time_recorded = (SELECT MAX(OLAST.time_recorded) FROM obs AS OLAST WHERE OLAST.MRN = patients.MRN) AND obs.par > 6
  22. As I understand it, you want to know, in a PHP script, if an image file on a remote server exists or not. If the file were on your local server, you could use file_exists. If allow_url_fopen is on, you can use it (file_exists()) on the remote file (I've never tried this). You can try something like this -- again, this would require that allow_url_fopen be on. function load_content_images($id) { $id = md5($id); $url = 'http://s3.amazonaws.com/fast-network/photos/' .$id .'.jpg'; if (! file_exists($url)) $url = 'http://mydomain.com/missing_image_filename.jpg'; return $url; }
  23. What is the mySql datatype of the column where you store that value? Maybe you should show all of the code from $Timestamp = ... up to where you put it in the database. Are you using number_format()? $Timestamp, as kicken said, will NOT have commas in it based on the code you posted. If the commas are in the database, then you have other code adding them. Where do you see the commas? Is it your display code that retrieves the data and then adds the commas before displaying it?
  24. Terms of Service He is free to be bored; frankly I am, too. I usually don't even bother to scroll through large chunks of code (that's 200 lines you posted) that are not even in code tags. It is nearly impossible to read. Since this is a forum of volunteers, you would get better responses if you follow the rules and make it as easy as possible for someone to spend their personal free time trying to help you.
  25. "Irrelevant" makes no sense here, perhaps you mean "invalid". In any case, the session is destroyed ON THE SERVER and the browser (THE CLIENT) has no knowledge of this until it requests another page. So the answer is "NO" Yes and No. There is no fool-proof way to do this. You can use AJAX on the client side to ask the server if it is ok to follow the link, but since the user has complete control of the CLIENT (browser) such checks can be easily bypassed or ignored. It is the responsibility of each "page" that should be secure to authenticate each and every request. Also, doing an AJAX check and then following the link wastes a lot of resources: bandwidth, server processing, user time. It makes more sense to do the check in the target script. Can NOT be done. You are trying to make "Mypage" a secured page, so it MUST validate the request.
×
×
  • 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.