Yani Posted February 2, 2007 Share Posted February 2, 2007 My first post here... so here goes: I ran into a strange problem recently. I noticed that when I use firefox, values from different form elements won't be stored in the database. Here's what happens: -I click submit on the form page and it takes me to the same page. -A php script at the start of the page notices if there's any form data. -In this case there will only be data from 1 textarea -After updating the mysql database with new values, I check that everything's in order. ->mysql_query("SELECT...") and mysql_fetch_assoc() return the correct values, so everything should be fine -Just to be sure, I double checked the database using the same query at the very end of the index page and still got the same good results. So at the end of the page the values are still in the database, according to my query at least. However when I reload the page or even check it with phpmyadmin right after I've submitted the form, there won't be anything in the 'text'-field of the used row. I'm not sure what happens here. My best guess is that mysql doesn't save directly to the database. It makes me wonder though, what is so different about firefox that even after confirming the data is actually there, it really isn't. This happens ONLY on firefox How can the browser even affect anything what's happening on server-side? Shouldn't it just download the content php has already generated? I think you get the idea.. I hope this has happened to someone else before. Seems kinda hard to believe as-is:D Quote Link to comment Share on other sites More sharing options...
fenway Posted February 2, 2007 Share Posted February 2, 2007 Not sure, probably has to do with how the POST data is coming through. Quote Link to comment Share on other sites More sharing options...
Yani Posted February 3, 2007 Author Share Posted February 3, 2007 It kinda makes sense. If the problem occurs only on firefox, the only things between php and the browser related to the problem is the POST data. The strangest thing is that after updating the database, I get 100% correct results with mysql select. Is there some kind of temp database for all mysql connections? I mean when the connection is established to the mysql server, php or mysql software creates a copy of the used db into eg. ram and for some odd resason concerning the POST data the temp db won't be saved. Seems kinda farfetch'd but so does the problem:D I hope there is someone who knows how these things work on the inside. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 If it's a browser issue, it has nothing to do with the DB. Quote Link to comment Share on other sites More sharing options...
Yani Posted February 5, 2007 Author Share Posted February 5, 2007 That's probably it. As I mentioned before, I'd like to know how php & mysql work in this case. After all, all the browser does is send incorrect POST data(I think). PHP deals with the actual processing. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 There's nothing magical about it... there's no "temp" area. Quote Link to comment Share on other sites More sharing options...
Yani Posted February 5, 2007 Author Share Posted February 5, 2007 okay, so how is it possible to fetch the submitted values right after updating the mysql table but still they disappear after reloading the page? I'm not doubting you, just curious Quote Link to comment Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 okay, so how is it possible to fetch the submitted values right after updating the mysql table but still they disappear after reloading the page? I'm not doubting you, just curious I'm not sure I understand... fetch from where? Quote Link to comment Share on other sites More sharing options...
Yani Posted February 5, 2007 Author Share Posted February 5, 2007 I'll put it this way: -at the very start of index.php, we have an init script, which does some form data processing and other stuff. -say we have a row with id "foo" and previous value "a". During the init script, we store the new data(value="b") using 'UPDATE' -to be sure the data really is there, we check it using 'SELECT' ->what we get is "b". That means the new value really is there. -after the init scripts we have the regular html code with some php and SELECT-queries and not a single query that alters the database in any way. -to double check, we have the same 'SELECT'-query at the end of the page. ->the query also returns value="b" At this point, it should be sure that the data is really there, right? Well, now we open up phpmyadmin to check once more. What we find is a row with id "foo" and value not "a" nor "b", but just ""(without the quotes of course) Get the idea? Quote Link to comment Share on other sites More sharing options...
shoz Posted February 5, 2007 Share Posted February 5, 2007 Post the script. If it's too long, post the relevant sections that deal with the UPDATE and the verification of the values. Quote Link to comment Share on other sites More sharing options...
fenway Posted February 5, 2007 Share Posted February 5, 2007 Seems strange... InnoDB tables? Maybe there's a consistency issue here. Quote Link to comment Share on other sites More sharing options...
Yani Posted February 6, 2007 Author Share Posted February 6, 2007 A strange solution to a strange problem. At the end of the <body> section I have a set of <div>s which are used for fade-in image preview. Apparently I have left the src of the img empty because it would be anyway replaced with javascript when clicking image thumbnail. Guess what happened when I changed the src to anything else but empty? Here's the source of index.php. There won't be any actual content since that is loaded thru an included file You can see the last set of divs(starting with <div class="center") at the bottom of the code. There's the img-tag which caused all this. I'm pretty sure you could use that same code to mess up your page if you'd like to experiment There aren't any comments, but I bet most of you wouldn't even understand finnish <?php include("config.php"); include("scripts/scripts.php"); include("scripts/init.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <?php include("scripts/tinymce.php"); ?> <link rel="stylesheet" type="text/css" href="blackdesign.css" /> <script src="scripts/javascript.js" type="text/javascript"></script> <?php if(CheckAdmin()) { echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"./admin.css\" />"; } ?> <title>JUUUU</title> </head> <body> <div id="topbar"></div> <div class="center"> <div id="main"> <div id="header"> <div id="menu"> <?php include("sivunosat/mainmenu.php"); ?> </div> </div> </div> </div> <div class="contentcenter"> <div id="vmenu"> <?php include("sivunosat/vmenu.php"); ?> </div> </div> <div class="contentcenter"> <div id="content"> <?php include("sivunosat/content.php"); ?> </div> </div> <div class="contentcenter"> <div id="minigallery"> <?php include("sivunosat/minigallery.php"); ?> </div> </div> <div id="admintext"><a href="?p=admin">Admin</a></div> <div class="center"> <div id="blur"> <div id="blurmain"> <img id="largeimage" onclick="HideImage()" alt ="" src="whii" /> <div id="largeimage_text"></div> </div> </div> </div> </body> </html> <?php $Query="SELECT * FROM sivut WHERE sivuid='$SubPage'"; echo $Query; $Result=mysql_query($Query); $Row=mysql_fetch_assoc($Result); print_r($Row); mysql_close(); ?> Quote Link to comment Share on other sites More sharing options...
fenway Posted February 6, 2007 Share Posted February 6, 2007 Interesting... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.