Jump to content

[SOLVED] Strange problem with mysql&firefox


Yani

Recommended Posts

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 :D

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

Link to comment
Share on other sites

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.:)

Link to comment
Share on other sites

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?:)

Link to comment
Share on other sites

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? :D

 

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 :P

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();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.