Error connecting to SQL Server using PDO in PHP [duplicate] - php

My Ubuntu vagrant Laravel Homestead set up has been configured to connect to MSSQL. Randomly it's starting throwing the following error on every query going to the MSSQL database (on a Windows server).
Any ideas? I can't find much info re:this available on Google.
I restarted PHP and confirmed SQLSRV modules are loaded.
SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. (SQL: select top 10 * from [orders] where [ordertype] = SO order by [orderdate] desc)

Check this issue report PDO::ATTR_PERSISTENT is not supported. Also they are reporting problems with PDO::ATTR_ERRMODE so check your connection for these two parameters.

Related

MySQL server has gone away #2006 - Azure server and using PHP

I have trouble with this query:
create temporary table IF NOT EXISTS vt_tmp_u2275(id int(11) primary key) ignore (SELECT 2275 as id) UNION (SELECT vt_user2role.userid AS userid FROM vt_user2role INNER JOIN vt_users ON vt_users.id=vt_user2role.userid INNER JOIN vt_role ON vt_role.roleid=vt_user2role.roleid WHERE vt_role.parentrole like 'H1::H4::H43::H401::H249::H250::H251::H776::H252::H544::H687::H794::H253::H360::H441::H442::%') UNION (SELECT groupid FROM vt_groups where groupid in (2841,2842,2843,2844,2845,2846,2847,2848,2864,2897,2903,2904,2908,2909,2910,3325,3372,3374,3377,4255,4379,4402,4541,4548,4740,4791,4792,4803,4805,4912,4953,4964,4966,4969,4970,4973,4982,4984,4985,4995,5004,5009,5010,5011,5017,5018,5023,5026,5033,5034,5041,5042,5043,5045,5047,5048,5050,5051,5055,5060,5062,5064,5065,5066,5072,5074,5078,5080,5086,5088,5099,5116,5130,5211,5213,5252,5293,5298,5300,5305,5309,5310,5313,5327,5331,5333,5343,5363,5364,5373,5415,5418,5420,5423,5424,5438,5448,5451,5453,5468,5491,5492,5513,5544,5601,5606,5611,5744,5905,5938,6023,6031,6032,6033,6034,6035,6038,6041,6042,6046,6056,6064,6065,6069,6070,6072,6079,6091,6092,6100,6101,6105,6113,6129,6153,6154,6155,6156,6158,6162,6164,6165,6166,6167,6171,6172,6173,6175,6177,6178,6183,6190,6201,6203,6204,6205,6207,6210,6212,6218,6219,6221,6225,6231,6248,6258,6259,6261,6264,6265,6266,6267,6268,6269,6270,6271,6274,6275,6276,6277,6279,6280,6281,6282,6293,6298,6311,6312,6313,6314,6315,6317,6319,6320,6323,6324,6325,6327,6328,6329,6330,6334,6355,6364,6391,6392,6394,6395,6399,6400,6404,6405,6407,6408,6409,6411,6412,6415,6424,6428,6430,6431,6432,6433,6435,6436,6443,6447,6449,6864,6867,6868,6869,6875,6880,6883,6884,6885,6942,6954,6959,6961,6966,6967,6969,6972,6978,6980,6981,6987,6989,6992,6994,6997,6998,7001,7003,7006,7007,7012,7013,7017,7022,7030,7031,7037,7038,7041,7044,7045,7046,7048,7052,7056,7057,7067,7070,7078,7079,7088,7090,7092,7093,7096,7100,7101,7102,7103,7108,7109,7115,7116,7117,7119,7120,8215,8525,8528,8725,8739,8927,9161,9162,9258,9259,9296,9331,9459,9460,9499,9504,9505,9563,9569,9570,9571,9669,9671,9700,9730,9754,9788,9859,9936,9957,10089,10196,10197,10673,10764,10781,10798,10805,11552,11553,11618,11627,11697,11807,11822,11824,11825,11826,11837,11838,11840,11841,11878,11903,11904,11920,11921,11922,11962,11964,11982,11984,12020,12021,12022,12032,12052,12053,12069,12104,12105,12113,12134,12141,12142,12144,12145,12175,12176,12184,12190,12206,12207,12208,12217,12246,12248,12249,12273,12303,12320,12325,12357,12374,12394,12409,12422,12438,12455,12511,12518,12632,12638,12671,12700,12752,12756,12757,12758,12763,12766,12772,12775,12780,12799,12800,12801,12812,12828,12833,12836,12837,12854,12884,12896,12900,12902,12930,12931,12992,12993,12994,13021,13028,13029,13035,13086,13095,13139,13162,13173,13182,13183,13196,13197,13207,13209,13213,13214,13268,13269,13297,13298,13302,13322,13323,13324,13337,13340,13342,13355,13357,13359,13380,13404,13405,13406,13407,13420,13421,13422,13423,13428,13429,13430,13432,13435,13449,13450,13451,13459,13460,13461,13462,13463,13466,13481,13482,13572,13611,13612,13626,13627,13643,13658,13659,13665,13683,13691,13692,13693,13699,13700,13701,13720,13721,13722,13728,13729,13743,13757,13758,13759,13761,13770,13771,13803,13809,13810,13812,13813,13814,13816,13845,13864,13865,13883,13884,13885,13886,13887,13893,13894,13895,13896,13913,13914,13962,13981,14038,14048,14050,14057,14058,14066,14068,14070,14076,14077,14092,14094,14099,14104,14126,14147,14152,14159,14167,14168,14176,14177,14178,14189,14190,14195,14196,14202,14204,14231,14238,14239,14240,14241,14243,14270,14271,14272,14292,14293,14303,14306,14318,14319,14320,14328,14337,14338,14340,14341,14342,14343,14374,14375,14376,14380,14384,14385,14389,14394,14406,14407,14412,14416,14417,14418,14419,14420,14421,14422,14423,14424,14425,14426,14427,14428,14429,14430,14431,14432,14433,14434,14435,14436,14437,14438,14439,14440,14441,14442,14443,14444,14445,14446,14448,14449,14450,14451,14452,14454,14455,14456,14462,14463,14465,14466,14467,14469,14479,14489,14492,14493,14494,14495,14496,14497,14499,14500,14503,14505,14507,14508,14514,14515,14519,14522,14525,14526,14527,14528,14542,14543,14547,14549,14553,14558,14559,14562,14608,14609,14615,14626,14627,14628,14632,14634,14638,14642,14667,14675,14684,14687,14691,14704,14705,14708,14711,14742,14747,14748,14759,14760,14761,14766,14767,14840,14841,14849,14858,14868,14869,14876,14879,14881,14882,14904,14907,14911,14912,14917,14918,14928,14953,15016,15050,15056,15060,15062,15073,15074,15081,15083,15086,15088,15092,15095,15101,15109,15110,15111,15140,15141,15142,15143,15144,15146,15149,15150,15166,15167,15176,15193,15194,15195,15199,15209,15220,15221,15223,15228,15247,15248,15249,15250,15251,15268,15269,15270,15271,15272,15273,15275,15278,15305,15320,15324,15365,15366,15388,15389,15390,15405,15415,15416,15430,15431,15432,15433,15436,15453,15454,15455,15461,15472,15473,15474,15480,15481,15500,15501,15520,15521,15522,15547,15557,15558,15559,15560,15561,15569,15576,15577,15578,15579,15589,15590,15591,15592,15593,15594,15607,15608,15615,15616,15617,15618,15623,15624,15625,15627,15628,15650,15662,15663,15682,15688,15689,15690,15717,15720,15721,15722,15723,15724,15732,15734,15735,15758,15772,15786,15788,15800,15801,15802,15803,15804,15805,15817,15818,15819,15839,15840,15863,15864,15865,15883,15884,15885,15886,15897,15907,15915,15917,15918,15937,15938,15949,15951,15958,15959,15960,15973,15975,15976,15983,15984,15985,15986,15988,15996,15997,16007,16008,16009,16015,16016,16029,16037,16045,16046,16047,16053,16062,16063,16072,16074,16075,16076,16077,16085,16089,16095,16115,16116,16120,16123,16127,16129,16130,16131,16135,16136,16154,16155,16158,16159,16160,16166,16167,16173,16174,16175,16176,16177,16178,16179,16180,16192,16193,16200,16210,16211,16213,16214,16215,16216,16217,16237,16238,16239,16240,16247,16254,16255,16276,16277,16278,16286,16294,16296,16299,16313,16317,16337,16344,16372,16386,16389,16390,16391,16415,16441,16446,16458,16467,16468,16469,16470,16474,16489,16490,16491,16507,16508,16509,16522,16523,16524,16525,16526,16527,16529,16559,16641,16642,16645,16646,16647,16648,16649,16650,16652,16653,16669,16671,16678,16679,16680,16683,16694,16695,16697,16698,16702,16709,16710,16711,16712,16713,16729,16730,16731,16732,16745,16746,16747,16761,16762,16766,16841,16862,16865,16878,16893,16904,16905,16906,16907,16930,16931,16932,16946,16947,16960,16961,16964,16992,17003,17004,17014,17015,17021,17022,17023,17041,17048,17049,17050,17051,17058,17059,17073,17092,17112,17120,17124,17134,17135,17136,17138,17139,17160,17172,17175,17181,17182,17186,17187,17196,17198,17200,17210,17230,17244,17246,17249,17261,17264,17265,17279,17286,17309,17314,17326,17327,17328,17333,17334,17335,17339,17349,17350,17351,17352,17353,17355,17371,17373,17376,17377,17397,17398,17399,17406,17407,17408,17412,17424,17426,17427,17437,17438,17449,17450,17451,17452,17453,17466,17467,17488,17489,17490,17491,17514,17515,17516,17521,17535,17536,17567,17569,17581,17601,17635,17640,17650,17653,17655,17656,17659,17672,17695,17700,17702,17742,17744,17764,17766,17771,17772,17781,17783,17792,17795,17797,17798,17799,17832,17833,17858,17859,17881,17888,17904,17905,17959,17960,17961,17966,17967,17990,17995,17997,17998,18000,18014,18052,18057,18058,18059,18064,18076,18077,18079,18083,18113,18114,18115,18116,18117,18123,18124,18125,18140,18145,18149,18151,18152,18153,18176,18188,18193,18199,18206,18207,18208,18218,18219,18221,18222,18223,18225,18241,18244,18249,18250,18252,18266,18267,18268,18269,18270,18271,18273,18285,18286,18287,18292,18293,18295,18304,18307,18308,18321,18323,18325,18329,18331,18332,18341,18342,18343,18345,18358,18359,18360,18365,18369,18370,18371,18372,18373,18374,18375,18392,18395,18397,18401,18420,18421,18422,18428,18476,18482,18485,18497,18501,18514,18515,18522,18523,18524,18525,18526,18527,18528,18535,18536,18537,18538,18539,18545,18546,18560,18561,18562,18563,18564,18567,18568,18569,18570,18572,18574,18575,18576,18577,18578,18582,18584,18595,18596,18603,18604,18623,18624,18628,18629,18630,18631,18640,12901,13436,14093,15087,15391,15392,15397,15556,15562,15733,16212,16442,16555,17378,17568,17634,17654,17678,17791,17831,18031)
Error: MySQL server has gone away
Code: 2006
Code is 2006 so I found online it is CR_SERVER_GONE_ERROR. I tried to resolve this issue, but without succession...
Here are some server related settings:
MySQL 8.0:
wait_timeout: 2147483
innodb_lock_wait_timeout: 1073741824
lock_wait_timeout: 31536000
net_read_timeout: 31536000
net_write_timeout: 31536000
interactive_timeout: 31536000
max_allowed_packet: 1073741824
tmp_table_size: 134217728
max_join_size: 18446744073709551615
PHP 7.2:
default_socket_timeout: 60000
mysqli.reconnect: On
post_max_size: 128000M
upload_max_filesize: 128000M
max_execution_time: 60000
max_input_time: 60000
memory_limit: 128000M
Values are extremely high for debugging reasons. Hint could be that, when I edit query and remove only one groupid from there, error disappears and everything works as expected.
When I run query in adminer without using application, query passes even without editing.
I am using SSL MySQL connection to Azure MySQL server 8.0.15 / tried also MySQL 5.6, same trouble.
When running this query on local dev environment, app works fine. As a driver for DB connection, I'm using adodb mysqli driver.
I also tried to compare server settings of both MySQL and PHP on local and beta server, it wasn't useful. Now I think trouble could be somewhat around that SSL connection to database. But I don't know what to search for...
Please help, I am out of ideas right now...
UPDATE
So I tried to turn off the SSL enforcing on Beta server in Azure portal and change connection on app - not to use the SSL connection.
App loaded results without error. So yes, problem is related to SSL connection with MySQL server.

Laravel: An unsupported attribute was designated on the PDO object. MSSQL on Ubuntu

My Ubuntu vagrant Laravel Homestead set up has been configured to connect to MSSQL. Randomly it's starting throwing the following error on every query going to the MSSQL database (on a Windows server).
Any ideas? I can't find much info re:this available on Google.
I restarted PHP and confirmed SQLSRV modules are loaded.
SQLSTATE[IMSSP]: An unsupported attribute was designated on the PDO object. (SQL: select top 10 * from [orders] where [ordertype] = SO order by [orderdate] desc)
Check this issue report PDO::ATTR_PERSISTENT is not supported. Also they are reporting problems with PDO::ATTR_ERRMODE so check your connection for these two parameters.

PHP Connection with interbase

I am trying to connect php with interbase. It seems php only works with firebird, instead of interbase. I already have a database , that is created in interbase, I just need connectivity with interbase, not firebird. When I am trying to connect it with interbase, it says .. invalid database. where as connection with firebird database is working fine. Using php 5.6, windows server, 64 bit architechture
There's a ton of helpful comments at the ibase_connect function page over at php.net, are you sure that you're following through and checking version numbers? It appears that you may need to perform a manual fix and set the dialect version of the connection, as follows:
ibase_connect ('localhost:/usr/db/db.gdb', 'SYSDBA', 'masterkey', 'ISO8859_1', '100', '1' ) ;
The last 1 as a parameter resets the dialect mode between the ibase_connect() and Interbase. You also should check and see if the version of PHP you're running is compatible with the version of Interbase you're running.

CodeIgniter 3 + SQL Server + Windows 10

I have a project working with CodeIgniter and sqlserver 2008 I updated my pc to windows 10 then stopped working, the sqlserver driver for php is configured and my php ini shows it, also the code connects to sql server but now when im triying to do a query it givme false
so this code:
$this->db->select('*')->from('distritos')->get()->result();
Fatal error: Call to a member function result() on a non-object in C:\
Always its like sqlserver not working anymore but cannot fix it.
Php info shows
PDO
PDO support enabled
PDO drivers mysql, pgsql, sqlite, sqlsrv
pdo_sqlsrv
pdo_sqlsrv support enabled
Version 3.0.2.2R (Unofficial)
Unofficial Changes Works with Native Clients 11/10/9
sqlsrv
sqlsrv support enabled
Version 3.0.2.2R (Unofficial)
Unofficial Changes Works with Native Clients 11/10/9
EDIT:
its my mistake cannot conect
Unable to connect to your database server using the provided settings.
Filename: C:/www/***/system/database/DB_driver.php
Line Number: 436
the database config its okay :S
The error wasnt on the config, was on the password that was expired but the code igniter wasn't showing the error becouse i have to active this config :
database.php
'db_debug' => TRUE,
Solved ;)

Using SQL Server in Cake PHP: PHP SQL Server interface is not installed

I inherited an old Cakephp site that was using adodb as a driver to connect to an MSSQL database and it turns out this is no longer supported in the new version of cake (1.3, we are in 1.2) so I'm trying to change the driver so I can upgrade. We're using IIS and a sql server 2005 database on a different server, php 5.2.17. However using driver "mssql" gives me the following errors:
PHP SQL Server interface is not installed. For troubleshooting information, see http://php.net/mssql/
Call to undefined function mssql_min_message_severity()
The top error leads me to a page regarding the old php_mssql.dll, which according to this question: ( CakePHP: error when trying to use mssql datasource ) will become a problem when I switch to PHP 5.3 so I'm trying to use the php_sqlsrv*.dll for my php version but I still get the error. Could never get the mssql.dll one to work either. I do however see "sqlsrv support enable" in phpinfo.php and the whole sqlsrv section is intact there.
In cake php I'm using "driver => 'mssql'", is this the correct driver for the new sqlsrv dll? Is there something I'm missing? For kicks I tried 'driver' => 'sqlsrv', that fixes the php SQL Server interface error but I still get
"Fatal error: Call to undefined function sqlsrv_min_message_severity() in C:\Inetpub\wwwroot\riverstone-dev\www\cake\libs\model\datasources\dbo\dbo_sqlsrv.php on line 107"
Installing the latest SQL Native Client set from Microsoft and reenabling the extension in PHP has worked, albeit on a different server. Please try the drivers below if having a similar problem:
http://www.microsoft.com/download/en/details.aspx?id=20098

Categories