Menu

SQLSTATE[42000]: Syntax error or access violation

Help
Ardy
2016-05-20
2016-12-24
  • Ardy

    Ardy - 2016-05-20

    Hello All,
    I really could use some help....I love to get this program going, becuse I love to be able to get my FamilyTree progect off my PC and make it accessebale to all the family members spread around the world........

    Operating system: Win server 2008R2
    MySql: 5.7.12
    PHP: 5.3.28
    PGV: 4.2.4
    IIS: 7.5

    I insatlled PHP, it is running fine I get PHP info via web, All is good. MySQL is installed and running fime.

    I have un-packed all the files under the webserver in a directory labeled phpgedview, and gave appropriate rights to all recommanded directories to include config.php. I created an schima in MySql first, also created a user specifically for use for this. gave the user all the needed rights.
    Ran the install.php the first thing I experianced was config.php is not writable. This according to some treads is OK becuse I can add the changes mannually, I gave it all the database connection strings and then i get this error SQLSTATE[42000]: Syntax error or access violation: 1171 All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead

    I looked into the MySql, it did create 16 tables in total........I am lost at this point....can somebody help me or give me a direction to be able to solve this.........

    Ardy

     
  • Lester Caine

    Lester Caine - 2016-05-20

    Which version of PGV did you download. The SF copies are aout of date, so you need the SVN version.
    I should probably kick you over to 'webtrees', but PGV is getting support these days and I would like to get it more actively used again.

     
  • Gerry Kroll

    Gerry Kroll - 2016-05-20

    As Lester said:
    Since you're just starting out, you should consider Webtrees in preference to PhpGedView. Webtrees is properly supported, while PhpGedView has been more-or-less stagnant for a long time, with only sporadic updates taking place.

    If you really MUST use PhpGedView, you should be using the "SVN" version. You need to be sure to give the proper rights to everything: 755 for all directories and their contents except file /config.php and the /media and /index directories, which need 777. Since you're starting from scratch, there will be no config.php file -- copy the /config.dist file and name the copy /config.php before giving it 777 permission.

    The SQL error is troubling. PGV should have created at least 30 tables. Give us a list of the table names that WERE created, and we can then tell which one is causing the error.

     
    • Ardy

      Ardy - 2016-05-20

      Thanks for the reply.....
      I don't have any strong feeling abt phpgedview, and I htink I will take your suggestion and try Webtrees......

      Thank you.......

       
  • John Taylor

    John Taylor - 2016-12-19

    Has anyone solved this problem? I tried to do a clean install with the SVN branch and got this result. Eventually I will shift over to Webtrees but I have a pretty complicated custom module for PGV that I want to keep working.

     
  • Gerry Kroll

    Gerry Kroll - 2016-12-19

    This problem cannot be solved without seeing a list of the tables that were produced. I haven't seen this list yet.

    PGV works OK for me.

     
  • John Taylor

    John Taylor - 2016-12-19

    Hi Gerry! I did not start this thread but I do have the same problem. Attached in the list of tables and mysql files created. I hope that helps

     
    • Lester Caine

      Lester Caine - 2016-12-19

      On 19/12/16 19:56, John Taylor wrote:

      Hi Gerry! I did not start this thread but I do have the same problem.
      Attached in the list of tables and mysql files created. I hope that helps

      Attachments:

      Ardy moved over to Webtrees so it was not actually pursued, and I can't
      help because I don't run MySQL ;) My copy of PGV is running on Firebird
      and that is my reason for not wanting to switch to webtrees ...

      My guess at the time was that when it's trying to create the initial
      entries it's missing the primary key for some reason. Once you have the
      initial entries created everything is fine which is why Gerry is OK. The
      thing we need to establish is just what table it's trying to update so
      we can see which record is a problem. The fact that PHP has moved a few
      goal posts around NULL handling my be adding to the problem. It may need
      a '0' adding where previously NULL would just have morphed into a '0' ...

      I do now have a copy of MySQL on the development machine so if I get
      some time I'll have a go at a clean install again using the current SVN.

      --
      Lester Caine - G8HFL


      Contact - http://lsces.co.uk/wiki/?page=contact
      L.S.Caine Electronic Services - http://lsces.co.uk
      EnquirySolve - http://enquirysolve.com/
      Model Engineers Digital Workshop - http://medw.co.uk
      Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

       
  • Gerry Kroll

    Gerry Kroll - 2016-12-19

    Weird, .....

    I just did a fresh install, and things went perfectly.

    I used a target directory different from the one I normally use, and also a table name prefix different from my normal one. Same database, though.

    I don't depend on the PhpGedView installation wizard to create the starting config.php file because that can lead to incorrect permissions being set. After uploading, I change the name of the config.dist file to config.php, and then upload another copy of the config.dist file.

    Initially, the config.php file should be world-writable, and the /index and /media directories need 777 permissions.

    Are you sure that you've allowed enough memory for PhpGedView? The default 32 Mb is definitely not enough. You should allow at least 64 Mb.

     
  • John Taylor

    John Taylor - 2016-12-19

    I have 128M allowed in PHP. The system is a fresh install of Fedora 25 with all the latest shiny stuff. (my working pgv is running on a FC13 system which is why updating is a major pain.) I did a webtrees install as well and it did not complain. I attached my system info if that is any help.
    Is there a debug mode to increase the logging level?

     
  • Gerry Kroll

    Gerry Kroll - 2016-12-20

    According to the list of tables that were created, the error occurred in the script "includes/db_schema/db_schema_2_3.php" around line 271.

    According to the available documentation, mysql 5.7 implemented a strict interpretation of the "primary key" specification. All fields involved in a primary key must now have the "NOT NULL" constraint. This is missing on line 271.

    This same error probably occurs in other places in the various db_schema files. A fix that you can try will be forthcoming tomorrow. Stay tuned.

     

    Last edit: Gerry Kroll 2016-12-20
  • Gerry Kroll

    Gerry Kroll - 2016-12-20

    The error is caused by "improvements" made to the way mysql 5.7 handles primary keys. As the error message says, you need to specify NOT NULL for all primary keys during table creation.

    Only one CREATE TABLE statement in all of PhpGedView has the "NOT" missing on a primary key.

    You can fix the error yourself:
    Edit line 271 of file "includes/db_schema/db_schema_2_3.php" to add "NOT " in front of "NULL".

    After having made the change, you can re-launch the failed install. It will pick up where it previously stopped.

    Note: The script "includes/db_schema/db_schema_6_7.php", run later in the Install sequence, modifies the s_file column to add the missing "NOT ", but that's too late for mysql 5.7

    I'll update the SVN repository to reflect this correction.

     
  • John Taylor

    John Taylor - 2016-12-20

    That fixed the db issue. Now another problem has popped up during installation. I renamed the config.dist (keeping a copy as config(copy).dist ) to config.php and chmod 777
    Parse error: syntax error, unexpected '<', expecting end of file in /var/www/newmans/PhpGedView/includes/functions/functions.php(345) : eval()'d code on line 1

     
  • Gerry Kroll

    Gerry Kroll - 2016-12-20

    Your config.php file is messed up. PhpGedView attempts to verify that each line in the config.php file is a valid PHP statement. Clearly, one of them isn't.

    Your procedure for manually editing the config.php file is faulty.

    I suggest that you make a copy of the distribution config file, "config.dist" and name it config.php. Transfer this renamed file to your PhpGedView directory, and give it 777 rights until the site is up and running.

     
  • John Taylor

    John Taylor - 2016-12-20

    I did not do any edits of the config.php. simply cp and chmod. I am going to do a clean install and see if i get anything different.

     
  • Gerry Kroll

    Gerry Kroll - 2016-12-20

    A possibility that comes to mind is that the database credentials contain an illegal character (probably a quotation mark), thus resulting in a config.php script that's not valid PHP code.

     
  • John Taylor

    John Taylor - 2016-12-20

    that is quite possible. is a "!" illegal? I think that I was required to have a symbol in the password now. I will go try and change it.

     
  • John Taylor

    John Taylor - 2016-12-20

    I have not been able to figure out how to set Fedora 25 into simple password mode. Here is the config.php file that I am using. It matches config.dist from SVN

     
  • Gerry Kroll

    Gerry Kroll - 2016-12-20

    Yes, the "bang" is allowed in a PHP string. Apostrophes are OK.

    You must avoid backslash, dollar sign, and quotation mark. These symbols have special meanings when they occur inside a PHP string that is enclosed in quotation marks. An embedded quotation mark would need to be preceded by a backslash, as would an embedded backslash or dollar sign.

     
  • John Taylor

    John Taylor - 2016-12-24

    Is there a verbose debug setting for PHP that might be helpful?

     
    • Lester Caine

      Lester Caine - 2016-12-24

      On 24/12/16 19:21, John Taylor wrote:

      Is there a verbose debug setting for PHP that might be helpful?

      The error_reporting is the only thing that can be used to swich levels
      of error reporting. But session.php should be set displaying all errors
      already.

      My own copy of PGV runs under ADOdb which has it's own debug system for
      the SQL traffic, but I think your problem was moved beyond that area. I
      use eclipse and it's error checker normally picks up errors in files
      before I ever run the stuff.

      --
      Lester Caine - G8HFL


      Contact - http://lsces.co.uk/wiki/?page=contact
      L.S.Caine Electronic Services - http://lsces.co.uk
      EnquirySolve - http://enquirysolve.com/
      Model Engineers Digital Workshop - http://medw.co.uk
      Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

       
  • Gerry Kroll

    Gerry Kroll - 2016-12-24

    John:
    If you're still having problems, please e-mail me a copy of your config.php file. It's impossible to figure out what's wrong without seeing the configuration file that PhpGedView is choking on. I do not want to see the configuration file that's used as input to the Install wizard. I need to see the result of the wizard's actions.

    Use this e-mail address, please: gkroll@keldine.ca

    Above all, DO NOT post the config.php file in any on-line forum.

     

Log in to post a comment.