Re: [PHP-DB] Prepared Statements Rows Selected

2011-05-23 Thread Giff Hammar
$stmt-rows() should give you the number of rows returned.

Giff

On Mon, 2011-05-23 at 18:53 -0400, Ron Piggott wrote:
 What command will tell me the # of rows the SELECT query retrieved using 
 Prepared Statements.
 
 
 $dsh = 'mysql:host=localhost;dbname='.$database;
 $dbh = new PDO($dsh, $username, $password);
 
 $stmt = $dbh-prepare($query);
 
 $stmt-bindParam(':email', $email);
 $stmt-bindParam(':pass', $pass);
 
 $stmt-execute();
 
 
 I am looking for the equivalent of mysql_numrows
 
 mysql_connect('localhost',$username,$password);
 @mysql_select_db($database) or die( Unable to select database);
 $result=mysql_query($query);
 $num=mysql_numrows($result);
 
 
 Ron
 
 The Verse of the Day
 “Encouragement from God’s Word”
 http://www.TheVerseOfTheDay.info  



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



Re: [PHP-DB] RE: Help for a beginner

2009-12-23 Thread Giff Hammar
It looks like you are not connecting because of a user name/password
combination. Typically, Windows does not use root as a valid login as do
most other operating systems. Try using your login information to see if
you can connect to mySQL using the GUI. I suspect you'll succeed. The
other option would be to use the mySQL admin user name and password. One
of those should work.

Once you can connect to your database with the GUI, you can then use PHP
to call the mySQL database connect strings and manipulate your data as
necessary. The DBD/DBI is a more generic solution that allows you to use
a standard coding structure in PHP (or perl) and easily change databases
underneath. For a small implementation, this isn't necessary. There are
other database abstraction layers that perform the same function.

Giff

On Wed, 2009-12-23 at 20:46 +0530, Chaitanya Yanamadala wrote:
 why dont u install the xampp
 
 On Wed, Dec 23, 2009 at 8:38 PM, Adam Sonzogni asonzo...@setfocus.comwrote:
 
  Mr. Brookhouse,
 
  Thanks for the quick reply. I am guessing it is not relevant to my case
  because I am not using PERL. I cannot find anything that says PHP requires
  PERL so I suspect Iam ok in this regard.
 
  Thank You,
  Adam
 
 
  -Original Message-
  From: Edward Brookhouse [mailto:eb...@healthydirections.com]
  Sent: Wednesday, December 23, 2009 9:59 AM
  To: Adam Sonzogni; php-db@lists.php.net
  Subject: RE: Help for a beginner
 
  Just a guess, as I have not tried a full stack in windows, but in any unix
  if you are connecting php and mysql, you need something in the middle like
  DBD::mysql
 
  See if this helps: http://forums.mysql.com/read.php?51,189692,189856
 
 
  -Original Message-
  From: Adam Sonzogni [mailto:asonzo...@setfocus.com]
  Sent: Wednesday, December 23, 2009 9:52 AM
  To: php-db@lists.php.net
  Subject: [PHP-DB] Help for a beginner
 
  Hi everyone, first thank you for ALL help and the understanding that I am
  new to PHP and MySQL. This is a long email and for that I apologize but I am
  trying to provide as much detail as possible. If this is the wrong list to
  ask for help, kindly direct me to the proper authority.
 
  I am trying to learn and I have built the following environment.
 
  Windows Server 2008 Standard 32bit service Pack 2 with IIS7
  mysql-essential-5.1.41-win32
  php-5.3.1-nts-Win32-VC9-x86.msi
  phpMyAdmin-3.2.4-english.zip
 
 
  I followed the steps as detailed below (I already had IIS7 and CGI
  installed)
 
 
  1. Install CGI  PHP
http://www.trainsignaltraining.com/iis-7-install-fastcgi-php/2008-09-04/
 
  2. Install MySQL
http://www.trainsignaltraining.com/install-mysql-on-iis7/2008-09-10/
 
  3. Install PHPMyAdmin
 
  http://www.trainsignaltraining.com/install-phpmyadmin-on-iis7-and-server-2008/2008-09-16/
 
 
  After I completed the installations
  1. If I navigate to the PHP directory and type php -info it spews a ton of
  data at me
AND
I created info.php which contains: ?php phpinfo(); ?
When I browse this, it correctly produces a page with all the info about
  my PHP server. Although I do not understand much of it I believe this
  confirms PHP is working correctly with IIS
 
  2. I open the MySQL CLI and perform the commands outlined in Step 23 at
  this page
http://www.bicubica.com/apache-php-mysql/index.php
This returns the expected results, confirming MySQL is working
 
  3. PHP is configured to work with php_mysql.dll as per the steps in the
  trainsignal links above so I begin!
  I go to the phpmyadmin page, enter root and my password and after a long
  time I get a FastCGI error. I am not ready to believe it because, in classic
  MS form, it has several VERY different potential causes, and I have covered
  all of those. Plus the error code is 0x which is like saying
  nothing... I start thinking maybe it is not connecting to the mYSQL server
  right, the instructions re: pma and the password made no sense to me so I
  fiddle with that with no change.
 
 
I  write the mysql_test.php page in step 5 of
  http://www.bicubica.com/apache-php-mysql/index.php
This fails with: A connection attempt failed because the connected party
  did not properly respond after a period of time, or established connection
  failed because connected host has failed to respond.
 
Because the PHP failed I try with ASP...
%
set conn=Server.CreateObject(ADODB.Connection)
conn.ConnectionString=Driver={mySQL};Server=localhost;Database=test;User
  Id=root;Password=youwish
conn.open
Response.write(Connected)
conn.close
%
 
This returns:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no
  default driver specified
/test.asp, line 4
 
  I believe I have established MySQL is working, but for some reason it
  appears that it cannot be reached This IS on the same server so firewall
  should not be an 

Re: [PHP-DB] DB interface problem

2009-10-28 Thread Giff Hammar
Thanks for the suggestion. I'll need to look into it.

Giff

On Wed, 2009-10-28 at 11:23 +0100, Samuel ROZE wrote:
 Why not using PDO ? It is a global and standardized method to access
 to data. :-)
 
 2009/10/27 Giff Hammar gham...@sv-phoenix.com:
  I started having trouble with a DBI interface to my PostgreSQL database
  after I built a new Ubuntu machine. The Postgres version is 8.3 and the
  DBI was written several years ago (by someone else). I'm using PHP
  version 5.2.6-3ubuntu4.2 with apache2. The problem is that I get the
  error:
 
  Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL
  result resource in /var/www/lib/dbi_pgsql.php on line 202
 
  I don't know what to check next to figure out why this is happening.
  Here is what I have done so far:
 
  - Updated the old PHP commands in the dbi file to reflect new ones
 var - public
 pg_numrows - pg_num_rows
 pg_cmdtuples - pg_affected_rows
 pg_exec - pg_execute
  - Connected to the database as the same user by using straight PHP calls
   vs the DBI. It worked fine.
  - Connected to the database via psql and that worked fine, too.
 
  There is something with the DBI class that is not right, but I am a
  novice with objects and classes, so I can't pin it down. The whole file
  is here: http://www.sv-phoenix.com/dbi_pgsql.php - it's 205 lines so I
  didn't want to put the whole thing in this post.
 
  If anyone can take a look at it and let me know what to check next, I
  would really appreciate it.
 
  Giff
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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



[PHP-DB] DB interface problem

2009-10-27 Thread Giff Hammar
I started having trouble with a DBI interface to my PostgreSQL database
after I built a new Ubuntu machine. The Postgres version is 8.3 and the
DBI was written several years ago (by someone else). I'm using PHP
version 5.2.6-3ubuntu4.2 with apache2. The problem is that I get the
error:

Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL
result resource in /var/www/lib/dbi_pgsql.php on line 202

I don't know what to check next to figure out why this is happening.
Here is what I have done so far:

- Updated the old PHP commands in the dbi file to reflect new ones
var - public
pg_numrows - pg_num_rows
pg_cmdtuples - pg_affected_rows
pg_exec - pg_execute
- Connected to the database as the same user by using straight PHP calls
  vs the DBI. It worked fine.
- Connected to the database via psql and that worked fine, too.

There is something with the DBI class that is not right, but I am a
novice with objects and classes, so I can't pin it down. The whole file
is here: http://www.sv-phoenix.com/dbi_pgsql.php - it's 205 lines so I
didn't want to put the whole thing in this post.

If anyone can take a look at it and let me know what to check next, I
would really appreciate it.

Giff


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



Re: [PHP-DB] DB interface problem

2009-10-27 Thread Giff Hammar
Andy,

Sometimes I'm too fast for my own good. I added .txt to the file and it
should be visible as http://www.sv-phoenix.com/dbi_pgsql.txt. Just
appending the .txt didn't work.

Thanks for taking a look!

Giff

On Tue, 2009-10-27 at 17:49 +, Andy Shellam (Mailing Lists) wrote:
 Hi Giff,
 
 I want to have a look at this for you, but you'll need to put the file  
 on your server as plain-text because your server is parsing the PHP  
 code and only sending us the output, not the source code.
 
 Append *.txt to your file on the server and we should be able to see  
 it better!
 
 Andy
 
 On 27 October2009, at 12:48, Giff Hammar wrote:
 
  I started having trouble with a DBI interface to my PostgreSQL  
  database
  after I built a new Ubuntu machine. The Postgres version is 8.3 and  
  the
  DBI was written several years ago (by someone else). I'm using PHP
  version 5.2.6-3ubuntu4.2 with apache2. The problem is that I get the
  error:
 
  Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL
  result resource in /var/www/lib/dbi_pgsql.php on line 202
 
  I don't know what to check next to figure out why this is happening.
  Here is what I have done so far:
 
  - Updated the old PHP commands in the dbi file to reflect new ones
 var - public
 pg_numrows - pg_num_rows
 pg_cmdtuples - pg_affected_rows
 pg_exec - pg_execute
  - Connected to the database as the same user by using straight PHP  
  calls
   vs the DBI. It worked fine.
  - Connected to the database via psql and that worked fine, too.
 
  There is something with the DBI class that is not right, but I am a
  novice with objects and classes, so I can't pin it down. The whole  
  file
  is here: http://www.sv-phoenix.com/dbi_pgsql.php - it's 205 lines so I
  didn't want to put the whole thing in this post.
 
  If anyone can take a look at it and let me know what to check next, I
  would really appreciate it.
 
  Giff
 
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 


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



Re: [PHP-DB] DB interface problem

2009-10-27 Thread Giff Hammar
Andy,

Thanks for your help! The var_dump after the pg_execute showed that the
execute() method wasn't being called (I left a line out of the calling
script). Once I fixed that, I changed pg_execute back to pg_exec and it
worked as expected. Now I have to figure out the difference between
pg_exec and pg_execute... From what I can tell, pg_exec isn't supported
any more and I should be using pg_execute instead... Thanks again.

Giff

On Tue, 2009-10-27 at 19:51 +, Andy Shellam (Mailing Lists) wrote:
 Hi Giff,
 
 No worries - I know the feeling well!
 
 At first glance this looks OK, however I notice that there is no res  
 property defined in the STH class, like there is session and query.
 
 $this-res on line 202 is what's causing the issue - PHP is saying  
 it's not a valid PostgreSQL result resource, so if you trace back to  
 where that comes from, you get to line 175:
 
 $this-res = @pg_execute($this-session, $query);
 
 PHP is therefore trying to assign a query result to a property that  
 doesn't exist.  I would have expected PHP to throw an error at this  
 but it may have been obscured with your logging settings, I'm not sure.
 
 Try adding public $res; after line 85 and see what you get.  You  
 could also add var_dump($this-res); between lines 175 and 176 which  
 should tell you what PHP thinks $this-res is.
 
 And lastly, you could get a back-trace of the rows() method call to  
 see if it's being called before $this-res has been assigned - just  
 add the line var_dump(debug_backtrace()); between lines 201 and 202.
 
 Hope this gives you a starting pointer!
 
 Regards,
 Andy
 
 On 27 October2009, at 19:36, Giff Hammar wrote:
 
  Andy,
 
  Sometimes I'm too fast for my own good. I added .txt to the file and  
  it
  should be visible as http://www.sv-phoenix.com/dbi_pgsql.txt. Just
  appending the .txt didn't work.
 
  Thanks for taking a look!
 
  Giff
 
  On Tue, 2009-10-27 at 17:49 +, Andy Shellam (Mailing Lists) wrote:
  Hi Giff,
 
  I want to have a look at this for you, but you'll need to put the  
  file
  on your server as plain-text because your server is parsing the PHP
  code and only sending us the output, not the source code.
 
  Append *.txt to your file on the server and we should be able to see
  it better!
 
  Andy
 
  On 27 October2009, at 12:48, Giff Hammar wrote:
 
  I started having trouble with a DBI interface to my PostgreSQL
  database
  after I built a new Ubuntu machine. The Postgres version is 8.3 and
  the
  DBI was written several years ago (by someone else). I'm using PHP
  version 5.2.6-3ubuntu4.2 with apache2. The problem is that I get the
  error:
 
  Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL
  result resource in /var/www/lib/dbi_pgsql.php on line 202
 
  I don't know what to check next to figure out why this is happening.
  Here is what I have done so far:
 
  - Updated the old PHP commands in the dbi file to reflect new ones
var - public
pg_numrows - pg_num_rows
pg_cmdtuples - pg_affected_rows
pg_exec - pg_execute
  - Connected to the database as the same user by using straight PHP
  calls
  vs the DBI. It worked fine.
  - Connected to the database via psql and that worked fine, too.
 
  There is something with the DBI class that is not right, but I am a
  novice with objects and classes, so I can't pin it down. The whole
  file
  is here: http://www.sv-phoenix.com/dbi_pgsql.php - it's 205 lines  
  so I
  didn't want to put the whole thing in this post.
 
  If anyone can take a look at it and let me know what to check  
  next, I
  would really appreciate it.
 
  Giff
 
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 
 
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


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



RE: [PHP-DB] Php in the twilight zone!

2006-04-21 Thread Giff Hammar
If you're doing lots of database queries, also make sure that every column
in your WHERE clause in each query is indexed. That will significantly
decrease the time it takes for the database engine to access the data.

Giff 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 21, 2006 3:49 AM
To: [EMAIL PROTECTED]; php-db@lists.php.net
Subject: RE: [PHP-DB] Php in the twilight zone!

You may want to check the max_execution_time directive in php.ini Neil 

-Original Message-
From: Iulian Manea [mailto:[EMAIL PROTECTED]
Sent: 21 April 2006 01:33
To: php-db@lists.php.net
Subject: [PHP-DB] Php in the twilight zone!

Hey everybody,

 

For about the last 7 hours I am trying to get a script to work and I have
absolutely no more ideas of why it isn't.

 

I run the script in a browser, and it has to run for some time, but after
about 20 minutes it suddenly . stops . it just pukes. No there is no error,
and yes the display_errors is on.  The script just stops as if it was stoped
by someone. There are  no errors, the server has absolutely no load, so it's
not the server either.

I then put in the script once every 3-4 lines this:

 

echo __LINE__;  

 

so I would actually know on what line it pukes. and it stops randomly.
Te funny thing is that last time I ran it, the last lines it displayed
were:

228, 234, 23  , so it just puked in THE MIDDLE of displaying 236!

 

Cound it be because of the browser???  Or the server would stop it??

I ran it in firefox and internet explorer.

 

Do any of you have any idea, because I would be imensly gratefull, at the
moment I am absolutely cluless!

 

Thanks a lot!

 

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

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



RE: [PHP-DB] MD5, MySQL, and salts

2006-04-17 Thread Giff Hammar
For an example, look at how UNIX/Linux stores regular login passwords. In
short, the salt is the first two characters in the password. When comparing
passwords, you take the salt and the user supplied password, encrypt, then
compare the two encrypted strings. If they match, the recently supplied
password matches the original. AFAIK, that is the only way to verify
passwords encrypted with a one-way algorithm.

Giff

-Original Message-
From: chris smith [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 17, 2006 4:36 PM
To: Sean Mumford
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] MD5, MySQL, and salts

On 4/18/06, Sean Mumford [EMAIL PROTECTED] wrote:
 Hi Guys,
 I'm working on securing user passwords in a MySQL 4 database with a 
 PHP5 frontend. I remember being told in one of my classes (I'm 
 currently a college junior) that the best way would be to hash a salt 
 and the password together and then store the hash in the database 
 instead of the plain MD5 hash. My question is, what is a good method 
 for the server and the database to agree on a salt value to use? I 
 know i could use a predefined variable, but I was wondering if 
 something dynamic might be better (timestamp, current date, something like
that). Any ideas? Thanks in advance!

If it's a dynamic salt, how are you going to access it when you have to
compare ?

There was an article either on phpsec.org or shiflett.org which talks about
this.. can't find the link right now :(

--
Postgresql  php tutorials
http://www.designmagick.com/

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

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



RE: [PHP-DB] Web forms

2006-04-14 Thread Giff Hammar
Ron,

One option is to build a list of privs and iterate over that for the form
and processing

To do that, you would iterate over the list and use variables to name the
fields. When you process the form, you would iterate over the same list and
extract the values.

Form building:

$foo = array ('priv1', 'priv2', 'priv3' ...);
...
foreach ($foo as $priv) {
...
input type=checkbox name=?php print $priv; ??php print
$priv; ?
...
}

Form processing:

foreach ($foo as $priv) {
if (isset($_POST[$priv])) {
do something here like update the database or build one SQL
statement
}
}

Instead of using a list when you build foo, you could use a hash.

$foo = array('priv1' = 'Man readable priv 1', 'priv2' = 'Man readable priv
2', 'priv3' = 'Man readable priv 3' ...);
...
foreach (array_keys($foo) as $priv) { 
...
input type=checkbox name=?php print $priv; ??php print
$foo[$priv]; ?
...
}

Hope this helps.

Giff

-Original Message-
From: Ron Piggott (PHP) [mailto:[EMAIL PROTECTED] 
Sent: Friday, April 14, 2006 1:22 PM
To: PHP DB
Subject: [PHP-DB] Web forms

I am creating some web based functions for the staff and volunteers to use.
Access to these functions is designated by those who need it.

I have two tables.  

One table describes the component --- It has a component reference number
column.  

The second table indicates who has access to what --- containing the
component reference number from the component table (described above) and
also the member reference number.  

Essentially if you are logged in your reference number is in a session
variable and using PHP  mySQL the script is checking to see which
components to allow you access to in your menu and only displaying those
menu options.

So far I have been updating this table using phpmyadmin.  I have begun
writing a script to do this in a more smooth fashion.

The script I am writing produces a form in a table.

Column 1 shows the component name.  Column 2 is a check box for the user to
check in if the person whose permissions are being modified should have
access to this component.  I have named the check box the component
reference number --- 1 for example.  There are about 16 components are
growing.  

I am not sure how to check if $1 = on indicating the check box was checked
in.  I know you would use an IF ( ) { } statement --- but I want to automate
this so when new components are added in I want have to modify the script
which actually updates who has access to what component.

What I have done so far is selected all the components and started a WHILE
loop --- $i will go from 0 to 15 so I am able to look at each check box to
see if it was selected or not and then I am going to use the INSERT INTO or
DELETE commands to update the table, etc.

How can I find out if $1 and $2 and $3 and ... $15 are on?

Ron

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

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



RE: [PHP-DB] Remove newlines from field

2006-03-21 Thread Giff Hammar
 

-Original Message-
From: Ludvig Ericson [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 20, 2006 5:54 PM
To: Giff Hammar
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Remove newlines from field

Mind you Pearl programmers, what would that do?

[snip]

It changes the end of line delimiter to match the platform that you're on
(\r\n for Windows, \r for Mac and \n for Unix/Linux).

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



RE: [PHP-DB] Remove newlines from field

2006-03-21 Thread Giff Hammar
 

-Original Message-
From: Miles Thompson [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 20, 2006 6:17 PM
To: php-db@lists.php.net
Subject: RE: [PHP-DB] Remove newlines from field

tops snipped

At 04:00 PM 3/20/2006, you wrote:


I am using a PHP script to pull information from a FoxPro database via
ODBC.
One of the fields is a memo field (large text) that contains newline 
characters. Displaying this info to the web page is fine as the 
newlines are ignored. The challenge is when I combine user entered text 
with the existing info and try to update the database. It fails with an
unrecognized command
because the end of field delimiter is on a different line. We're 
running on PHP 4.2.7 and I have tried using various combinations of 
str_replace to eliminate the newline characters, but I have been 
unsuccessful. Any suggestions?

Giff

Giff Hammar
IT Director
Certified Parts Warehouse
http://www.certifiedparts.com http://www.certifiedparts.com/   
http://www.certifiedparts.com/ http://www.certifiedparts.com/
mailto: [EMAIL PROTECTED]
V: 603.516.1707
F: 603.516.1702
M: 603.490.7163

Giff,

Are you inserting back into the FoxPro table? I had to use the following to
clean up text, cut and pasted from WPfor Windows 5.2, into a textarea. 
Immediately before the INSERT I also used PHP's addslashes(). The database
is MySQL.

 // have to clean up the extraneous CR/LF combos
 $trupara= .\r\n; // period+CR+LF
 $dblquotpara= ''.\r\n; // double quote+CR+LF
 $sglquotpara= '.\r\n; // single quote+CR+LF
 $questnpara = ?\r\n; // question+CR+LF
 $exclampara = !\r\n; // exclamation+CR+LF
 $colonpara  = :\r\n; // exclamation+CR+LF
 $dudspc = . \r\n; // period+spc+CR+LF
 $flspara= \r\n; //CR+LF
 $truflag= ***; //something unique

 $txtBody = str_replace ( $trupara, $truflag, $txtBody);
 $txtBody = str_replace ( $dblquotpara, $$$, $txtBody);
 $txtBody = str_replace ( $sglquotpara, %%%, $txtBody);
 $txtBody = str_replace ( $questnpara, +++, $txtBody);
 $txtBody = str_replace ( $exclampara, !!!, $txtBody);
 $txtBody = str_replace ( $colonpara, :::, $txtBody);
 $txtBody = str_replace ( $dudspc, ###, $txtBody);

 $txtBody = str_replace ( $flspara,  , $txtBody);
 $txtBody = str_replace ( $truflag, .\n\n, $txtBody);
 ///double quote
 $txtBody = str_replace ( $$$, '\n', $txtBody);
 ///single quote
 $txtBody = str_replace ( %%%, '\n, $txtBody);
 ///question mark
 $txtBody = str_replace ( +++, '?\n', $txtBody);
 ///exclamation mark
 $txtBody = str_replace ( !!!, '!\n', $txtBody);
 ///colon
 $txtBody = str_replace ( :::, ':\n', $txtBody);
 ///dudspace
 $txtBody = str_replace ( ###, '.\n\n', $txtBody);

 $txtBody = str_replace ( \n , \n, $txtBody);

Hope this is helpful - Miles

PS Policy on this list is to bottom post. 



Thanks for the help! A combination of this and the nl2br finally solved the
problem and allowed me to process the update to the database. Now it's on
the figuring out why VFP doesn't accept \ to escape special characters 

Giff

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



RE: [PHP-DB] help with file downloads from MySQL

2006-03-21 Thread Giff Hammar
Can you use something like this (I haven't tried it)?

$search = '/^0a/'; // Looks at the beginning of the stream for 0a
$replace = ; // Replace with this
$limit = 1; // How many you want to do 
$new_file = preg_replace($search, $replace, $old_file, $limit);

Giff 

-Original Message-
From: Mickey Martin [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 21, 2006 4:05 PM
To: 'Bastien Koert'; php-db@lists.php.net
Subject: RE: [PHP-DB] help with file downloads from MySQL

I tried purposely corrupting the file by adding blank spaces at the
beginning of the echo:
echo  ,$data;

The 0a was put in at the beginning again, followed by the spaces and then
the file. 

Mickey


-Original Message-
From: Bastien Koert [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 21, 2006 2:07 PM
To: [EMAIL PROTECTED]; php-db@lists.php.net
Subject: RE: [PHP-DB] help with file downloads from MySQL

If you load the data into the field with addslashes, have you tried
stripslashes on the way out?

Bastien


From: Mickey Martin [EMAIL PROTECTED]
To: php-db@lists.php.net
Subject: [PHP-DB] help with file downloads from MySQL
Date: Tue, 21 Mar 2006 12:55:56 -0600

Every time I try to download a file from MySQL it cannot be opened. 
Using HexEdit, I noticed that all of the files are getting 0a added to 
the beginning of them (happens with all browsers).

I can look at the files with MySQL Query Browser and they don't have 
the 0a.
Using php 4.3.11, Solaris 8, Apache 2.0.54, MySQL 4.1.11.

Here's what I'm using:
mysql_select_db($database_ctnwww, $ctnwww); $query_Attachment = 
sprintf(SELECT bin_data, filetype, filename, filesize FROM IssueAttach 
WHERE id_files=%s, $_GET['id_files']); $Attachment = 
mysql_query($query_Attachment, $ctnwww) or die(mysql_error()); 
$row_Attachment = mysql_fetch_array($Attachment);

   $data = $row_Attachment['bin_data'];
   $name = $row_Attachment['filename'];
   $size = $row_Attachment['filesize'];
   $type = $row_Attachment['filetype'];

   header(Content-type: $type);
   header(Content-length: $size);
   header(Content-Disposition: attachment; filename=$name);
   header(Content-Description: PHP Generated Data);
   echo $data;

Thanks in advance,
Mickey

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


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


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



[PHP-DB] Remove newlines from field

2006-03-20 Thread Giff Hammar
I am using a PHP script to pull information from a FoxPro database via ODBC.
One of the fields is a memo field (large text) that contains newline
characters. Displaying this info to the web page is fine as the newlines are
ignored. The challenge is when I combine user entered text with the existing
info and try to update the database. It fails with an unrecognized command
because the end of field delimiter is on a different line. We're running on
PHP 4.2.7 and I have tried using various combinations of str_replace to
eliminate the newline characters, but I have been unsuccessful. Any
suggestions?
 
Giff
 
Giff Hammar
IT Director
Certified Parts Warehouse
http://www.certifiedparts.com http://www.certifiedparts.com/ 
mailto: [EMAIL PROTECTED]
V: 603.516.1707
F: 603.516.1702
M: 603.490.7163
 


RE: [PHP-DB] Remove newlines from field

2006-03-20 Thread Giff Hammar
Thanks, Jeremy and Bastien. I just tried nl2br and it has the unfortunate
side effect of losing everything except the most recently added data when I
update the database. I think I need something like the 'local $/ = \r\n'
construct in perl...
 
Giff

  _  

From: Jeremy Peterson [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 20, 2006 5:14 PM
To: Giff Hammar
Subject: Re: [PHP-DB] Remove newlines from field


Try nl2br.  

http://php.net/nl2br

At 04:00 PM 3/20/2006, you wrote:


I am using a PHP script to pull information from a FoxPro database via ODBC.
One of the fields is a memo field (large text) that contains newline
characters. Displaying this info to the web page is fine as the newlines are
ignored. The challenge is when I combine user entered text with the existing
info and try to update the database. It fails with an unrecognized command
because the end of field delimiter is on a different line. We're running on
PHP 4.2.7 and I have tried using various combinations of str_replace to
eliminate the newline characters, but I have been unsuccessful. Any
suggestions?
 
Giff
 
Giff Hammar
IT Director
Certified Parts Warehouse
http://www.certifiedparts.com http://www.certifiedparts.com/  
http://www.certifiedparts.com/ http://www.certifiedparts.com/ 
mailto: [EMAIL PROTECTED]
V: 603.516.1707
F: 603.516.1702
M: 603.490.7163
 



Jeremy Peterson, MACS
Automation Systems Administrator
Crowell Library
Moody Bible Institute
820 N. LaSalle Drive
Chicago, IL, 60610

Email:[EMAIL PROTECTED]
Phone:  312.329.8081
Fax:  312.329.8959