Page 1 of 1

File upload to database

Posted: Thu Jun 20, 2024 9:29 am
by iggabz

Good day,

i have followed the instructions on https://phpmaker.dev/docs/#/fileuploaddb.html

but i have this error during click add "An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '??u?J?Č66??F?!jd? N&???:2J?@$?"????????o??vz?3̛#v???a??AɫQ...' at line 1".

if i return to the list page, the attachment is fine.

any tip please to resolved the error?


Re: File upload to database

Posted: Thu Jun 20, 2024 10:27 am
by arbei

Make sure:

  1. Your project uses utf-8 charset,
  2. Your field supports binary (e.g. BLOB data type) data, not text,
  3. Your field size is large enough.

Re: File upload to database

Posted: Thu Jun 20, 2024 10:40 am
by iggabz
  1. how to check?
  2. the field intended is already set to longblob
  3. size is automatically set to 4294967295

Re: File upload to database

Posted: Thu Jun 20, 2024 10:57 am
by arbei
  1. Check charset, make sure it is "utf-8".
  2. Are you uploading a very large file? If yes, test with a smaller file.

Re: File upload to database

Posted: Thu Jun 20, 2024 11:03 am
by iggabz
  1. charset is already utf-8
  2. attachment allowed is only pdf, file cap is 2000000bytes. so far test upload is under 1000KB

Re: File upload to database

Posted: Thu Jun 20, 2024 11:46 am
by iggabz
#0 C:\xampp\htdocs\project\vendor\doctrine\dbal\src\Connection.php(1939): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query))
#1 C:\xampp\htdocs\project\vendor\doctrine\dbal\src\Connection.php(1881): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query))
#2 C:\xampp\htdocs\project\vendor\doctrine\dbal\src\Connection.php(1213): Doctrine\DBAL\Connection->convertExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDO\Exception), 'INSERT INTO tbl...', Array, Array)
#3 C:\xampp\htdocs\project\src\phpfn.php(6032): Doctrine\DBAL\Connection->executeStatement('INSERT INTO tbl...')
#4 C:\xampp\htdocs\project\models\TblGrsTracks.php(2353): PHPMaker2024\project1\ExecuteStatement('INSERT INTO tbl...')
#5 C:\xampp\htdocs\project\models\TblGrsTracksAdd.php(1720): PHPMaker2024\project1\TblGrsTracks->rowInserted(NULL, Array)
#6 C:\xampp\htdocs\project\models\TblGrsTracksAdd.php(613): PHPMaker2024\project1\TblGrsTracksAdd->addRow(NULL)
#7 C:\xampp\htdocs\project\controllers\ControllerBase.php(34): PHPMaker2024\project1\TblGrsTracksAdd->run()
#8 C:\xampp\htdocs\project\controllers\TblGrsTracksController.php(31): PHPMaker2024\project1\ControllerBase->runPage(Object(Slim\Http\ServerRequest), Object(Slim\Http\Response), Array, 'TblGrsTracksAdd')
#9 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Handlers\Strategies\RequestResponse.php(38): PHPMaker2024\project1\TblGrsTracksController->add(Object(Slim\Http\ServerRequest), Object(Slim\Http\Response), Array)
#10 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Routing\Route.php(363): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Http\ServerRequest), Object(Slim\Http\Response), Array)
#11 C:\xampp\htdocs\project\src\PermissionMiddleware.php(117): Slim\Routing\Route->handle(Object(Slim\Http\ServerRequest))
#12 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(280): PHPMaker2024\project1\PermissionMiddleware->__invoke(Object(Slim\Http\ServerRequest), Object(Slim\Routing\Route))
#13 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(73): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#14 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(73): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest))
#15 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Routing\Route.php(321): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest))
#16 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Routing\RouteRunner.php(74): Slim\Routing\Route->run(Object(Slim\Http\ServerRequest))
#17 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Middleware\BodyParsingMiddleware.php(65): Slim\Routing\RouteRunner->handle(Object(Slim\Http\ServerRequest))
#18 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): Slim\Middleware\BodyParsingMiddleware->process(Object(Slim\Http\ServerRequest), Object(Slim\Routing\RouteRunner))
#19 C:\xampp\htdocs\project\src\CorsMiddleware.php(35): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#20 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): PHPMaker2024\project1\CorsMiddleware->process(Object(Slim\Http\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#21 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#22 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Http\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#23 C:\xampp\htdocs\project\src\LaravelSessionMiddleware.php(45): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#24 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): PHPMaker2024\project1\LaravelSessionMiddleware->process(Object(Slim\Http\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#25 C:\xampp\htdocs\project\vendor\hkvstore\samesite-cookie\src\SameSiteCookieMiddleware.php(52): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#26 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): Selective\SameSiteCookie\SameSiteCookieMiddleware->process(Object(Slim\Http\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#27 C:\xampp\htdocs\project\vendor\hkvstore\samesite-cookie\src\SameSiteSessionMiddleware.php(52): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#28 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): Selective\SameSiteCookie\SameSiteSessionMiddleware->process(Object(Slim\Http\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#29 C:\xampp\htdocs\project\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(77): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#30 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(129): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Http\ServerRequest), Object(Psr\Http\Server\RequestHandlerInterface@anonymous))
#31 C:\xampp\htdocs\project\vendor\slim\slim\Slim\MiddlewareDispatcher.php(73): Psr\Http\Server\RequestHandlerInterface@anonymous->handle(Object(Slim\Http\ServerRequest))
#32 C:\xampp\htdocs\project\vendor\slim\slim\Slim\App.php(209): Slim\MiddlewareDispatcher->handle(Object(Slim\Http\ServerRequest))
#33 C:\xampp\htdocs\project\vendor\slim\slim\Slim\App.php(193): Slim\App->handle(Object(Slim\Http\ServerRequest))
#34 C:\xampp\htdocs\project\index.php(150): Slim\App->run()
#35 {main}

this is the error code


Re: File upload to database

Posted: Thu Jun 20, 2024 6:14 pm
by arbei

iggabz wrote:

#3 C:\xampp\htdocs\project\src\phpfn.php(6032): Doctrine\DBAL\Connection->executeStatement('INSERT INTO tbl...')
#4 C:\xampp\htdocs\project\models\TblGrsTracks.php(2353): PHPMaker2024\project1\ExecuteStatement('INSERT INTO tbl...')
#5 C:\xampp\htdocs\project\models\TblGrsTracksAdd.php(1720): PHPMaker2024\project1\TblGrsTracks->rowInserted(NULL, Array)

Then you better double check your code in the Row_Inserted server event, in which you have some code to execute an INSERT statement, make sure it is correct.


Re: File upload to database

Posted: Fri Jun 21, 2024 8:56 am
by iggabz

Thank you for this.

additional question: will this file upload to database work on view table, will the uploaded file show?


Re: File upload to database

Posted: Fri Jun 21, 2024 9:33 am
by arbei

What did you mean by "view table"? You may test yourself. If you mean database view, it depends on the SQL of your view, if more than one table, you may not be able to update the view.


Re: File upload to database

Posted: Tue Jun 25, 2024 12:46 am
by DGarza

iggabz wrote:

additional question: will this file upload to database work on view table, will the uploaded file show?

I guess it is a normal view right? If that column its of the main table, yes yo can, but it the column its references to another table, yu can not upload