You are here: Re: "call to undefined function" mysql_error when adding new rows to table « All PHP « IT news, forums, messages
Re: "call to undefined function" mysql_error when adding new rows to table

Posted by davek on 07/14/06 21:35

JDS wrote:
> It is, but in the future, post to both groups AT THE SAME TIME!!!

Sorry, I posted to the other group before I realised there was this
group as well. Will be more careful in future.

Anyway, here's the code that was causing the problem:
1. if (@mysql_query($makechanges)) {
2. echo "<p>$pubname has been added to database</p>";
3. } else {
4. echo "<p>Error updating database: " . mysqlerror() . "</p>";
5. }

Spot the deliberate mistake in line 4!

The reason I hadn't noticed this before was because the if condition
had never returned a false result before! With that fixed, this is the
error message:

Error updating database: Duplicate entry '127' for key 1

ie, for some reason, the INSERT query is trying to enter the new row
with the same primary key as an already existing row, which it
shouldn't be as it's set to auto_increment.

I think this is something for my webhost to sort out. Thanks for your
patience...

David

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация