[PHP] ODBC text file connection problem

2002-09-10 Thread Ethan Nelson

Good morning...

I've got one for ya.  I've been trying to conenct to a csv text file =
(comma delimited, \r\n row separators, and " text qualifiers) using the =
odbc_connect command and then run simple select statements through it.  =
It doesn't work and I'm at a loss for why.  Here's the meat (I replace =
anything potentially sensitive with ***):

ODBC connection: Microsoft text driver version 4.00.6200.00 Win2K IIS =
5.0.

ODBC schema: I have specified, for the particular file I am trying to =
connect to, column name headers and ANSI format.  That's it...

// ODBC PHP connect string:=20
$odbc =3D odbc_connect("***input","",""); // This appears to work as no =
errors are reported

// ODBC commands to explore connection:
$result =3D odbc_tables($odbc);
odbc_fetch_into($result,$row);
print_r($row);

// I get the following output to the screen:
Array ( [0] =3D> ***:\***\***\*** [1] =3D> [2] =3D> inputfile.txt [3] =
=3D> TABLE [4] =3D> )=20

// Further commands to select data from text file:
$result =3D odbc_exec($odbc,"SELECT * FROM inputfile.txt");

// ERROR to screen:
Warning: SQL error: [Microsoft][ODBC Text Driver] The Microsoft Jet =
database engine cannot open the file '(unknown)'. It is already opened =
exclusively by another user, or you need permission to view its data., =
SQL state S1000 in SQLExecDirect in ***:\***\***\***\basecsv2.html on =
line 53

PHP Warning: SQL error: [Microsoft][ODBC Text Driver] The Microsoft Jet =
database engine cannot open the file '(unknown)'. It is already opened =
exclusively by another user, or you need permission to view its data., =
SQL state S1000 in SQLExecDirect in ***:\***\***\***\basecsv2.html on =
line 53=20

Any ideas?

-Ethan, Modulus, LLC


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] ODBC text file connect problem

2002-09-10 Thread Ethan Nelson

Good morning...

I've got one for ya.  I've been trying to conenct to a csv text file (comma delimited, 
\r\n row separators, and " text qualifiers) using the odbc_connect command and then 
run simple select statements through it.  It doesn't work and I'm at a loss for why.  
Here's the meat (I replace anything potentially sensitive with ***):

ODBC connection: Microsoft text driver version 4.00.6200.00 Win2K IIS 5.0.

ODBC schema: I have specified, for the particular file I am trying to connect to, 
column name headers and ANSI format.  That's it...

// ODBC PHP connect string: 
$odbc = odbc_connect("***input","",""); // This appears to work as no errors are 
reported

// ODBC commands to explore connection:
$result = odbc_tables($odbc);
odbc_fetch_into($result,$row);
print_r($row);

// I get the following output to the screen:
Array ( [0] => ***:\***\***\*** [1] => [2] => inputfile.txt [3] => TABLE [4] => ) 

// Further commands to select data from text file:
$result = odbc_exec($odbc,"SELECT * FROM inputfile.txt");

// ERROR to screen:
Warning: SQL error: [Microsoft][ODBC Text Driver] The Microsoft Jet database engine 
cannot open the file '(unknown)'. It is already opened exclusively by another user, or 
you need permission to view its data., SQL state S1000 in SQLExecDirect in 
***:\***\***\***\basecsv2.html on line 53

PHP Warning: SQL error: [Microsoft][ODBC Text Driver] The Microsoft Jet database 
engine cannot open the file '(unknown)'. It is already opened exclusively by another 
user, or you need permission to view its data., SQL state S1000 in SQLExecDirect in 
***:\***\***\***\basecsv2.html on line 53 

Any ideas?

-Ethan, Modulus, LLC


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] ODBC text file connection problem

2002-09-10 Thread Ethan Nelson

I actually do use fopen to connect to the file and create a table based on the column 
names I gather from the first line.  However, actaully parsing through the file and 
trying to dynamically create insert statements for each row seems like it would be a 
regular expression nightmare.  I really can't guarantee the format of the csv in any 
way that is easy to work with... for instance, the first data line might look like 
this:

"2","Ethan Nelson","My favorite quote is ""To hell with them"".","just a test"\r\n

As you can see, If I'm going to preserve the double quotes in the third column, I 
would have to come up with a script that would deal with escaped characters.

I was hoping that I could just establish an ODBC connection to the text file, which it 
appears that I can, and then select stuff from it.  Microsoft's documentation that I 
could find states that their text driver doesn't support create/drop table, insert, or 
update commands (obviously), but it doesn't mention SELECT as being off limits...

-Ethan

-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 11:48 AM
To: Ethan Nelson; [EMAIL PROTECTED]
Subject: RE: [PHP] ODBC text file connection problem


[snip]
I've got one for ya.  I've been trying to conenct to a csv text file =
(comma delimited, \r\n row separators, and " text qualifiers) using the =
odbc_connect command and then run simple select statements through it.  =
It doesn't work and I'm at a loss for why.  
[/snip]

Why not use fopen()? A CSV file is a plain text file and therefore cannot be treated 
as a database. The CSV file has no data engine with which to connect to.

HTH!

Jay

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort & Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] ODBC text file connection problem

2002-09-10 Thread Ethan Nelson

I know that the connection works because the following command ODBC_tables into which 
I feed my connection accurately searches the connection and returns an array with some 
table information.
[snip]

// ODBC commands to explore connection:
$result = odbc_tables($odbc);
odbc_fetch_into($result,$row);
print_r($row);

// I get the following output to the screen:
Array ( [0] => ***:\***\***\*** [1] => [2] => inputfile.txt [3] => TABLE [4] => ) 

[/snip]
inputfile.txt in row 2 is the file I want to select from.

Just for kicks, I added the "OR DIE" and got nothing.  I'm pretty sure that I have 
created a valid ODBC system resource and that my ODBC_connect command succesfully 
creates a bridge to my materials.  Its just that I can't execute commands beyond the 
odbc_tables without getting this big nasty error:

[snip]
$result = odbc_exec($odbc,"SELECT * FROM inputfile.txt");
[/snip]

Warning: SQL error: [Microsoft][ODBC Text Driver] The Microsoft Jet database engine \
cannot open the file '(unknown)'. It is already opened exclusively by another user, \
or you need permission to view its data., SQL state S1000 in SQLExecDirect in \
***:\***\***\***\basecsv2.html on line 53

-Ethan

-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 12:03 PM
To: Ethan Nelson; [EMAIL PROTECTED]
Subject: RE: [PHP] ODBC text file connection problem


[snip]
As you can see, If I'm going to preserve the double quotes in the third column, I 
would have to come up with a script that would deal with escaped characters.

I was hoping that I could just establish an ODBC connection to the text file, which it 
appears that I can, and then select stuff from it.  Microsoft's documentation that I 
could find states that their text driver doesn't support create/drop table, insert, or 
update commands (obviously), but it doesn't mention SELECT as being off limits...
[/snip]

The quotes should not be a problem as you could use addslashes() to escape them. On 
your connection you say that it does not return an error;

$odbc =3D odbc_connect("***input","",""); // This appears to work as no = errors are 
reported

But you're not testing for errors

$odbc =3D odbc_connect("***input","","") OR die("There is an error connecting to the 
CSV file.");

Make sure that you trap every potential error.

Jay

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort & Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] ODBC text file connection problem

2002-09-10 Thread Ethan Nelson

So this code:

$odbc = odbc_connect("cvalcoinput","","") OR die("There is an error connecting to the 
CSV file.");
$result = odbc_tables($odbc);

while(odbc_fetch_into($result, $fields)){
  for ($i = 0; $i < sizeof($fields); $i++) {
echo $fields[$i] . "";
  }
}

Derives the following results:
D:\INETPUB\CVALCO\INCLUDE\INPUT

inputfile.txt
TABLE

Which makes sense.  Those are the contents of the array returned by odbc_tables.  Now 
try to use odbc_exec and I run into my problems.  This article on the microsoft KB 
seems to suggest under "text driver limitations" that I should be able to run select 
statements using the odbc_exec command.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q178717

Anyone know of any really good ODBC resources?


-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 12:29 PM
To: Ethan Nelson; [EMAIL PROTECTED]
Subject: RE: [PHP] ODBC text file connection problem


[snip]
// ODBC commands to explore connection:
$result = odbc_tables($odbc);
odbc_fetch_into($result,$row);
print_r($row);
[/snip]

Have you tried a WHILE loop to print out each row? I am not sure of the exact syntax 
but something like;

\n"); //at end of row
}
?>

Jay

*
* Texas PHP Developers Conf  Spring 2003*
* T Bar M Resort & Conference Center*
* New Braunfels, Texas  *
* Contact [EMAIL PROTECTED]   *
*   *
* Want to present a paper or workshop? Contact now! *
*

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




php-general@lists.php.net

2001-01-25 Thread Ethan Nelson

Hello,

I've got 4.25, 4.50 and 4.00.

I want to format them so that they give back 4.24, 4.5 and 4

I've already seen a pattern replacement that looks close to what I want, but
not quite.

Thanks ahead of time

Ethan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Question about dopping zeros

2001-01-25 Thread Ethan Nelson

I need to format decimals that are percise to the second place in the
following format:

4.00 to 4
4.50 to 4.5
4.25 to 4.25

As you can see, I just want to drop the trailing zeros, and if necessary the
decimal.

Thanks

___
Ethan Nelson, Systems Administrator
Net Solutions, LLC
840 Lawrence Street
Eugene, OR 97401
[EMAIL PROTECTED]
http://www.netsolutionsllc.com
Voice +1 541 345-7087
Fax   +1 541 485-5519


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Get rid of da Zero's

2001-01-25 Thread Ethan Nelson

Almost there... actually this creates one problem...

It turns 40.00 into 4

It needs to quit shaving zero's when it hits the decimal point.

40.00 into 40
45.50 into 45.5
40.25 into 40.25

Thanks

-Original Message-
From: Philip Hallstrom [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 25, 2001 12:43 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Question about dopping zeros


ereg_replace("[0\.]*$", "", $number)

should do it.  I'm not sure you need the slash in front of the dot or
not. try it and see.

In article
<[EMAIL PROTECTED]> you
write:
>I need to format decimals that are percise to the second place in the
>following format:
>
>4.00 to 4
>4.50 to 4.5
>4.25 to 4.25
>
>As you can see, I just want to drop the trailing zeros, and if necessary
the
>decimal.
>
>Thanks
>
>___
>Ethan Nelson, Systems Administrator
>Net Solutions, LLC
>840 Lawrence Street
>Eugene, OR 97401
>[EMAIL PROTECTED]
>http://www.netsolutionsllc.com
>Voice +1 541 345-7087
>Fax   +1 541 485-5519
>
>
>-- 
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] PDF bug question?

2002-03-29 Thread Ethan Nelson

Hello,

I checked the developer database, and I'm not saying it isn't in there...
but I couldn't find it, so here it goes:

Here is the problem... given the code below, I would expect a fill color of
73% cyan, 26% magenta, 5% yellow and 0 black.  However, the 73% cyan will
default to zero unless you specify 1.  The bug is that no gradient is
allowed for the first color option in the pdf set color command.  It takes
either 1 or zero and anything in between defaults to zero.  This is true of
RGB as well.  If you do not specify 1, the first colorspace defaults to 0.

pdf_setcolor("$pdf","fill","cmyk",.73,.26,.05,0);

I'm using php 4.05 RC1.  I know there was a bug about the last options being
required but ignored for color options, such as RGB, that doesn't make use
of them, but I don't know of one relating to this... am I doing something
wrong?

-Ethan Nelson

___
Ethan Nelson, Web Applications Engineer
Net Solutions, LLC
840 Lawrence Street
Eugene, OR 97401
[EMAIL PROTECTED]
http://www.netsolutionsllc.com
Voice +1 541 345-7087
Fax   +1 541 485-5519



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Pspell on win32 platform

2004-12-16 Thread Ethan Nelson
I can't instantiate new instances of the pspell library.
 
I've got the latest w32 binaries installed and the latest english
dictionary installed to c:\aspell.  I've got aspell and aspell\bin added
to the system environment path.  I've got the aspell.dll in the system32
folder.  Permissions look like they are working.
 
A phpinfo() command shows that I have php4.3.10 with pspell enabled.
However, when I run the command pspell_check($pspell_link, "testt") in
my web scripts, the page appears to header redirect on itself
indefinitely.
 
Please help.
 
-Ethan Nelson,
Modulus, LLC