Re: "call to undefined function" mysql_error when adding new rows to table



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

.



Relevant Pages

  • Re: Itanium Port Question
    ... It is a fine and good practice to have the primary key be the first ... if you have no reason for it to be elsewhere. ... By physicaly storing the primary key up front, rms does not have to ... I found RMS compression to ALWAYS be a net CPU AGAIN. ...
    (comp.os.vms)
  • Re: Primary Key and Indexes, are they necessary?
    ... The vendor responsed that the reasons they do not add the primary key ... Indexes do slow down data entry. ... Indexes should always be evaluated and have a reason for existing. ... In Oracle 10g, the Cost Based Optimizer has been improved to the point ...
    (comp.databases.oracle.misc)
  • Re: Primary Key and Indexes, are they necessary?
    ... The vendor responsed that the reasons they do not add the primary key ... Indexes do slow down data entry. ... Indexes should always be evaluated and have a reason for existing. ... In Oracle 10g, the Cost Based Optimizer has been improved to the point ...
    (comp.databases.oracle.misc)
  • Re: One to One - Multilple tables for large field qty
    ... If I add the third one-to-one, the primary key ... If you were advised to normalize your data, there's a reason. ... On the header table there is a form ID (primary ... joining the same FormID. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Restoring deleted autonumber
    ... Follow-up questions should in general be posted to the ... >> reason: to provide a unique value that can be ... >> as a primary key. ... >> that the value of the autonumber gets displayed. ...
    (microsoft.public.access.tablesdbdesign)