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

PHP - unable to update database

Plus d'informations
il y a 8 ans 10 mois #4705 par jayaich
Réponse de jayaich sur le sujet 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!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 8 ans 10 mois - il y a 8 ans 10 mois #4706 par tom
Réponse de tom sur le sujet 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.
Dernière édition: il y a 8 ans 10 mois par tom.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 8 ans 10 mois #4708 par jayaich
Réponse de jayaich sur le sujet 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.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 8 ans 10 mois #4709 par jayaich
Réponse de jayaich sur le sujet 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.

Connexion ou Créer un compte pour participer à la conversation.

Modérateurs: JohnSmith
Temps de génération de la page : 0.134 secondes
Copyright © 2026 The Xerte Project.
Xerte logo Apereo logo OSI Logo