The place for more technical questions for those who want to create new pagetypes or bespoke functionality.

PHP - unable to update database

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
8 jaren 10 maanden geleden #4705 door jayaich
Beantwoord door jayaich in topic PHP - unable to update database
Okay, on my modified upgrade program I had to add:
Code:
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
after establishing the connection.
Running the program I then get the following output shown:

Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1142 ALTER command denied to user 'xerteuser'@'localhost' for table 'sitedetails' in /var/www/html/xerte-3.5/jhf.php on line 37
Array ( [0] => 00000 [1] => [2] => )

Line 37 corresponds to the execute statement.

It's odd though because the user does have permissions, and if I run the command by hand as that user, then it works.
So, not sure if I'm a bit closer with this or not!

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Meer
8 jaren 10 maanden geleden - 8 jaren 10 maanden geleden #4706 door tom
Beantwoord door tom in topic PHP - unable to update database
Found it.

Because I coincidently happened to run into the same problem....

The _db_add_field() function basically is not able to handle fields of type 'text'.

A type text is a blob in mysql, and blob types cannot have a default value, but _db_add_field() tries to set the default value.

So either change the type to a varchar, or modify _db_add_field() to be able to handle text fields.

I haven't touched the code.
Laatst bewerkt 8 jaren 10 maanden geleden door tom.

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
8 jaren 10 maanden geleden #4708 door jayaich
Beantwoord door jayaich in topic PHP - unable to update database
Erm... no :-)
I know what you mean about globs not having a default (despite NULL seeming to be an obvious default for text fields). But mysql does not actually object to a TEXT default so long as it is '' (2 single quotes) or set to NULL (not the string "NULL" which _db_add_field does.) Setting any other default does give an error saying that globs/text cannot have a default.
(Tested with mariadb 5.5.56).
I did try setting the field to something other than text (I used char(255)), but it gave the same error.

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

  • jayaich
  • Onderwerp Auteur
  • Offline
  • Premium lid
  • Premium lid
Meer
8 jaren 10 maanden geleden #4709 door jayaich
Beantwoord door jayaich in topic PHP - unable to update database
Okay, the problem was permissions!
The error is confusing because it says

...ALTER command denied to user 'xerteuser'@'localhost' for table...

If I check that users permissions then they have all permissions.
However, in database.php the host is '127.0.0.1', and for that user ('xerteuser'@'127.0.0.1') the permissions are just select, insert etc. So by allowing the user 'xerteuser' @'127.0.0.1' the ALTER permission, the script then works fine in adding the new field.
I guess when I added the field manually from the command line it was because I was seen as being from 'localhost'.

Anyway, problem solved. Many thanks for your help.

Graag Inloggen of een account aanmaken deelnemen aan het gesprek.

Moderators: JohnSmith
Tijd voor maken pagina: 0.134 seconden
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo