The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

PHP/MySQL question

Sorry I didn't really know where to post this!

I am having a problem with a web application, each time I place something into the database it creates a second entry which is blank. This only happens for three secions and the other three enter the data into mysql perfectly without any problems.

I have tried everything that I can think of, re-writing the sql statements, checking all lines of code but have been unable to find the problem,

Has anyone come accross this before?

Any Help is greatly appreicated
Thursday, May 19, 2005
Nodoby can possibly answer this without seeing the code. I think the best place to ask this type of question is within the PHP forum run by Sitepoint at
Tony Marston Send private email
Thursday, May 19, 2005
Is the mysql_query() in any kind of loop that might be executing twice? If so, the variables might not be  getting set properly.

You could always put in a temporary debug print statement that outputs the exact query being executed right before the actual mysql_query() is executed:

  print "<pre>$query</pre>\n";
  $result = mysql_query($query, $db_handle);

That might help you figure out what's happening.
Thursday, May 19, 2005
Check out has some useful debugging output (not that you can't write your own).

Thursday, May 19, 2005
Are you posting say a form or a querystring to a page, then doing a redirect back to the page after a successful db update?

This might cause the update to be performed again, only this time without any posted values, hence your blank entry in the database.
Joe Send private email
Friday, May 20, 2005
OK, this is going to be a lame try, but its a similar 'sounding' issue to the one Dan's posted.

When you read data from a mysql database in PHP you always have a duplicate set of data with index as 'numbers' rather than the fieldnames.

Dan, are you by any remotest of chances reading 'this' data which is 'almost always' repeated when you pull data from mysql.
for e.g.

array a (
[name]=> 'Dan', [0]=> 'Dan',
[email]=> '', [1]=> '',

I apologize in case you need the moon when I am shooting at Andromeda Galaxy ... :)
Robins Tharakan Send private email
Monday, May 23, 2005
Thank you all for your replies.

You can all hopefully laugh at the solution now...I had to flush the database and then it stopped duplicate entries

This happened to me two years ago and a friend who was helping on that project suggested it, woo, all is good in the world again!

Thanks for the replies tho, its must appreicated as at this point I was pulling my hair out!


Sunday, June 12, 2005

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz