Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
The place for more technical questions for those who want to create new pagetypes or bespoke functionality.
  • Page:
  • 1
  • 2

TOPIC:

PHP - unable to update database 6 years 7 months ago #4705

  • jayaich
  • jayaich's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 92
  • Thank you received: 5
Okay, on my modified upgrade program I had to add:
$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!

Please Inloggen or Create an account to join the conversation.

PHP - unable to update database 6 years 6 months ago #4706

  • tom
  • tom's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 1293
  • Thank you received: 308
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.

Please Inloggen or Create an account to join the conversation.

Last edit: by tom.

PHP - unable to update database 6 years 6 months ago #4708

  • jayaich
  • jayaich's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 92
  • Thank you received: 5
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.

Please Inloggen or Create an account to join the conversation.

PHP - unable to update database 6 years 6 months ago #4709

  • jayaich
  • jayaich's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 92
  • Thank you received: 5
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.

Please Inloggen or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: JohnSmith
Time to create page: 0.049 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search