Re: [PHP] regex
Jim Lucas wrote: Peter wrote: I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, I have managed to get the caps to lower but I cant work out how to put the _ in place of spaces if the spaces are between [ ]. I either end up with S_E_L_E_C . or SELECT_DISTINCT_ etc... . Something along the lines of this? \n"; preg_match_all('%\[([^\]]+)\]%', $sql, $matches, PREG_SET_ORDER); $change = array(); foreach ( $matches AS $match ) { $change[$match[0]] = str_replace(' ', '_', $match[1]); } echo ''.print_r($change,1).''; echo str_replace(array_keys($change), $change, $sql); Thanks Keith and Jim once I wake up I'll give both methods a try and let you know how I go. (Just having my morning coffee atm) I know I wont find the perfect converter as ms access lets you use to many 'bad' characters in column names. aah well only need to change about 600 queries. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] regex
Jim Lucas wrote: Peter wrote: I am trying to convert ms access sql to postgresql using php. I have a sql statement in the form ;- $sql = SELECT DISTINCT [Table Name].[Column.Name], [Table Name 1].[Column Name 2] etc. what I want to end up with is $sql = SELECT DISTINCT table_name.column_name, table_name_1.column_name_2, Something along the lines of this? \n"; preg_match_all('%\[([^\]]+)\]%', $sql, $matches, PREG_SET_ORDER); $change = array(); foreach ( $matches AS $match ) { $change[$match[0]] = str_replace(' ', '_', $match[1]); } echo ''.print_r($change,1).''; echo str_replace(array_keys($change), $change, $sql); Jim You are a genius! Worked like a charm. I ran the string thru strlower and strreplace first then thru your code and it ended up exactly as I required it (all table/columns lower case, no % $ in column names etc). Thank you very much. Peter (Keith I havent tried yours as yet) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Printing Question
OK this is very general. Whats the best way to do formatted printing via php? In my case I have a postgre database that I connect to with a php(naturally seeing as this is the php list). My aim is to convert an Access db to php/postgre. In this access db there are several reports that require landscape printing. So the question is how to replace this via php/whatever. (I did say it was a vague question) Oh and I'm aiming for a unix/windows outcome. any links welcome. TIA Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] odbc msaccess php5
Hi list, I am trying to get info out of a MS Access 2000 db. So far I have managed to do some of it but current part has me stumped. Set up Machine 1 - Debian 4, Apache, PHP5 unixodbc, mdbtools Machine 2 - WindowsXP, MS-Access Database is in a windows share that is smfs mounted on the linux box. $conn=odbc_connect("Database","",""); works $a = "abcd"; (this value exists in db) $stat = "Select * FROM " . '"Table Name"'; $qry = odbc_exec($conn,$stat); $res = odbc_result_all($qry) or die("Error: "); The above works as I expect it to.(Returns 70 rows) If I now want to add a where clause $stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" = " . $a; (This works) Now the place I fall into the abyss. if I change WHERE clause in $stat to " WHERE " . '"Column Name"' LIKE abc* (or other variations like abc% "abc%" "abc*" 'abc%' 'abc*') All I end up with is a blank page or Warning odbc_result_all No tuples available at this result index. Also I'm having trouble working out how to use a date in the WHERE clause. I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00 etc I realize this is probably more odbc/sql related but after a lot of goggling and reading I havent found the answer (about 5 days so far) And before everyone shouts use mySQL postgresql etc that isnt an option at this point in time. I dont need to update the records I just need to be able to read them with php. Oh and whilst I'm here is it possible to read an ms-query via odbc? (eg select * from myquery). Just thinking that may fix one of my problems (Caps and spaces in table/column names aaarrgghh) Peter Jackson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Trying to keep a dropdown selection sticky
Michael S. Dunsavage wrote: I have a form I want to keep sticky, but I can't figure out how. I got all the 's to be sticky The select script State'; echo ''; foreach ($state_list as $key => $value) { echo " $value\n"; } echo ''; echo ''; ?> If I'm reading this correctly you mean if the value has been selected before select it again? If so way I did it was by checking the database value eg echo " $value \n"; Peter Jackson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] odbc msaccess php5
Bastien Koert wrote: On Sat, Jul 5, 2008 at 11:04 AM, Bastien Koert <[EMAIL PROTECTED]> wrote: On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson <[EMAIL PROTECTED]> wrote: $conn=odbc_connect("Database","",""); works $a = "abcd"; (this value exists in db) $stat = "Select * FROM " . '"Table Name"'; $qry = odbc_exec($conn,$stat); $res = odbc_result_all($qry) or die("Error: "); The above works as I expect it to.(Returns 70 rows) If I now want to add a where clause $stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" = " . $a; (This works) Now the place I fall into the abyss. if I change WHERE clause in $stat to " WHERE " . '"Column Name"' LIKE abc* (or other variations like abc% "abc%" "abc*" 'abc%' 'abc*') All I end up with is a blank page or Warning odbc_result_all No tuples available at this result index. Also I'm having trouble working out how to use a date in the WHERE clause. I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00 etc I realize this is probably more odbc/sql related but after a lot of goggling and reading I havent found the answer (about 5 days so far) As the data seems to be text based, you need to quote it WHERE " . '"Column Name"' LIKE 'abc%' -- Bastien Cat, the other other white meat sorry, missed the access dates... try mm/dd/ as the format Unfortunately thats the first thing I thought of. I've tried every variation of quote I could think of. Can anyone tell me how to log what the odbc connection is actually sending/receiving? (as opposed to just echoing the sql statement I 'think' its sending. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] odbc msaccess php5 [Giving Up]
Peter Jackson wrote: well thats it Ive come to the conclusion that its a driver/lib issue. From what I can see mdbtools lib only reads and only does basic select. (eg Select * from table where col =thistext But not tex* % or date. Also looks like the project has died (think the last release was 2004 or so.) Thought I would give odbtp ago but cant get that to make. aargghh I give up. Bastien Koert wrote: On Sat, Jul 5, 2008 at 11:04 AM, Bastien Koert <[EMAIL PROTECTED]> wrote: On Sat, Jul 5, 2008 at 6:51 AM, Peter Jackson <[EMAIL PROTECTED]> wrote: $conn=odbc_connect("Database","",""); works $a = "abcd"; (this value exists in db) $stat = "Select * FROM " . '"Table Name"'; $qry = odbc_exec($conn,$stat); $res = odbc_result_all($qry) or die("Error: "); The above works as I expect it to.(Returns 70 rows) If I now want to add a where clause $stat = "SELECT * FROM " . '"Table Name"' . " Where " . '"Column Name" = " . $a; (This works) Now the place I fall into the abyss. if I change WHERE clause in $stat to " WHERE " . '"Column Name"' LIKE abc* (or other variations like abc% "abc%" "abc*" 'abc%' 'abc*') All I end up with is a blank page or Warning odbc_result_all No tuples available at this result index. Also I'm having trouble working out how to use a date in the WHERE clause. I've tried #yy-mm-dd# yy-mm-dd* dd/mm/yy etc etc (oh and yy/mm/dd 00:00:00 etc I realize this is probably more odbc/sql related but after a lot of goggling and reading I havent found the answer (about 5 days so far) As the data seems to be text based, you need to quote it WHERE " . '"Column Name"' LIKE 'abc%' -- Bastien Cat, the other other white meat sorry, missed the access dates... try mm/dd/ as the format Unfortunately thats the first thing I thought of. I've tried every variation of quote I could think of. Can anyone tell me how to log what the odbc connection is actually sending/receiving? (as opposed to just echoing the sql statement I 'think' its sending. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP / LAMP Training
Has anyone been to good PHP and/or LAMP training? I was looking around and saw on a blog where they really liked the security aspects of this one: http://www.sans.org/ns2005/description.php?tid=249 Has anyone been to classes by sans.org? Thanks, Peter __ Free 3000MB email. Stops spam 100%. No banner ads. No popup ads. http://www.cashette.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php