php-general Digest 5 Sep 2012 09:56:47 -0000 Issue 7952
php-general Digest 5 Sep 2012 09:56:47 - Issue 7952 Topics (messages 318992 through 318995): Re: array.sorting.php 318992 by: Matijn Woudt 318993 by: John Taylor-Johnston 318994 by: Matijn Woudt MS SQL server connection problem. 318995 by: Girish Talluru Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- On Tue, Sep 4, 2012 at 9:20 PM, John Taylor-Johnston jt.johns...@usherbrooke.ca wrote: Here is my code: ---snip--- $mynewstring = http://foo.com/bigtextfile.txt;; $words = preg_split('/[[:space:]]+/',$mynewstring); foreach ($words as $word) { $freq[$word]++; } #natcasesort($freq); ksort($freq); John You can try uksort with a custom compare function. - Matijn Custom compare function? Yes, for example: function insensitive_uksort($a,$b) { return strtolower($a)strtolower($b); } or use a function like strnatcasecmp. you can then call uksort($array, insensitive_uksort); or uksort($array, strnatcasecmp); - Matijn ---End Message--- ---BeginMessage--- Matijn Woudt wrote: Taken from the natsort manual page comments: ?php /** * keyNatSort does a natural sort via key on the supplied array. * * @param $array The array to natural sort via key. * @param $saveMemory If true will delete values from the original array as it builds the sorted array. * @return Sorted array on success. Boolean false if sort failed or null if the object was not an array. */ PS. Please bottom post on this and probably any mailing list I've tried it. I don't see it sorting anything? http://cegepsherbrooke.qc.ca/~languesmodernes/test/keynatsort.php $words = preg_split('/[[:space:]]+/',$mynewstring); foreach ($words as $word) { $freq[$word]++; } function keyNatSort($array, $saveMemory=false) { if(is_array($array)) { $keys = array_keys($array); if(natsort($keys)) { $result = array(); foreach($keys as $key) { $result[$key] = $array[$key]; if($saveMemory) unset($array[$key]); } } else $result = false; } else $result = null; return $result; } keyNatSort($freq); echo table\n; foreach ($freq as $key = $val) { # echo $key = $val br /\n; echo trtd.str_replace(_, , $key)./tdtd$val/td/tr\n; } echo /table\n; ---End Message--- ---BeginMessage--- On Tue, Sep 4, 2012 at 9:33 PM, John Taylor-Johnston jt.johns...@usherbrooke.ca wrote: Matijn Woudt wrote: Taken from the natsort manual page comments: ?php /** * keyNatSort does a natural sort via key on the supplied array. * * @param $array The array to natural sort via key. * @param $saveMemory If true will delete values from the original array as it builds the sorted array. * @return Sorted array on success. Boolean false if sort failed or null if the object was not an array. */ PS. Please bottom post on this and probably any mailing list I've tried it. I don't see it sorting anything? http://cegepsherbrooke.qc.ca/~languesmodernes/test/keynatsort.php $words = preg_split('/[[:space:]]+/',$mynewstring); foreach ($words as $word) { $freq[$word]++; } function keyNatSort($array, $saveMemory=false) { if(is_array($array)) { $keys = array_keys($array); if(natsort($keys)) { $result = array(); foreach($keys as $key) { $result[$key] = $array[$key]; if($saveMemory) unset($array[$key]); } } else $result = false; } else $result = null; return $result; } keyNatSort($freq); Try : $freq = keyNatSort($freq); - Matijn ---End Message--- ---BeginMessage--- Hi All, I'm having problem while connecting to MS SQL server from my php program. I tried downloading driver from Microsoft and changed php.ini file but it is showing the following error. This statement I used to connect. $connect = mssql_connect(localhost, PC6, password); This is the error message I got Call to undefined function mssql_connect() in C:\wamp\www\Test\dbTest.php Then I tried other one as shown below: This statement I used to connect. $connect = sqlsrv_connect(localhost, PC6, password); This is the error message I got Array ( [0] = Array ( [0] = IMSSP [SQLSTATE] = IMSSP [1] = -49 [code] = -49 [2] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] = This
[PHP] MS SQL server connection problem.
Hi All, I'm having problem while connecting to MS SQL server from my php program. I tried downloading driver from Microsoft and changed php.ini file but it is showing the following error. This statement I used to connect. $connect = mssql_connect(localhost, PC6, password); This is the error message I got Call to undefined function mssql_connect() in C:\wamp\www\Test\dbTest.php Then I tried other one as shown below: This statement I used to connect. $connect = sqlsrv_connect(localhost, PC6, password); This is the error message I got Array ( [0] = Array ( [0] = IMSSP [SQLSTATE] = IMSSP [1] = -49 [code] = -49 [2] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] = Array ( [0] = IM002 [SQLSTATE] = IM002 [1] = 0 [code] = 0 [2] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) ) It is asking to download a native client. but i have already downloaded a driver at http://www.microsoft.com/en-in/download/details.aspx?id=20098 named SQLSRV30.EXE why do I need a native client or ODBC driver when I already got this driver installed in my system. Please help me out with this guys. I'm new to this. Thanks, Girish Talluru
Re: [PHP] MS SQL server connection problem.
Hi, why do I need a native client or ODBC driver when I already got this driver installed in my system. You need the Native Client on top of the PHP driver. The PHP driver implements functions that enable PHP to talk to SQL Server through the Native Client. HTH Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl Convince Microsoft! They need to add TRUNCATE PARTITION in SQL Server https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table 2012/9/5 Girish Talluru girish.dev1...@gmail.com Hi All, I'm having problem while connecting to MS SQL server from my php program. I tried downloading driver from Microsoft and changed php.ini file but it is showing the following error. This statement I used to connect. $connect = mssql_connect(localhost, PC6, password); This is the error message I got Call to undefined function mssql_connect() in C:\wamp\www\Test\dbTest.php Then I tried other one as shown below: This statement I used to connect. $connect = sqlsrv_connect(localhost, PC6, password); This is the error message I got Array ( [0] = Array ( [0] = IMSSP [SQLSTATE] = IMSSP [1] = -49 [code] = -49 [2] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] = Array ( [0] = IM002 [SQLSTATE] = IM002 [1] = 0 [code] = 0 [2] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) ) It is asking to download a native client. but i have already downloaded a driver at http://www.microsoft.com/en-in/download/details.aspx?id=20098 named SQLSRV30.EXE why do I need a native client or ODBC driver when I already got this driver installed in my system. Please help me out with this guys. I'm new to this. Thanks, Girish Talluru
RE: [PHP] MS SQL server connection problem.
Hi, I am relatively new as well. I tried both of those methods with no luck. I finally had success using odbc_connect(). See below: $conn = odbc_connect(Driver={SQL Server};Server=$server;Database=$database;, $user, $password); Thanks, Jeff Burcher - IT Dept Allred Metal Stamping PO Box 2566 High Point, NC 27261 (336)886-5221 x229 j...@allredmetal.com -Original Message- From: Girish Talluru [mailto:girish.dev1...@gmail.com] Sent: Wednesday, September 05, 2012 5:57 AM To: php-general@lists.php.net Cc: rahu...@radiare.co.in Subject: [PHP] MS SQL server connection problem. Hi All, I'm having problem while connecting to MS SQL server from my php program. I tried downloading driver from Microsoft and changed php.ini file but it is showing the following error. This statement I used to connect. $connect = mssql_connect(localhost, PC6, password); This is the error message I got Call to undefined function mssql_connect() in C:\wamp\www\Test\dbTest.php Then I tried other one as shown below: This statement I used to connect. $connect = sqlsrv_connect(localhost, PC6, password); This is the error message I got Array ( [0] = Array ( [0] = IMSSP [SQLSTATE] = IMSSP [1] = -49 [code] = - 49 [2] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] = Array ( [0] = IM002 [SQLSTATE] = IM002 [1] = 0 [code] = 0 [2] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) ) It is asking to download a native client. but i have already downloaded a driver at http://www.microsoft.com/en-in/download/details.aspx?id=20098 named SQLSRV30.EXE why do I need a native client or ODBC driver when I already got this driver installed in my system. Please help me out with this guys. I'm new to this. Thanks, Girish Talluru -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MS SQL server connection problem.
Hi Jeff - Wonderful - Nice find. Thanks a lot -Girish Talluru On Wed, Sep 5, 2012 at 4:43 PM, Jeff Burcher j...@allredmetal.com wrote: Hi, I am relatively new as well. I tried both of those methods with no luck. I finally had success using odbc_connect(). See below: $conn = odbc_connect(Driver={SQL Server};Server=$server;Database=$database;, $user, $password); Thanks, Jeff Burcher - IT Dept Allred Metal Stamping PO Box 2566 High Point, NC 27261 (336)886-5221 x229 j...@allredmetal.com -Original Message- From: Girish Talluru [mailto:girish.dev1...@gmail.com] Sent: Wednesday, September 05, 2012 5:57 AM To: php-general@lists.php.net Cc: rahu...@radiare.co.in Subject: [PHP] MS SQL server connection problem. Hi All, I'm having problem while connecting to MS SQL server from my php program. I tried downloading driver from Microsoft and changed php.ini file but it is showing the following error. This statement I used to connect. $connect = mssql_connect(localhost, PC6, password); This is the error message I got Call to undefined function mssql_connect() in C:\wamp\www\Test\dbTest.php Then I tried other one as shown below: This statement I used to connect. $connect = sqlsrv_connect(localhost, PC6, password); This is the error message I got Array ( [0] = Array ( [0] = IMSSP [SQLSTATE] = IMSSP [1] = -49 [code] = - 49 [2] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] = This extension requires the Microsoft SQL Server 2012 Native Client. Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] = Array ( [0] = IM002 [SQLSTATE] = IM002 [1] = 0 [code] = 0 [2] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified [message] = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ) ) It is asking to download a native client. but i have already downloaded a driver at http://www.microsoft.com/en-in/download/details.aspx?id=20098 named SQLSRV30.EXE why do I need a native client or ODBC driver when I already got this driver installed in my system. Please help me out with this guys. I'm new to this. Thanks, Girish Talluru -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] templeting
On 09/04/2012 04:14 AM, David McGlone wrote: Does anyone use any templeting system for any projects? If so what would anyone recommend? I looked at Code Ignitor, but it seems the templeting system is optional and left out by default. - Jelix / jTpl - Symfony / Twig -- RMA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MS SQL server connection problem.
On Sep 5, 2012 7:14 AM, Jeff Burcher j...@allredmetal.com wrote: Hi, I am relatively new as well. I tried both of those methods with no luck. I finally had success using odbc_connect(). See below: $conn = odbc_connect(Driver={SQL Server};Server=$server;Database=$database;, $user, $password); Thanks, Jeff Burcher - IT Dept ODBC may work for you, but it has issues if you need to work with text longer than 4k if I recall. The SQLSRV library really is the way to go. Just make sure you have the correct SQL client library installed and use the SQL for PHP driver that matches your PHP installation. (Threaded, non-threaded, etc.) Andrew