Thanks for your useful article. I have a trouble with a request because the column name have space like ‘Raison Sociale’ in the mdb file and I can not change that. Request return a null value then there is a correct match for this request. Do you have a trick to use à column name with space please ?

my request :
SELECT * FROM Client WHERE Raison Sociale LIKE ‘%vig%’;

Thanks in advance.
Best regards.

]]>By: David Francishttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17445
Sat, 25 May 2013 12:34:59 +0000http://www.sitepoint.com/?p=2418#comment-17445Mark, you are indeed one small step away. Be sure your connection string specifies the correct driver for your database. If you’re not sure about odbc_connect(), check the odbc_connect entry in the PHP.net website where there are examples in the contributed notes.
]]>By: Can't connect to my Access database..https://www.sitepoint.com/using-an-access-database-with-php/#comment-17444
Fri, 24 May 2013 09:31:57 +0000http://www.sitepoint.com/?p=2418#comment-17444David, first of all thanks for the really helpful article.
I’m new to PHP and am having trouble with the code to connect to my Access database which is hosted for me.
My host has given me a DNS and told me no username or password is required.
So at the moment my code looks like this:
“$conn = odbc_connect(‘ORS-database’,”,”);”
However surely I need more than the simple DNS in the code? For example, the IP of the host?
I feel I am one small step away… but I couldn’t work out what I need from your article as I think you refer to database names rather than DNS.
Having real trouble cracking this so any advice would be hugely welcomed!!
Many thanks again for the article.
Mark
]]>By: mr.dhttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17443
Mon, 06 May 2013 06:06:30 +0000http://www.sitepoint.com/?p=2418#comment-17443How to add UTF-8 support to pdo (odbc) ?
Access database
]]>By: David Francishttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17442
Sun, 28 Apr 2013 07:36:01 +0000http://www.sitepoint.com/?p=2418#comment-17442You are most welcome, Xander. I shall endeavour to keep any future articles I write to at least this standard. :-)
]]>By: Xander Taylorhttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17441
Sat, 27 Apr 2013 02:27:44 +0000http://www.sitepoint.com/?p=2418#comment-17441Hi David,
Firstly, I want to say thanks for a fantastic article … I’m still learning a lot everyday! I’m working with a 10 year old application at the moment which still uses MDB, but I’m writing in PHP so this was VERY handy!

By laying out the sequential flow of the query, it makes it SO much easier to read and understand! THANK YOU for showing this! :)
This will make my life so much easier!
(Can’t believe I never thought to do that!! LOL)

]]>By: David Francishttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17440
Fri, 26 Apr 2013 12:05:19 +0000http://www.sitepoint.com/?p=2418#comment-17440I have Access 2000 installed, so I can comment only on how it stores images. It doesn’t have a distinct ‘image’ field type, using instead a general purpose OLE field, but the principle outlined below may still apply to later versions of Access.

Objects are stored in this field as hexadecimal strings. This makes it easy to display the contents of an OLE field. A crucial aspect of this string is that it’s wrapped in an OLE header and trailer. These need to be removed before the enclosed object (an image, in your case) can be extracted.

For example, if a GIF89a image is stored in an OLE field, the hexadecimal string will contain the character sequence “474946383961”.

Use PHP to remove the header up to this GIF identifier, then apply a similar process to remove the trailer. The hexadecimal string can now be converted to binary. PHP 5.4.0 onwards has the hex2bin() function. I use 5.3.5, but there’s a useful bespoke function on the hex2bin() page by ‘Johnson’.

Convert the string to binary, then save to disc using a suitable filename including the ‘.gif’ extension.

The image is now useable.

This technique can be applied to any image type. Note that each image type has its own header, which can be viewed by opening an example image in a text editor or you could check online for the official image specification.

]]>By: IThttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17439
Mon, 22 Apr 2013 20:37:10 +0000http://www.sitepoint.com/?p=2418#comment-17439Hi,
Can someone help me, to retrieve images from access file with PHP? I have one old access database, and images are saved in image field.
]]>By: G.R.https://www.sitepoint.com/using-an-access-database-with-php/#comment-17438
Wed, 17 Apr 2013 18:23:46 +0000http://www.sitepoint.com/?p=2418#comment-17438Robert, I wonder if you ever solved this trouble? Mine is very similar to yours.
]]>By: David Francishttps://www.sitepoint.com/using-an-access-database-with-php/#comment-17437
Sat, 15 Dec 2012 15:20:17 +0000http://www.sitepoint.com/?p=2418#comment-17437I’ve just tested it successfully using base64_encode to store a GIF image in an OLE field in Access 2000.

However, I’ve always been told that binary objects are best stored outside of a database, with the relevant database field instead containing a filepath or URL reference to the object. It’s more efficient and less troublesome.