Jump to content

mmosel

Members
  • Posts

    66
  • Joined

  • Last visited

    Never

Everything posted by mmosel

  1. [!--quoteo(post=354084:date=Mar 12 2006, 12:15 AM:name=txmedic03)--][div class=\'quotetop\']QUOTE(txmedic03 @ Mar 12 2006, 12:15 AM) [snapback]354084[/snapback][/div][div class=\'quotemain\'][!--quotec--] The key is that you have to go with what works for you. I believe the problem is that there is a particular line somewhere above the header() that fires on those occasions that it fails and the conditions of it are not met for the times it succeeds. I hope that makes sense to you. [/quote] Well, yeah, in theory, what you are saying makes sense to me. But the fact remains that the condition that changes in this case isn't the fact that html and other content is echoed to the browser before header is reached in the script - it's that the number of lines of output changes. If you could see it, you'd understand why it's stumped me - because it defies the logic that says this is wrong, and the error should occur with ANY output before the header() is called - but that's just not the case. I should also note that I'm running this site development on my localhost Apache server on Win2k. When I run this on my live server, my results could change and perhaps the error will be more consistant. Thankfully I have the output buffer!
  2. Hi. Thanks again for your reply. I appreciate that code snippet, and I may use it. However, I definitely prefer to use php if I can. I am using ob_start() and flush and it's working fine. If outputing any code to the browser before calling the header() function is the problem, then I don't really need anyone to look at the code, because I know exactly where I'm doing that. My question is why would the error sometimes NOT occur when in fact I am echoing content and html before the script that calls the function? Maybe it's a timing thing, or the speed of the script? I don't know, but I may just end up using the output buffering for all my scripts.
  3. Thanks for your reply. I appreciate it. (note: when I say I use a header() function, the only function I've been using is the header( "location: ") - if that makes any difference.) I understand what you're saying, but my experience has been mixed. I have output, such as navigation, which is output via echo by php. The navigation is working fine. Later on down, in another script that runs after the navigation output, I call the header() function in my cart and it works just fine. It reloads the page and all is well. I also use a custom error function that calls a header() function that works after stuff is being echoed to the browser. However, I use multiple scripts, not just one big long one. I don't know if this would have any affect on this issue. But if my programming should NOT be working, but yet IS working, I'd like to know why! Posting specific code for that problem that I had would be a little nutty, because it's a very long script. The script itself functions just great. No functionality errors. Just that header already sent error that was unpredictable at best. According to theory, my scripts that call a header() shouldn't work at all, but they do! I wish I knew!
  4. Well, I'm going to use ob_start() for this particular script. However, I would still like to know why this is happening so unpredictably. I don't know if I should use the ob_start for other scripts that use a header() function or not. Strange and frustrating.
  5. Well, I'm back with another error and this time I really stumped. I'm getting the good ol' nasty cannot modify header info - headers already sent error. The thing that gets me is that I cannot pinpoint the problem. It seems to be very unpredictable. For the longest time I've been programming this project without a problem. I have four sections of info, the header or banner/ nav area, the right column, the main page, and the footer. Most of my application is happening on the main page. My index.php includes four files - header, rcolumn, main, footer -in that order. I have php outputting the navigation and user info in the column and everything works fine. I have my main scripts doing all sorts of things. Often, I'll use a header() command to redirect or reload a page (like in the cart). But for some strange reason, when I run a script for publishing a product, I get this header error. This script has been running just fine for weeks. The problem comes when I add more output in the right column page. If I have too many echo statements, or if the html is too long, then I get the error. But if I minimize this, the error disappears! I can't understand why it sometimes works and sometimes does not. I would think that if it was because of an echo statement ahead of it, then it would never work at all, no? I hope someone can help me understand what might be happending here. My head is starting to hurt with this one. Ouch.
  6. [!--quoteo(post=353107:date=Mar 8 2006, 08:52 PM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Mar 8 2006, 08:52 PM) [snapback]353107[/snapback][/div][div class=\'quotemain\'][!--quotec--] Just to add on to this bug, I've noticed mixed bugs with IE. Sometimes the script executes without the error, and other times with the error. I'm stumped at the moment. [/quote] My goodness, that was a strange bug. I don't know why it worked sometimes and not other times. Anyway, I fixed it. It was pretty simple once I tracked it down. (aren't most bugs that way?) Basically, I had an include function in the middle of a div tag. I changed the include variable for different needs. The publish script didn't like it because it was trying to call a header function, but the div tag was output already. I moved the include to before the tag for the publish case only. I still don't know why it worked prior to this for weeks. Strange, but I'm glad it's fixed.
  7. Just to add on to this bug, I've noticed mixed bugs with IE. Sometimes the script executes without the error, and other times with the error. I'm stumped at the moment.
  8. I'm programming a complex site full of many scripts working together. Everything is humming along nicely. I have a side bar section that comes before the main body section (due to my css layout). In my side bar, I have a member box that uses session variables and a little logic to say hello to the user when they are logged in. I also have some cart info that displays when the cart variables are in use. In another section in my script, I have a large script that publishes an item. Here's the bug. If I display the user's name and the line that shows the cart variables, the item publishes perfectly with no errors. However, if I add another line above the the cart info (which is part of a single variable that gets echoed) I get the ugly headers already sent error. example: [code] if I do it like this: $cartinfo = "<span class='bluetext' >$t $item, Sub-Total: $$subtotal</span>"; ...and then a few lines down in the html: <?php echo $cartinfo;?> it works just fine... ---------------------------- but if I do this: $cartinfo = "<a href=\"?page=cart\">Your Cart:</a><br /> <span class='bluetext' >$t $item, Sub-Total: $$subtotal</span>"; <?php echo $cartinfo;?> I get the header sent error? --------------------------- and if I do this: $cartinfo = "<a href=\"?page=cart\">Your Cart:</a><br />"; and leave out the cart variables, it works fine also... [/code] The problem only appears when I have the link and the variable info in the cartinfo variable together! Anyone have an idea as to why this is the case? Any tips? Thanks...
  9. Hi all, I have a question for the pros. In my cart, each item has a checkbox for removal and an input box for changing the quantity. I have several buttons that are all submit buttons handled by JS. All the buttons work, that's not a problem. However, if a user changes the qty amount and hits return or enter, the remove button is used which is not what I want! I would like the update button to be used. I think it's defaulting to the remove button because it's first. Is there an easy way to change the focus of the qty input field so that an enter will automatically update and not attempt to remove? Thanks for any tips you may have.
  10. Well, I think I came up with an easy and elegant solution. I think this would work with POST as well as GET. I'm going to continue using GET for the cart. However, when I'm done with my add item script, I will simply reload the page without the additem in the url. This way the page can be refreshed without adding another item. The back button will take you back to the item you were looking at. You can add the item again and it will increment. It works, I love it!
  11. I'm refining my shopping cart right now. I have been using GET variable when adding an item to the cart. (as opposed to POST variables) One reason I don't like POST for this purpose is that if the user refreshes the page, they get the annoying WARNING regarding POST data. However, with the GET method, after an item has been added to the cart (?additem=1234), if the user refreshes the page, the item gets added again (if the item can be sold multiple times). Some sites don't let items increment in a cart unless the user changes the item quantity in the cart and then updates the cart. Other sites let you click the add cart item again and the item increments by 1. I've figured out a solution for this using a session switch. It's not hard to do, but I'm just curious as to what other's preferred method is for carts - if you have a cart on your site. Anyone?
  12. [!--quoteo(post=346875:date=Feb 17 2006, 04:02 PM:name=ChrisDarl)--][div class=\'quotetop\']QUOTE(ChrisDarl @ Feb 17 2006, 04:02 PM) [snapback]346875[/snapback][/div][div class=\'quotemain\'][!--quotec--] The code that i put works, you can put whatever code you like betwee n the { } be it running another function or not. [/quote] Thanks both of you. I'll try out both or your suggestions and see how it goes. Cheers.
  13. [!--quoteo(post=346489:date=Feb 16 2006, 02:50 PM:name=ChrisDarl)--][div class=\'quotetop\']QUOTE(ChrisDarl @ Feb 16 2006, 02:50 PM) [snapback]346489[/snapback][/div][div class=\'quotemain\'][!--quotec--] And you've set it out like the code bellow? window.onload = function() { [JavaScript Code to run on load] }; Chris [/quote] Well, I had been using this method, perhaps this was wrong? function load(){ executeotherfunction(); }; window.onload = load(); then, I found this and tried it: function loadmeup(){ executeotherfunction(); }; var OnLoad = 'loadmeup()'; window.onload = function() {eval(OnLoad);}; and it seems to work in IE. I haven't had a problem with Firefox. I'll try it the other way and see what happens, thanks!
  14. Help!! Argh! Things are going along just fine, until I start getting this error in IE while using a window.onload = function(); I get this error 'not implemented'. The strange thing is that the function still executes, but I get this error and I can't get rid of it. ?????
  15. [!--quoteo(post=345932:date=Feb 14 2006, 10:53 PM:name=mmosel)--][div class=\'quotetop\']QUOTE(mmosel @ Feb 14 2006, 10:53 PM) [snapback]345932[/snapback][/div][div class=\'quotemain\'][!--quotec--] Hi all, I'm working on a little javascript and I've come upon a lil' snag. [code]if ( picon == 0){     //alert (srcimg); document.imageinstruct1.src = 'ui/showhelp.gif'; }else{ document.imageinstruct1.src = 'ui/hidehelp.gif'; }[/code] The part that I'm having a problem with is the document.variable.src, where I would like to use a variable that may have different values in that middle spot. As of now I can't get it to work, so I have to type in the actual name value of the image I want to swap. I don't want to have to write multple functions where one should do the trick. Is this possible? If so, what's the trick? Another example would be: [code]var myvar = 'main'; document.myvar.src = 'image1.jpg';[/code] Any ideas or suggestions? [/quote] Well, I stumbled onto a solution. Instead of using the name tag I used the id tag, which allowed me to use this: document.getElementById(myvar).src = 'ui/showhelp.gif'; Works...
  16. Hi all, I'm working on a little javascript and I've come upon a lil' snag. [code]if ( picon == 0){     //alert (srcimg); document.imageinstruct1.src = 'ui/showhelp.gif'; }else{ document.imageinstruct1.src = 'ui/hidehelp.gif'; }[/code] The part that I'm having a problem with is the document.variable.src, where I would like to use a variable that may have different values in that middle spot. As of now I can't get it to work, so I have to type in the actual name value of the image I want to swap. I don't want to have to write multple functions where one should do the trick. Is this possible? If so, what's the trick? Another example would be: [code]var myvar = 'main'; document.myvar.src = 'image1.jpg';[/code] Any ideas or suggestions?
×
×
  • 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.