[PHP] cannot figure out permissions for fopen/fwrite

2009-07-01 Thread Mari Masuda

Hello,

This is probably a dumb newbie question.  I am running PHP 5.2.5 and  
Apache 2.2.8 on my Mac Book Pro OS X 10.4.11.  I compiled PHP and  
Apache from source a while ago (as opposed to using the built-in web  
server that is included w/ Mac OS X).  I have written the below PHP  
whose purpose is to read an existing comma separated (CSV) file and  
save the data into a text file that I can later copy and paste from  
into my website content management system.  The problem is that on my  
Mac, I cannot seem to figure out what permissions I need to set in  
order to make the input CSV and the initially non-existant output  
text file readable and writable by Apache/PHP.  I have Googled and  
come across many pages about different ways to set permissions and  
different permissions to set but none of the ways suggested that I  
tried seemed to work for me.  As a temporary solution, I uploaded my  
PHP file to a Windows 2003 server running Apache and PHP and it  
worked flawlessly (and makes me suspicious that there is some huge  
security hole with the Windows box since it was able to execute with  
no permissions modifications).  Any tips would be greatly  
appreciated.  Thanks!


Mari

--- start my code ---
	$out = fopen("/Applications/apache/htdocs/wp-php/ 
tableToCutAndPaste.txt", "w");

$counter = 0;


fwrite($out, "\n");

while(($data = fgetcsv($in)) !== FALSE) {
$paperNumber = $data[0];
$authors = $data[1];
$title = $data[2];
$filename = $paperNumber . ".pdf";

if(($counter % 2) == 0) {
fwrite($out, "\n");
} else {
fwrite($out, "\n");  
  
}

		fwrite($out, "http://www.example.com/workingpapers/ 
getWorkingPaper.php?filename=$filename\">$paperNumber\n");

fwrite($out, "$authors\n");
fwrite($out, "$title\n");
fwrite($out, "\n");

$counter++;
}

fwrite($out, "\n");


fclose($in);
fclose($out);

?>
--- end my code ---

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



Re: [PHP] Re: cannot figure out permissions for fopen/fwrite

2009-07-01 Thread Mari Masuda

On Jul 1, 2009, at 12:20, Shawn McKenzie wrote:


Shawn McKenzie wrote:

Mari Masuda wrote:

Hello,

This is probably a dumb newbie question.  I am running PHP 5.2.5 and
Apache 2.2.8 on my Mac Book Pro OS X 10.4.11.  I compiled PHP and  
Apache

from source a while ago (as opposed to using the built-in web server
that is included w/ Mac OS X).  I have written the below PHP whose
purpose is to read an existing comma separated (CSV) file and  
save the

data into a text file that I can later copy and paste from into my
website content management system.  The problem is that on my Mac, I
cannot seem to figure out what permissions I need to set in order to
make the input CSV and the initially non-existant output text file
readable and writable by Apache/PHP.  I have Googled and come across
many pages about different ways to set permissions and different
permissions to set but none of the ways suggested that I tried  
seemed to

work for me.  As a temporary solution, I uploaded my PHP file to a
Windows 2003 server running Apache and PHP and it worked  
flawlessly (and

makes me suspicious that there is some huge security hole with the
Windows box since it was able to execute with no permissions
modifications).  Any tips would be greatly appreciated.  Thanks!

Mari

--- start my code ---
fopen("/Applications/apache/htdocs/wp-php/ 
tableToCutAndPaste.txt", "w");

$counter = 0;


fwrite($out, "\n");

while(($data = fgetcsv($in)) !== FALSE) {
$paperNumber = $data[0];
$authors = $data[1];
$title = $data[2];
$filename = $paperNumber . ".pdf";

if(($counter % 2) == 0) {
fwrite($out, "\n");
} else {
fwrite($out, "\n");
}

fwrite($out, "href=\"http://www.example.com/workingpapers/getWorkingPaper.php? 
filename=$filename\">$paperNumber\n");


fwrite($out, "$authors\n");
fwrite($out, "$title\n");
fwrite($out, "\n");

$counter++;
}

fwrite($out, "\n");


fclose($in);
fclose($out);

?>
--- end my code ---


What are the permissions on /Applications/apache/htdocs/wp-php/ ?

Apache needs write permissions on that dir in order to create the  
file

tableToCutAndPaste.txt.

It's probably not a secure idea to give write permissions to that  
dir,
so maybe create a subdir of tmp and change those permissions (one  
way):


mkdir /Applications/apache/htdocs/wp-php/tmp
chmod a+w /Applications/apache/htdocs/wp-php/tmp



Also, turn on error reporting so that you can see the exact  
problem.  It

may not be what you think.

--
Thanks!
-Shawn
http://www.spidean.com



Thanks for the suggestions.  I added the following lines to the very  
top of my code:


error_reporting(E_ALL);

mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true);
chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w");

and I also changed the line where it tries to open the file to write  
to to go to the new directory:


	$out = fopen("/Applications/apache/htdocs/wp-php/tmp/ 
tableToCutAndPaste.txt", "w");


Below are the errors I got:
--- start errors ---
Warning: mkdir() [function.mkdir]: Permission denied in /Applications/ 
apache/htdocs/wp-php/generateTable.php on line 5


Warning: chmod() [function.chmod]: No such file or directory in / 
Applications/apache/htdocs/wp-php/generateTable.php on line 6


Warning: fopen(/Applications/apache/htdocs/wp-php/tmp/ 
tableToCutAndPaste.txt) [function.fopen]: failed to open stream: No  
such file or directory in /Applications/apache/htdocs/wp-php/ 
generateTable.php on line 9


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 13


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 22


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 27


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 28


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 29


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 30


Warning: fwrite(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 35


Warning: fclose(): supplied argument is not a valid stream resource  
in /Applications/apache/htdocs/wp-php/generateTable.php on line 39

--- end errors ---

The permissions are as follows (sorry I didn't think to include th

Re: [PHP] Re: cannot figure out permissions for fopen/fwrite

2009-07-01 Thread Mari Masuda


On Jul 1, 2009, at 12:54, Shawn McKenzie wrote:


Mari Masuda wrote:

On Jul 1, 2009, at 12:20, Shawn McKenzie wrote:


Shawn McKenzie wrote:

Mari Masuda wrote:

Hello,

This is probably a dumb newbie question.  I am running PHP  
5.2.5 and

Apache 2.2.8 on my Mac Book Pro OS X 10.4.11.  I compiled PHP and
Apache
from source a while ago (as opposed to using the built-in web  
server

that is included w/ Mac OS X).  I have written the below PHP whose
purpose is to read an existing comma separated (CSV) file and  
save the

data into a text file that I can later copy and paste from into my
website content management system.  The problem is that on my  
Mac, I
cannot seem to figure out what permissions I need to set in  
order to

make the input CSV and the initially non-existant output text file
readable and writable by Apache/PHP.  I have Googled and come  
across

many pages about different ways to set permissions and different
permissions to set but none of the ways suggested that I tried
seemed to
work for me.  As a temporary solution, I uploaded my PHP file to a
Windows 2003 server running Apache and PHP and it worked  
flawlessly

(and
makes me suspicious that there is some huge security hole with the
Windows box since it was able to execute with no permissions
modifications).  Any tips would be greatly appreciated.  Thanks!

Mari

--- start my code ---
\n");

while(($data = fgetcsv($in)) !== FALSE) {
$paperNumber = $data[0];
$authors = $data[1];
$title = $data[2];
$filename = $paperNumber . ".pdf";

if(($counter % 2) == 0) {
fwrite($out, "\n");
} else {
fwrite($out, "\n");
}

fwrite($out, "href=\"http://www.example.com/workingpapers/getWorkingPaper.php? 
filename=$filename\">$paperNumber\n");



fwrite($out, "$authors\n");
fwrite($out, "$title\n");
fwrite($out, "\n");

$counter++;
}

fwrite($out, "\n");


fclose($in);
fclose($out);

?>
--- end my code ---


What are the permissions on /Applications/apache/htdocs/wp-php/ ?

Apache needs write permissions on that dir in order to create  
the file

tableToCutAndPaste.txt.

It's probably not a secure idea to give write permissions to  
that dir,
so maybe create a subdir of tmp and change those permissions  
(one way):


mkdir /Applications/apache/htdocs/wp-php/tmp
chmod a+w /Applications/apache/htdocs/wp-php/tmp



Also, turn on error reporting so that you can see the exact  
problem.  It

may not be what you think.

--
Thanks!
-Shawn
http://www.spidean.com



Thanks for the suggestions.  I added the following lines to the  
very top

of my code:

error_reporting(E_ALL);

mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true);
chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w");

and I also changed the line where it tries to open the file to  
write to

to go to the new directory:

$out =
fopen("/Applications/apache/htdocs/wp-php/tmp/ 
tableToCutAndPaste.txt",

"w");

Below are the errors I got:
--- start errors ---
Warning: mkdir() [function.mkdir]: Permission denied in
/Applications/apache/htdocs/wp-php/generateTable.php on line 5

Warning: chmod() [function.chmod]: No such file or directory in
/Applications/apache/htdocs/wp-php/generateTable.php on line 6

Warning:
fopen(/Applications/apache/htdocs/wp-php/tmp/tableToCutAndPaste.txt)
[function.fopen]: failed to open stream: No such file or directory in
/Applications/apache/htdocs/wp-php/generateTable.php on line 9

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 13

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 22

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 27

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 28

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 29

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 30

Warning: fwrite(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 35

Warning: fclose(): supplied argument is not a valid stream  
resource in

/Applications/apache/htdocs/wp-php/generateTable.php on line 39
--- end errors ---

The permissions are as follows (sorry I didn't think to include  
them in

my original message):

[Wed Jul 01 12:28:29] ~: ls -la /Applications/apache/htdocs/w

Re: [PHP] cannot figure out permissions for fopen/fwrite

2009-07-02 Thread Mari Masuda
Yes, currently the tmp folder (or any folders in my Apache htdocs  
folder) is not accessible to the web due to the Mac's built-in  
firewall set to block all incoming traffic except network time and  
something installed by Adobe when I installed CS4 (e.g., Photoshop,  
InDesign, etc.).  However, I was wondering what the normal technique  
is for writing files if the script that does the fopen/fwrite is  
located on a production server that IS on the web.  It occurred to me  
that I could create a 777 folder outside of the web root so that it  
would not be accessible on the web even if the script was running on  
a production server, but I wasn't sure if that was a good or bad idea.


On Jul 2, 2009, at 17:59, Waynn Lue wrote:


The tmp folder isn't accessible from the web though, right? Someone
would first have to get access to your server for that.

On 7/1/09, Mari Masuda  wrote:


On Jul 1, 2009, at 12:54, Shawn McKenzie wrote:


Mari Masuda wrote:

On Jul 1, 2009, at 12:20, Shawn McKenzie wrote:


Shawn McKenzie wrote:

Mari Masuda wrote:

Hello,

This is probably a dumb newbie question.  I am running PHP
5.2.5 and
Apache 2.2.8 on my Mac Book Pro OS X 10.4.11.  I compiled PHP  
and

Apache
from source a while ago (as opposed to using the built-in web
server
that is included w/ Mac OS X).  I have written the below PHP  
whose

purpose is to read an existing comma separated (CSV) file and
save the
data into a text file that I can later copy and paste from  
into my

website content management system.  The problem is that on my
Mac, I
cannot seem to figure out what permissions I need to set in
order to
make the input CSV and the initially non-existant output text  
file

readable and writable by Apache/PHP.  I have Googled and come
across
many pages about different ways to set permissions and different
permissions to set but none of the ways suggested that I tried
seemed to
work for me.  As a temporary solution, I uploaded my PHP file  
to a

Windows 2003 server running Apache and PHP and it worked
flawlessly
(and
makes me suspicious that there is some huge security hole  
with the

Windows box since it was able to execute with no permissions
modifications).  Any tips would be greatly appreciated.  Thanks!

Mari

--- start my code ---
$in = fopen("/Applications/apache/htdocs/wp-php/wp.csv",  
"r");

$out =
fopen("/Applications/apache/htdocs/wp-php/ 
tableToCutAndPaste.txt",

"w");
$counter = 0;


fwrite($out, "\n");

while(($data = fgetcsv($in)) !== FALSE) {
$paperNumber = $data[0];
$authors = $data[1];
$title = $data[2];
$filename = $paperNumber . ".pdf";

if(($counter % 2) == 0) {
fwrite($out, "\n");
} else {
fwrite($out, " 
\n");

}

fwrite($out, "http://www.example.com/workingpapers/getWorkingPaper.php?
filename=$filename\">$paperNumber\n");


fwrite($out, "$authors\n");
fwrite($out, "$title\n");
fwrite($out, "\n");

$counter++;
}

fwrite($out, "\n");


fclose($in);
fclose($out);

?>
--- end my code ---


What are the permissions on /Applications/apache/htdocs/wp-php/ ?

Apache needs write permissions on that dir in order to create
the file
tableToCutAndPaste.txt.

It's probably not a secure idea to give write permissions to
that dir,
so maybe create a subdir of tmp and change those permissions
(one way):

mkdir /Applications/apache/htdocs/wp-php/tmp
chmod a+w /Applications/apache/htdocs/wp-php/tmp



Also, turn on error reporting so that you can see the exact
problem.  It
may not be what you think.

--
Thanks!
-Shawn
http://www.spidean.com



Thanks for the suggestions.  I added the following lines to the
very top
of my code:

error_reporting(E_ALL);

mkdir("/Applications/apache/htdocs/wp-php/tmp", 0777, true);
chmod("/Applications/apache/htdocs/wp-php/tmp", "a+w");

and I also changed the line where it tries to open the file to
write to
to go to the new directory:

$out =
fopen("/Applications/apache/htdocs/wp-php/tmp/
tableToCutAndPaste.txt",
"w");

Below are the errors I got:
--- start errors ---
Warning: mkdir() [function.mkdir]: Permission denied in
/Applications/apache/htdocs/wp-php/generateTable.php on line 5

Warning: chmod() [function.chmod]: No such file or directory in
/Applications/apache/htdocs/wp-php/generateTable.php on line 6

Warning:
fopen(/Applications/apache/htdocs/wp-php/tmp/ 
tableToCutAndPaste.txt)
[function.fopen]: failed to open stream: No such file or  
directory in

/Applications/apache/htdocs/wp-php/generateTable.php on line 9

Warning: fwrite(): supplied argument is not a valid stream
resource in
/Applications/apache/htdocs/wp-php/generateTable.php on line 13

Warning: fwrite(): supplied ar

Re: [PHP] Re: PHP as Language

2009-07-24 Thread Mari Masuda


On Jul 24, 2009, at 11:30, Shawn McKenzie wrote:


Martin Scotta wrote:

Hi all

Is there a formal definition for the php language?
Where I can found it?

I've STW with no results.



What is a definition?  Do you mean specification like ECMA or ANSI?



I think he meant Backus Naur, but I could be wrong.

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



Re: [PHP] Single Quotes in Form Inputs

2009-07-27 Thread Mari Masuda
You need to sanitize and escape the input before inserting it into  
the db.  You can use http://us.php.net/mysql_real_escape_string to  
escape the input.


On Jul 27, 2009, at 09:35, Ben Miller wrote:


Hi,



I have a form in which my sales reps can add new clients into the  
database,
but I'm running into a problem if the client's name includes a  
single quote,
such as O'Henry, when it comes time to input the form data into the  
database
table.  I'm guessing I need to use ereg_replace, or something  
similar, to
change the single quote, but I still can't seem to get the syntax  
right.
Any help would be appreciated.  For what it's worth, here is a  
shortened

version of what I have:



$ firstName = "$_POST[form_firstName]";

$ lastname = "$_POST[form_lastName]";



$query = mysql_query("INSERT INTO customers (`cust_first`,`cust_last`)
VALUES ('$firstName','$lastName')");



Ben Miller






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



Re: [PHP] reason for a "Notice:.." on one site but not another? (Same code.)

2009-08-09 Thread Mari Masuda


On Aug 9, 2009, at 16:43, John Butler wrote:


Hi sunday  coders,

I've been using this kind of logic on one PHP site I work on to  
display one thing or another depending on whether the form was  
submitted or not:


if($_POST['UserWishesDateRange']) {  //--line 79
echo'submitted';
} else {
echo'NOT submitted';
}

and it works great on that site.

But on another site it still works, but gives this error:
Notice: Undefined index: UserWishesDateRange in /home/vs/site/phvs/ 
bl/7solarsecrets/admin/trackingcode.html on line 79


I assume that is because the error display settings are set to a  
more rigorous level in this latter site.

Is this correct?

(Both sites reside on servers where I am not the admin.)


John Butler (Govinda)
govinda.webdnat...@gmail.com



You could do something like:

if(isset($_POST['UserWishesDateRange'])) {  //--line 79  or you could  
use something like !empty($_POST['UserWishesDateRange'])

echo 'submitted';
} else {
echo 'NOT submitted';
}

This will check if $_POST['UserWishesDateRange'] is set to  
something.  You are getting the error message because $_POST 
['UserWishesDateRange'] is not set if the form is not submitted.  The  
server where you don't get the error message probably just has error  
reporting turned off.


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



Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo

2009-10-02 Thread Mari Masuda


On Oct 2, 2009, at 15:22, Daevid Vincent wrote:





-Original Message-
From: Ben Dunlap [mailto:bdun...@agentintellect.com]
Sent: Friday, October 02, 2009 2:58 PM
To: php-general@lists.php.net; Daevid Vincent
Subject: Re: [PHP] Whacky increment/assignment logic with
$foo++ vs ++$foo


mind-blowing. What the heck /is/ supposed to happen when

you do this:


   $a = 2;
   $a = $a++;
   echo $a;

Seems like any way you slice it the output should be 3. I

guess what's

... and, in fact, that /is/ how C behaves. The following code:

int a = 2;
a = a++;
printf("a = [%d]\n", a);

Will output "a = [3]". At least on Ubuntu 9 using gcc 4.3.3.

So I retract my initial terse reply and apologize for  
misunderstanding

your question.

Ben


EXACTLY! :)

God (or diety of your choice) bless you for "getting" what I'm  
saying and
proving that it's not "C" like either. That just adds credence to  
my/our

argument.


d



I think if you rewrote the above example as

int a = 2;
b = a++;
printf("b = [%d]\n", b);

"b" would be 2 when printed.  However, after the second line (b = a+ 
+;) finished executing, "a" would then be 3.


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



[PHP] XML parsing with PHP

2009-10-21 Thread Mari Masuda

Hi,

I need to transform some XML files and have not really done much  
XSLT.  I am looking for recommendations on ways to parse XML via  
PHP.  The XML files I have contain the content from our website CMS.   
We are switching from a proprietary CMS to Drupal and I need to  
transform the XML into .csv (comma separated) so I can suck the data  
into MySQL.  Any suggestions are appreciated.  Thanks!


Mari

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



[PHP] cannot compile PHP 5.2.11 on Mac OS X 10.6.1

2009-10-24 Thread Mari Masuda

Hi,

I am setting up my Mac Book Pro running Mac OS X 10.6.1 as a  
development environment for Drupal.  I already successfully have MySQL  
5.1.40 and Apache 2.2.11 up and running.  I tried to compile PHP  
5.2.11 in the following manner and keep getting an error.  Any help  
would be great!


1.  Downloaded php-5.2.11.tar.gz from php.net.  The MD5 checksum of  
the downloaded file is the same as what is listed on php.net so I do  
not think the file is corrupt.
2.  Expanded php-5.2.11.tar.gz by double-clicking the file I  
downloaded and moving the resulting folder (named "php-5.2.11") to my  
desktop.


In terminal did the following (I am following the instructions in the  
box labeled "Example #1 Installation Instructions (Apache 2 Shared  
Module Version)" at http://www.php.net/manual/en/install.unix.apache2.php 
)

3.  cd /Users/mari/Desktop/php-5.2.11
4.  ./configure --prefix=/Applications/php --disable-short-tags --with- 
mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config  
--with-apxs2=/Applications/apache/bin/apxs --enable-mbstring --with- 
pdo-mysql=/usr/local/mysql

5.  make

At this point, make does not complete and it exits with an error:

---start error---
Undefined symbols:
  "_res_9_dn_expand", referenced from:
  _zif_dns_get_mx in dns.o
  "_res_9_search", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_check_record in dns.o
  "_libiconv", referenced from:
  __php_iconv_strlen in iconv.o
  _php_iconv_string in iconv.o
  _php_iconv_string in iconv.o
  __php_iconv_strpos in iconv.o
  __php_iconv_appendl in iconv.o
  __php_iconv_appendl in iconv.o
  _zif_iconv_substr in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  "_res_9_dn_skipname", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
---end error---

To try to simplify things, I deleted the php-5.2.11 folder I created  
in step 2 above and repeated steps 2 and 3.  Then at this point I only  
did ./configure by itself with no options, thinking that I could try  
to see if any of my configuration options were causing the issue.   
Alas, no, the problem still happens; the error is now this:


---start error---
Undefined symbols:
  "_res_9_dn_expand", referenced from:
  _zif_dns_get_mx in dns.o
  "_res_9_search", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_check_record in dns.o
  "_libiconv", referenced from:
  __php_iconv_strlen in iconv.o
  _php_iconv_string in iconv.o
  _php_iconv_string in iconv.o
  __php_iconv_strpos in iconv.o
  __php_iconv_appendl in iconv.o
  __php_iconv_appendl in iconv.o
  _zif_iconv_substr in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _zif_iconv_mime_encode in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  _php_iconv_stream_filter_append_bucket in iconv.o
  "_res_9_dn_skipname", referenced from:
  _zif_dns_get_mx in dns.o
  _zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1
---end error---

What can I do to get around this problem and compile PHP?  Thanks!

Mari

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



[PHP] [SOLVED] Re: [PHP] cannot compile PHP 5.2.11 on Mac OS X 10.6.1

2009-10-25 Thread Mari Masuda

Hi,

So I found out there are two bugs filed in bugs.php.net that are  
related to this problem.  The bugs are http://bugs.php.net/bug.php?id=49332and 
 http://bugs.php.net/bug.php?id=49267.


To anyone else that has the same issues as me, here is how to get  
around the problem if you are trying to compile a freshly downloaded  
copy of PHP 5.2.11 on Mac OS X 10.6.1.


1.  First, open /ext/iconv/iconv.c and edit line 197.   
Lines 196-198 look like this originally:

---
#ifdef HAVE_LIBICONV
#define iconv libiconv
#endif
---
You need to change it to look like this:
---
#ifdef HAVE_LIBICONV
#define iconv iconv
#endif
---

2.  When you run ./configure, prepend LIBS=-lresolv so the resulting  
command is:

---
LIBS=-lresolv ./configure <...your options here...>
---

Now when you run make you should not get a compilation error and you  
should be able to follow the rest of the instructions on http://www.php.net/manual/en/install.unix.apache2.php 
 to get your PHP 5.2.11 up and running.


Mari


On Oct 24, 2009, at 15:33, Mari Masuda wrote:


Hi,

I am setting up my Mac Book Pro running Mac OS X 10.6.1 as a  
development environment for Drupal.  I already successfully have  
MySQL 5.1.40 and Apache 2.2.11 up and running.  I tried to compile  
PHP 5.2.11 in the following manner and keep getting an error.  Any  
help would be great!


1.  Downloaded php-5.2.11.tar.gz from php.net.  The MD5 checksum of  
the downloaded file is the same as what is listed on php.net so I do  
not think the file is corrupt.
2.  Expanded php-5.2.11.tar.gz by double-clicking the file I  
downloaded and moving the resulting folder (named "php-5.2.11") to  
my desktop.


In terminal did the following (I am following the instructions in  
the box labeled "Example #1 Installation Instructions (Apache 2  
Shared Module Version)" at http://www.php.net/manual/en/install.unix.apache2.php 
)

3.  cd /Users/mari/Desktop/php-5.2.11
4.  ./configure --prefix=/Applications/php --disable-short-tags -- 
with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/ 
mysql_config --with-apxs2=/Applications/apache/bin/apxs --enable- 
mbstring --with-pdo-mysql=/usr/local/mysql

5.  make

At this point, make does not complete and it exits with an error:

---start error---
Undefined symbols:
 "_res_9_dn_expand", referenced from:
 _zif_dns_get_mx in dns.o
 "_res_9_search", referenced from:
 _zif_dns_get_mx in dns.o
 _zif_dns_check_record in dns.o
 "_libiconv", referenced from:
 __php_iconv_strlen in iconv.o
 _php_iconv_string in iconv.o
 _php_iconv_string in iconv.o
 __php_iconv_strpos in iconv.o
 __php_iconv_appendl in iconv.o
 __php_iconv_appendl in iconv.o
 _zif_iconv_substr in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _php_iconv_stream_filter_append_bucket in iconv.o
 _php_iconv_stream_filter_append_bucket in iconv.o
 "_res_9_dn_skipname", referenced from:
 _zif_dns_get_mx in dns.o
 _zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
---end error---

To try to simplify things, I deleted the php-5.2.11 folder I created  
in step 2 above and repeated steps 2 and 3.  Then at this point I  
only did ./configure by itself with no options, thinking that I  
could try to see if any of my configuration options were causing the  
issue.  Alas, no, the problem still happens; the error is now this:


---start error---
Undefined symbols:
 "_res_9_dn_expand", referenced from:
 _zif_dns_get_mx in dns.o
 "_res_9_search", referenced from:
 _zif_dns_get_mx in dns.o
 _zif_dns_check_record in dns.o
 "_libiconv", referenced from:
 __php_iconv_strlen in iconv.o
 _php_iconv_string in iconv.o
 _php_iconv_string in iconv.o
 __php_iconv_strpos in iconv.o
 __php_iconv_appendl in iconv.o
 __php_iconv_appendl in iconv.o
 _zif_iconv_substr in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _zif_iconv_mime_encode in iconv.o
 _php_iconv_stream_filter_append_bucket in iconv.o
 _php_iconv_stream_filter_append_bucket in iconv.o
 "_res_9_dn_skipname", referenced from:
 _zif_dns_get_mx in dns.o
 _zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [sapi/cgi/php-cgi] Error 1
---end error---

What can I do to get around this problem and compile PHP?  Thanks!

Mari

--
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



Re: [PHP] [php] INSERT and immediately UPDATE

2009-10-28 Thread Mari Masuda
Maybe you could use http://us.php.net/manual/en/function.mysql-insert-id.php 
 to get the inserted id.


On Oct 28, 2009, at 12:21 PM, Allen McCabe wrote:


Hey everyone, I have an issue.

I need my (employee) users to be able to insert shows into the our  
MySQL
database and simultaneously upload an image file (and store the path  
in the

table).

I have accomplished this with a product-based system (adding  
products and
uploading images of the product), and accomplished what I needed  
because the

product name was unique; I used the following statements:

$prodName = $_POST['prodName'];
$prodDesc = $_POST['prodDesc'];
$prodPrice = $_POST['prodPrice'];

$query2  = "INSERT INTO product (pID, pName) VALUES (NULL,  
'$prodName');";

$result2 = mysql_query($query2) or die(mysql_error());

$query  = "SELECT pID FROM product WHERE pName = '$prodName';";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die (mysql_error());

$prodID = $row['pID'];


I had to select the new product to get the product id to use in the  
new

unique image name.

The problem I am facing now, is that with the shows that my users  
add will
have multitple show times; this means non-unique titles. In fact,  
the only
unique identifier is the show id. How can I insert something  
(leaving the
show_id field NULL so that it is auto-assigned the next ID number),  
and then

immediately select it?

PHP doesn't seem to be able to immediately select something it has  
just

inserted, perhaps it needs time to process the database update.

Here is the code I have now (which does not work):

$query2  = "INSERT INTO afy_show (show_id, show_title, show_day_w,
show_month, show_day_m, show_year, show_time, show_price,  
show_description,

show_comments_1, show_seats_reqd) VALUES (NULL, '{$show_title}',
'{$show_day_w}', '{$show_month}', '{$show_day_m}', '{$show_year}',
'{$show_time}', '{$show_price}', '{$show_description}',
'{$show_comments_1}', '{$show_seats_reqd}');";
$result2 = mysql_query($query2) or die(mysql_error());

$query3 = "SELECT * FROM afy_show WHERE *show_id = '$id'*;";
$result3 = mysql_query($query3) or die('Record cannot be located!' .
mysql_error());
$row3 = mysql_fetch_array($result3);
$show_id = $row3['show_id'];

How do I select the item I just inserted to obtain the ID number??



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



Re: [PHP] Change styling depending on var value

2009-11-20 Thread Mari Masuda

On Nov 20, 2009, at 2:29 PM, Ashley Sheridan wrote:

> On Fri, 2009-11-20 at 17:23 -0500, Phil Matt wrote:
> 
>> Ashley Sheridan wrote:
>> 
>>> put
>>> 
>>> var_dump($row);
>>> 
>> I inserted this line in the script at the end of the html table, still 
>> inside the PHP echo statement.
>> 
>> This yields:
>> 
>> bool(false)
>> 
>> Cheers --- Phil
> 
> 
> That means that $row doesn't contain what you thought it did. It
> contains the boolean value false (which is different from the string
> 'false') Are you sure you spelt the varialbe correctly in all of your
> code?

This may be a dumb question, but did you actually fetch the db query's results 
and put them in $row before trying to use $row?  In MySQL you could do 
something like:

$query = "select * from my_table";
$result = mysql_query($query);
$row = mysql_fetch_array($result);  //this statement would need to be inside of 
a loop if there is more than one result



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



Re: [PHP] Emergency! Performance downloading big files

2009-12-01 Thread Mari Masuda
On Dec 1, 2009, at 2:48 PM, Brian Dunning wrote:

> This is a holiday-crunch emergency.
[snip]
> Is there a SUBSTANTIALLY faster way to download and save these files? Keep in 
> mind the client's requirements cannot be changed. Thanks for any suggestions.


Could you just put the URLs of the files into something that you can iterate 
over and use curl to get the PDFs?  I don't know if this would be any faster 
than your method but it was just an idea.

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



Re: [PHP] Arrays & Regexp - Help Requested

2010-01-01 Thread Mari Masuda
I think the problem is here:

echo 'default 
text.  It looks like your code is trying to make a textarea that 
starts with http://www.w3.org/TR/html401/interact/forms.html#h-17.7 for how to use textarea.


On Jan 1, 2010, at 3:38 PM, Allen McCabe wrote:

> echo ' if ($input_type == 'text')
> {
>  echo 'size="';
>  $length = printByType($field['type'], 'INPUT_LENGTH');
>  echo $length;
>  echo '" ';
>  echo 'value="';
>  if ($field['null'] == 'YES') // CAN BE NULL?
>  {
>   echo 'NULL';
>  }
>  echo '" ';
> }
> elseif ($input_type == 'textarea')
> {
>  echo 'rows="7" cols="30" ';
>  echo 'value="';
>  if ($field['null'] == 'YES') // CAN BE NULL?
>  {
>   echo 'NULL';
>  }
>  echo '" ';
> }


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



Re: [PHP] Regexp and Arrays

2010-01-02 Thread Mari Masuda
On a quick glance I don't think you are doing the casting correctly.  For 
example, you have stuff like:

(string) $string; 

and 

(string) $key;
(int) $val;

and 

(int) $length_value = $match[1];

and the casted value is not being saved anywhere.

I believe it should be something like $string = (string) $string; in order to 
assign the casted value back to the variable.  In the third example, you 
probably meant $length_value = (int) $match[1];

On Jan 2, 2010, at 1:09 PM, Allen McCabe wrote:

> I have been plauged for a few days by this, can anyone see a problem with
> this function??
> 
> function printByType($string, $mode)
> {
>  (string) $string;
>  $lengths = array(
>'VARCHAR' => 10
>, 'TINYINT' => 1
>, 'TEXT' => 10
>, 'DATE' => 7
>, 'SMALLINT' => 1
>, 'MEDIUMINT' => 2
>, 'INT' => 2
>, 'BIGINT' => 3
>, 'FLOAT' => 4
>, 'DOUBLE' => 4
>, 'DECIMAL' => 4
>, 'DATETIME' => 10
>, 'TIMESTAMP' => 10
>, 'TIME' => 7
>, 'YEAR' => 4
>, 'CHAR' => 7
>, 'TINYBLOB' => 10
>, 'TINYTEXT' => 10
>, 'BLOB' => 10
>, 'MEDIUMBLOB' => 10
>, 'MEDIUMTEXT' => 10
>, 'LONGBLOB' => 10
>, 'LONGTEXT' => 10
>, 'ENUM' => 5
>, 'SET' => 5
>, 'BIT' => 2
>, 'BOOL' => 1
>, 'BINARY' => 10
>, 'VARBINARY' => 10);
>  $types = array(
>'VARCHAR' => 'text'
>, 'TINYINT' => 'text'
>, 'TEXT' => 'textarea'
>, 'DATE' => 'text'
>, 'SMALLINT' => 'text'
>, 'MEDIUMINT' => 'text'
>, 'INT' => 'text'
>, 'BIGINT' => 'text'
>, 'FLOAT' => 'text'
>, 'DOUBLE' => 'text'
>, 'DECIMAL' => 'text'
>, 'DATETIME' => 'text'
>, 'TIMESTAMP' => 'text'
>, 'TIME' => 'text'
>, 'YEAR' => 'text'
>, 'CHAR' => 'text'
>, 'TINYBLOB' => 'textarea'
>, 'TINYTEXT' => 'textarea'
>, 'BLOB' => 'textarea'
>, 'MEDIUMBLOB' => 'textarea'
>, 'MEDIUMTEXT' => 'textarea'
>, 'LONGBLOB' => 'textarea'
>, 'LONGTEXT' => 'textarea'
>, 'ENUM' => 'text'
>, 'SET' => 'text'
>, 'BIT' => 'text'
>, 'BOOL' => 'text'
>, 'BINARY' => 'text'
>, 'VARBINARY' => 'text');
> 
>  switch ($mode)
>  {
>   case 'INPUT_LENGTH':
>foreach ($lengths as $key => $val)
>{
> (string) $key;
> (int) $val;
> 
> // DETERMINE LENGTH VALUE eg. int(6) GETS 6
> preg_match('#\((.*?)\)#', $string, $match);
> (int) $length_value = $match[1];
> 
> // SEARCH
> $regex = "/" . strtolower($key) . "/i";
> $found = preg_match($regex, $string);
> 
> if ($found !== false)
> {
>  // DETERMINE ADD INTEGER eg. If the length_value is long enough,
> determine number to increase html input length
>  switch ($length_value)
>  {
>   case ($length_value <= 7):
>return $length_value;
>   break;
>   case ($length_value > 7 && $length_value < 15):
>return $val += ($length_value/2);
>   break;
>   case ($length_value > 14 && $length_value < 101):
>$result = ($length_value / 5);
>$divide = ceil($result);
>return $val += $divide;
>   break;
>   case ($length_value > 100):
>return 40;
>   break;
>   default:
>return 7;
>   break;
>  }
>  return $val;
> }
> else
> {
>  return 7; // default value
> }
>}
>   break;
> 
>   case 'INPUT_TYPE':
> 
>foreach ($types as $key => $val)
>{
> (string) $val;
> (string) $key;
> 
> // SEARCH
> $regex = "/" . strtolower($key) . "/i";
> $found = preg_match($regex, $string);
> 
> if ($found === false)
> {
>  return 'text'; // default value
> }
> else
> {
>  return $val;
> }
>}
>   break;
>  }
> 
> } // END function printByType()


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



[PHP] cannot access SimpleXML object property

2010-01-07 Thread Mari Masuda
Hi,

I am working with an XML document and have a SimpleXML object whose var_dump 
looks like this:

---
object(SimpleXMLElement)#2 (10) {
  ["@attributes"]=>
  array(1) {
["id"]=>
string(7) "3854857"
  }
  ["type"]=>
  string(7) "Article"
  ["createDate"]=>
  string(25) "2006-09-06T16:42:20-07:00"
  ["editDate"]=>
  string(25) "2007-07-16T09:15:53-07:00"
  ["creator"]=>
  string(19) "Michael Gottfredson"
  ["status"]=>
  string(5) "ready"
  ["field"]=>
  ...snip a bunch of stuff...
}
---

Assuming the above object is referenced by $current_object, I can access the 
values of most stuff with $current_object->creator or whatever.  However, I 
cannot figure out how to access the value of id.  I tried the following, none 
of which worked for me:

1.  $current_object->@attributes->id (gives Parse error: syntax error, 
unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in 
/Applications/apache/htdocs/test.php on line 33)

2.  $current_object->'@attributes'->id (gives Parse error: syntax error, 
unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or '{' 
or '$' in/Applications/apache/htdocs/test.php on line 33)

3.  $current_object->{...@attributes}->id (no error but is null)

4.  $current_object->{'@attributes'}->id (no error but is also null)

Does anyone know how I can reference the value of id?  Thanks!

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



Re: [PHP] cannot access SimpleXML object property

2010-01-07 Thread Mari Masuda

On Jan 7, 2010, at 2:31 PM, Jonathan Tapicer wrote:

> On Thu, Jan 7, 2010 at 6:56 PM, Mari Masuda  wrote:
>> Hi,
>> 
>> I am working with an XML document and have a SimpleXML object whose var_dump 
>> looks like this:
>> 
>> ---
>> object(SimpleXMLElement)#2 (10) {
>>  ["@attributes"]=>
>>  array(1) {
>>["id"]=>
>>string(7) "3854857"
>>  }
>>  ["type"]=>
>>  string(7) "Article"
>>  ["createDate"]=>
>>  string(25) "2006-09-06T16:42:20-07:00"
>>  ["editDate"]=>
>>  string(25) "2007-07-16T09:15:53-07:00"
>>  ["creator"]=>
>>  string(19) "Michael Gottfredson"
>>  ["status"]=>
>>  string(5) "ready"
>>  ["field"]=>
>>  ...snip a bunch of stuff...
>> }
>> ---
>> 
>> Assuming the above object is referenced by $current_object, I can access the 
>> values of most stuff with $current_object->creator or whatever.  However, I 
>> cannot figure out how to access the value of id.  I tried the following, 
>> none of which worked for me:
>> 
>> 1.  $current_object->@attributes->id (gives Parse error: syntax error, 
>> unexpected '@', expecting T_STRING or T_VARIABLE or '{' or '$' in 
>> /Applications/apache/htdocs/test.php on line 33)
>> 
>> 2.  $current_object->'@attributes'->id (gives Parse error: syntax error, 
>> unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING or T_VARIABLE or 
>> '{' or '$' in/Applications/apache/htdocs/test.php on line 33)
>> 
>> 3.  $current_object->{...@attributes}->id (no error but is null)
>> 
>> 4.  $current_object->{'@attributes'}->id (no error but is also null)
>> 
>> Does anyone know how I can reference the value of id?  Thanks!
>> 
>> Mari
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>> 
>> 
> 
> 
> $id = (string)$current_object['id'];


Thank you.  I also found I could do it with 
$current_object->attributes()->id
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] how do I use php://memory?

2010-01-29 Thread Mari Masuda
Hello,

I have a function that uses tidy to attempt to clean up a bunch of crappy HTML 
that I inherited.  In order to use tidy, I write the crappy HTML to a temporary 
file on disk, run tidy, and extract and return the clean(er) HTML.  The program 
itself works fine but with all of the disk access, it runs quite slowly.  I saw 
on this page (http://www.php.net/manual/en/wrappers.php.php) that I could write 
to memory by using php://memory.  Unfortunately, I could not quite get it to 
work.  The problem is that in the below function, the code within the [[[if 
(file_exists($dirty_file_path))]]] does not get run if I change 
[[[$dirty_file_path]]] to "php://memory".  Has anyone ever successfully used 
php://memory before?  If so, what can I do to use it in my code?  Thank you.


//==
function cleanUpHtml($dirty_html, $enclose_text=true) {

$parent_dir = "/filesWrittenFromPHP/";
$now = time();
$random = rand();

//save dirty html to a file so tidy can process it
$dirty_file_path = $parent_dir . "dirty" . $now . "-" . $random . 
".txt";
$dirty_handle = fopen($dirty_file_path, "w");
fwrite($dirty_handle, $dirty_html);
fclose($dirty_handle);

$cleaned_html = "";
$start = 0;
$end = 0;

if (file_exists($dirty_file_path)) {
exec("/usr/local/bin/tidy -miq -wrap 0 -asxhtml --doctype 
strict --preserve-entities yes --css-prefix \"tidy\" --tidy-mark no 
--char-encoding utf8 --drop-proprietary-attributes yes  --fix-uri yes " . 
($enclose_text ? "--enclose-text yes " : "") . $dirty_file_path . " 2> 
/dev/null");

$tidied_html = file_get_contents($dirty_file_path);

$start = strpos($tidied_html, "") + 6;
$end = strpos($tidied_html, "") - 1;

$cleaned_html = trim(substr($tidied_html, $start, ($end - 
$start)));
}

unlink($dirty_file_path);


return $cleaned_html;
}
//==


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



Re: [PHP] how do I use php://memory?

2010-01-29 Thread Mari Masuda

On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote:

> On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda  wrote:
> Hello,
> 
> I have a function that uses tidy to attempt to clean up a bunch of crappy 
> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
> temporary file on disk, run tidy, and extract and return the clean(er) HTML.  
> The program itself works fine but with all of the disk access, it runs quite 
> slowly.
> 
> why read from disk in the first place?
> 
> http://us3.php.net/manual/en/tidy.parsestring.php
> 
> -nathan 

Thank you, this looks like exactly what I need.  Unfortunately I cannot get it 
to work on my machine.  I recompiled PHP with --with-tidy=/usr/local and this 
is the version and modules in use:

[Fri Jan 29 22:50:41] ~: php -vPHP 5.2.12 (cli) (built: Jan 29 2010 22:35:24) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
[Fri Jan 29 22:52:30] ~: php -m
[PHP Modules]
ctype
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mysql
mysqli
pcre
PDO
pdo_mysql
pdo_sqlite
posix
Reflection
session
SimpleXML
SPL
SQLite
standard
tidy
tokenizer
xml
xmlreader
xmlwriter
zlib

[Zend Modules]

[Fri Jan 29 22:52:34] ~: 


When I run this test code
=
blahhello";
$config = array('indent' => true,
'wrap' => '0');

// Tidy
$tidy = new tidy();
var_dump($tidy);
$tidy->parseString($html, $config, 'utf8');
var_dump($tidy);
$tidy->cleanRepair();
var_dump($tidy);
echo tidy_get_output($tidy);
var_dump($tidy);
?>
=

I get this output:
=
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}
object(tidy)#1 (2) {
  ["errorBuffer"]=>
  NULL
  ["value"]=>
  NULL
}


I have no clue what I'm doing wrong...

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



Re: [PHP] how do I use php://memory?

2010-01-29 Thread Mari Masuda

On Jan 29, 2010, at 10:57 PM, Mari Masuda wrote:

> 
> On Jan 29, 2010, at 4:38 PM, Nathan Nobbe wrote:
> 
>> On Fri, Jan 29, 2010 at 5:35 PM, Mari Masuda  
>> wrote:
>> Hello,
>> 
>> I have a function that uses tidy to attempt to clean up a bunch of crappy 
>> HTML that I inherited.  In order to use tidy, I write the crappy HTML to a 
>> temporary file on disk, run tidy, and extract and return the clean(er) HTML. 
>>  The program itself works fine but with all of the disk access, it runs 
>> quite slowly.
>> 
>> why read from disk in the first place?
>> 
>> http://us3.php.net/manual/en/tidy.parsestring.php
>> 
>> -nathan 
> 
> Thank you, this looks like exactly what I need.  Unfortunately I cannot get 
> it to work on my machine.

[snip]

So I figured it out... I was using the wrong command to compile libtidy.  (I am 
not a *nix geek so I had no idea I was messing it up.)  To get it working, I 
followed the instructions I found here: 
http://www.php.net/manual/en/ref.tidy.php#64281

My setup is slightly different from the person who wrote the directions in that 
I am running OS X 10.6.2 and PHP 5.2.12.  However, the only difference between 
the instructions I followed and what I actually had to do is that the line to 
comment out for me was line 525 instead of 508.  (The actual line is: typedef 
unsigned long ulong;)

Thank you everyone for your help!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Mari Masuda
Also, in PHP you should NOT put the last semi-colon at the end of your SQL 
statement.  http://www.php.net/manual/en/function.mysql-query.php

On Feb 11, 2010, at 1:26 PM, Joseph Thayne wrote:

> Try putting tick marks (`) around the field and table names.  So your SQL 
> query would then look like:
> 
> INSERT INTO `history` (`v_id`, `hour`, `visits`, `date`) VALUES (45, 0, 59, 
> '2010 01 27');
> 
> This is a good practice to get into.  The problem is that MySQL allows you to 
> create tables and fields with the same name as functions.  If the tick marks 
> are not there, then it assumes you mean to try using the function.  In your 
> case, hour is a function in mysql.  I would assume that the reason it works 
> in phpmyadmin is that it filters the query somehow to add the tick marks in.
> 
> Joseph
> 
> james stojan wrote:
>> I'm at my wits end trying to make this mysql statement insert work in
>> PHP. I'm not getting any errors from PHP or mysql but the insert fails
>> (nothing is inserted) error reporting is on and is reporting other
>> errors. When I echo out the query and manually paste it into PHP
>> myAdmin the query inserts without a problem. I know that I am
>> connecting to the database as well part of the data being inserted
>> comes from the same database and that the mysql user has permission to
>> do inserts (even tried as root no luck).
>> 
>> $query="INSERT INTO upload_history (v_id,hour,visits,date) VALUES
>> (".$v_id.",".$hour.",".$visits.",'$date1'".");";
>> 
>> $r2=mysql_query($query) or die("A fatal MySQL error
>> occured.\nQuery: " . $query . "\nError: (" .
>> mysql_errno() . ") " . mysql_error());
>> 
>> This is an echo of $query and runs in phpmyadmin.
>> 
>> INSERT INTO history (v_id,hour,visits,date) VALUES (45,0,59,'2010 01 27');
>> 
>> 
>> Any idea what is going on here?
>> 
>>  
> 
> -- 
> 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



Re: [PHP] Replacing a special character

2010-04-18 Thread Mari Masuda
Maybe you could try to assign the return value of preg_replace to a variable so 
you can use it later, like: 

$name = preg_replace('/−/','-',$name);


On Apr 18, 2010, at 11:38 AM, Michael Stroh wrote:

> Thanks for the advice. I've changed the code to use mysql_real_escape_string. 
> So now it is
> 
>  $name = mysql_real_escape_string($name);
>  preg_replace('/−/','-',$name);
> 
> but it's still not replacing the − string. I've also changed the field 
> in the database so that now it is using the collation utf8_general_ci. I've 
> also tried
> 
>  preg_replace('/−/','-',$name);
>  $name = mysql_real_escape_string($name);
>  preg_replace('/−/','-',$name);
> 
> and that also did not work. Any ideas?
> 
> Michael
> 
> 
> 
> On Apr 18, 2010, at 1:08 PM, Michiel Sikma wrote:
> 
>> On 18 April 2010 16:46, Peter Lind  wrote:
>> 
>>> On 18 April 2010 16:40, Phpster  wrote:
 
 
 On Apr 18, 2010, at 8:59 AM, Michael Stroh  wrote:
 
> I have this form that people use to add entries into a MySQL database.
> Recently I've had some users insert − in their entries instead of -
>>> which is
> causing some issues with scripts down the line. I'd like to replace the
>>> −
> character with -.
> 
> Originally I had something like
> 
> $name = mysql_escape_string($_POST["name"]);
> 
> which would convert the offending character to − before entering
>>> it
> into the database. It's this encoding that is causing the problems since
> some scripts send out emails with this entry in their subject line which
> looks messy.
> 
> I've tried adding the following line after the previous line to help fix
> this issue, however, I just got another entry with the same problem.
> 
> preg_replace('/−/','-',$name);
> 
> Any suggestions on how others would fix this problem? I'd just like to
>>> fix
> it before the entry hits the database instead of creating fixes on the
>>> other
> end of things.
> 
> 
> Cheers,
> Michael
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
 
 One option is to send an HTML email which would have the email reader
 interpret that code correctly
 
 Bastien
>>> 
>>> Another option would be to use mysql_real_escape_string and make sure
>>> that your code and the database are using utf-8. Then when the email
>>> is sent, make sure that uses utf-8 as well.
>>> 
>>> Regards
>>> Peter
>>> 
>>> 
>> Make sure the database connection is also utf8:
>> 
>> set names 'utf8';
>> 
>> Typically, you should keep everything in utf8 unless you have a very good
>> reason not to.
>> And as Peter mentioned, the proper way to escape MySQL inserts (that is, if
>> you're not already using a framework that does this competently) is
>> mysql_real_escape_string().
>> 
>> Michiel
> 
> 
> --
> 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



Re: [PHP] What's wrong with this code?

2010-06-05 Thread Mari Masuda
Could it be that you are not using the same variable name?  In the if statement 
you are using $row['EndDate'] and when attempting to print you are using 
$row['enddate'].  I think you need to be consistent about which capitalization 
you use (and make sure it matches what is in the db).

>>> if (!empty($row['EndDate'])) {
>>> echo "" . $row['enddate'] . "";
>>> }



On Jun 5, 2010, at 5:43 PM, David Mehler wrote:

> Hi,
> Thanks. I took out the entire else section including the exit call, it
> now all processes, however $row['enddate'] is not displayed on the two
> records where it is set.
> Thanks.
> Dave.
> 
> 
> On 6/5/10, Karl DeSaulniers  wrote:
>> Could the exit() be terminating it? Do you need this exit() as the
>> else for that if statement? Try deleting just the else {}.
>> 
>> JAT
>> 
>> Karl
>> 
>> Sent from losPhone
>> 
>> On Jun 5, 2010, at 6:54 PM, David Mehler  wrote:
>> 
>>> Hello,
>>> I've got a while loop outputting values from a database. Briefly it
>>> looks like this:
>>> 
>>> while($row = mysql_fetch_array($result3))
>>> {
>>> echo "";
>>> echo "" . $row['name'] . "";
>>> echo "" . $row['type'] . "";
>>> echo "" . $row['startdate'] . "";
>>> if (!empty($row['EndDate'])) {
>>> echo "" . $row['enddate'] . "";
>>> } else {
>>> exit();
>>> }
>>> echo "" . $row['location'] . "";
>>> echo "" . $row['summary'] . "";
>>> echo "" . $row['description'] . "";
>>> echo "";
>>> }
>>> 
>>> That's not the whole code, but it is the problem code. Some output has
>>> the ending date set, one or two records i can't remember how many i
>>> entered with one, most do not, i want the echo to be conditional. The
>>> output stops right before the if statement, echoes startdate and
>>> that's it, comment out the if block and it works fine.
>>> Thanks.
>>> Dave.
>>> 
>>> --
>>> 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 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



Re: [PHP] Quick session question

2010-06-24 Thread Mari Masuda

On Jun 24, 2010, at 9:09 AM, Danny wrote:

> Thanks Ashley and Jim,
> 
>> When you say 'sessions did not work' what do you mean? Sessions aren't being
>> created? You can't access session variables? You need to be a bit more 
>> specific
>> about the issue.
> 
> Sorry, here is an explanation:
> 
> The project I uploaded for a customer is a "stock ordering" web-app that they 
> used
> on their local intranet for a year or so, but now they want this same web-app 
> to
> be available globally.
> 
> I thought that it would work "out-the-box" on the internet but it doesn't. On
> their local-lan I am able to do some (advanced) login checks with sessions 
> with no
> problem, like I said, it has been workng for a year or so now. Also, the same
> login sequence I use here I also use in my other intranet web-apps.
> 
> However, when I uploaded this project and I log on, I just get a blank screen
> after the login checks are done and it is supposed to take me to the logged-in
> start page.
> 
> That is why I say that somehow my sessions are not "carried over" or "caught" 
> by php.
> 
> Thanks for the comments on my session initialization, if there is not really
> anything that should be changed, then I will leave it like it is.
> 
> Just one more thing, should I always expand the URL's to an absolute path
> instead of using a session variable like I do?
> 
> Thnks again guys
> 
> Danny
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



Maybe you need to change 

$_SESSION['server'] = "http://localhost/~user/new_project"; ;

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



Re: [PHP] mysqldump

2010-08-17 Thread Mari Masuda

On Aug 17, 2010, at 11:40 AM, tedd wrote:

> At 2:17 PM -0400 8/17/10, Robert Cummings wrote:
>> On 10-08-17 02:08 PM, tedd wrote:
>>> Hi gang:
>>> 
 At 6:11 PM -0400 8/13/10, Daniel P. Brown wrote:
 Easiest method, from the command line on the server from which you
 want to dump the database:
 
 mysqldump -u user -p database_name>  outfile.sql
>> 
>> Command is wrong... should be:
>> 
>>mysqldump -u user -p password database_name > outfile.sql
> 
> 
> I did catch that, but did not correct it in my post (considering it was a 
> direct quote).
> 
> ---

Actually, 

mysqldump -u user -p password database_name > outfile.sql 

is also the incorrect command.  When providing the password in the command, 
there should not be a space between the "-p" and the actual password.  Try 

mysqldump -u user -ppassword database_name > outfile.sql 

and see if that gets you anywhere.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Character encoding hell

2010-10-26 Thread Mari Masuda

On Oct 26, 2010, at 10:10 AM, Marc Guay wrote:

>> A windows server, or windows client to the same Linux server? I believe that 
>> this issue is starting to get a bit over my head, with the different 
>> operating systems involved and such.
> 
> Windows server.  This is over my head, too.  I'm guessing that Windows
> and Linux encode filenames differently and when I transferred the file
> from one to the other, some kind of adjustment was made.
> 
> Marc

I think one way to do this is something like this (untested):

1.  Put all of your files in some directory on the server.

2.  Change your http://example.com/encoded-file-name.pdf";>my file 
to http://example.com/download-file.php?fileID=xxx";>my file where 
xxx is the urlencoded version of "encoded-file-name.pdf".  (xxx could also be a 
fileID number if stored in a database.)

3.  In download-file.php do something like this:


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



[PHP] mysqli fetch-fields returns blob for text

2011-01-04 Thread Mari Masuda
Hello,

On http://www.php.net/manual/en/mysqli.constants.php there are some predefined 
constants for MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, 
MYSQLI_TYPE_LONG_BLOB, and MYSQLI_TYPE_BLOB.  Through some experimentation I 
have found that fields in my MySQL database that are declared as 'text' in 
MySQL are categorized by PHP as 'blob' when I compare the above constants to 
the field's type using 
http://www.php.net/manual/en/mysqli-result.fetch-fields.php.

In the MySQL documentation http://dev.mysql.com/doc/refman/5.1/en/blob.html in 
the second paragraph it states: 
---
BLOB values are treated as binary strings (byte strings). They have no 
character set, and sorting and comparison are based on the numeric values of 
the bytes in column values. TEXT values are treated as nonbinary strings 
(character strings). They have a character set, and values are sorted and 
compared based on the collation of the character set.
---

I was wondering if PHP's interpretation of 'text' as 'blob' could cause me any 
trouble down the road and what the workarounds are, if any.  Thank you.

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



Re: [PHP] Stripping carriage returns

2011-01-11 Thread Mari Masuda

On Jan 11, 2011, at 11:34 AM, Richard S. Crawford wrote:

> Strangely, when I use \n, or nl2br(), or PHP_EOL, or anything like that, it
> strips out not just line breaks, but most of the rest of the text as well. I
> suspect an encoding issue at this point.
> 
> Daniel, you were right when you said that neither of my str_replace lines
> had repl.acement values; that was indeed a typo when I was copying the code
> over into my email.
> 
> Ashley, I've already been using strip_tags to eliminate all but , ,
> , and  tags.
> 

Perhaps you could use tidy to clean up the formatting  (use -wrap 0) before 
attempting to strip out the stuff you want to get rid of.

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



[PHP] how to dynamically generate list of arguments to pass to array_diff

2011-02-18 Thread Mari Masuda
Hello,

I have an array of arrays like this:
---
[array_of_arrays:private] => Array
(
[0] => Array
(
[0] => 2
[1] => 4
[2] => 5
[3] => 17
[4] => 80
)

[1] => Array
(
[0] => 5
[1] => 7
[2] => 9
[3] => 2
[4] => 16
[5] => 58
)

[2] => Array
(
[0] => 2
[1] => 4
[2] => 6
[3] => 8
[4] => 37
[5] => 92
)

)
---
and I want to do an array_diff on them so that I get something like this back:
---
Array
(
[0] => 6
[1] => 7
[2] => 8
[3] => 9
[4] => 16
[5] => 17
[6] => 37
[7] => 58
[8] => 80
[9] => 92
)
---

The arrays above are just an example; the real arrays I am working with can 
have many more elements (in the tens of thousands).  Also, there can be a 
variable number of subarrays.  I have written several different versions of my 
own array_diff that iterates over all the subarrays but they are slow.

My question is is there a way to call the built-in array_diff with a 
dynamically generated list of arguments?  I was thinking maybe there would be a 
way to do this with variable variables or if I generated a string that could be 
parsed by PHP but I have only succeeded in confusing myself further.  Thanks 
for any suggestions.

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



[PHP] Re: [SOLVED] [PHP] how to dynamically generate list of arguments to pass to array_diff

2011-02-18 Thread Mari Masuda

On Feb 18, 2011, at 12:03 PM, Simon J Welsh wrote:

> 
> On 19/02/2011, at 8:07 AM, Mari Masuda wrote:
>> My question is is there a way to call the built-in array_diff with a 
>> dynamically generated list of arguments?  I was thinking maybe there would 
>> be a way to do this with variable variables or if I generated a string that 
>> could be parsed by PHP but I have only succeeded in confusing myself 
>> further.  Thanks for any suggestions.
>> 
>> Mari
> 
> call_user_func_array('array_diff', $this->array_of_arrays);
> 
> http://php.net/call_user_func_array
> 
> Though from your example, passing multiple arrays to array_diff is not what 
> you're after, as it just returns the items in the first array that are not in 
> any of the others.
> ---
> Simon Welsh
> Admin of http://simon.geek.nz/
> 
> Who said Microsoft never created a bug-free program? The blue screen never, 
> ever crashes!
> 
> http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e
> 

Hi Simon,

Thank you for the info on call_user_func_array and for pointing out my error!  
(That bug would partially explain why I have been beating my head against the 
wall for the last several days.)  call_user_func_array is exactly what I need.  
Thanks again!

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



[PHP] call_user_func_array and bind_result

2011-12-16 Thread Mari Masuda
Hello,

I am having trouble figuring out how to properly bind the results of a mysqli 
prepared statement using call_user_func_array.

I have an "AbstractModel" abstract class and within the class is a method 
called "load" that takes the primary key of the desired item and retrieves and 
loads the data from the database into the object.

abstract class AbstractModel {
// lots of stuff omitted

// this is just a rough draft so no error checking is implemented
// $db is a subclass of mysqli
// $primaryKeyAsTypedItem is an object that holds a type (int, float, 
string, etc.) and value
public function load($db, $primaryKeyAsTypedItem) {
$query = "SELECT * FROM " . $this->tableName . " WHERE " . 
$this->primaryKeyName . "=?"; 
$ps = $db->prepare($query); 
$type_string = $primaryKeyAsTypedItem->getTypeAbbreviation(); 
$value = $db->escapeSql($primaryKeyAsTypedItem->getValue()); 
$ps->bind_param($type_string, $value); 
$ps->execute(); 
$ps->store_result(); 
$metadata = $ps->result_metadata()->fetch_fields(); 
$params = array(); 
foreach ($metadata as $object) { 
$params[$object->orgname] = null;
} 
call_user_func_array(array($ps, 'bind_result'), $params); 
$ps->fetch(); 

// see what is going on
print ""; 
var_dump($params); 
print "";

// more stuff omitted
}
}

The problem I am having is that mysqli_stmt::bind_result expects a list of 
individual variables to which the results are bound, not just an array with the 
proper number of available indices.  I have done a lot of Googling and tried 
following the advice I found at [1], [2], [3], etc. but I was not successful in 
getting this to work.  I don't know how I can generically "expand" $params so 
that this will work for different tables with different fields.  Any pointers 
greatly appreciated.

[1] 
http://forums.devshed.com/php-development-5/mysqli-bind-result-to-return-array-568982.html
[2] 
http://www.charles-reace.com/blog/2009/04/28/mysqli-avoiding-bind_result-for-every-column/
[3] http://us.php.net/manual/en/mysqli-stmt.bind-result.php#102179
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] call_user_func_array and bind_result

2011-12-16 Thread Mari Masuda
On Dec 16, 2011, at 4:51 PM, David Harkness wrote:

> Each *value* in the array must be a reference to an existing variable--they 
> cannot be null or direct values. 

[snip]

Thank you very much for your explanation and example code.  I was missing the 
fact that the *values* in the array must be references.  I was thinking that 
call_user_func_array wanted a reference to the array itself where I wanted the 
values stored, but when I tried doing 

call_user_func_array(array($ps, 'bind_result'), &$params);

I got the following deprecation notice so I knew I was on the wrong track but 
didn't know where I was going wrong:
Warning: Call-time pass-by-reference has been deprecated in 
/Applications/apache/htdocs/hila/includes/class.AbstractModel.php on line 176

In the course of studying your example and trying to get it to work I also 
discovered a problem elsewhere in my code where the value of the primary key 
field in my MySQL database, defined as 

`user_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT

was being returned to PHP as a string instead of an int, and this was causing a 
type mismatch that ultimately resulted in all fields of the results array being 
populated with NULLs, which is why all of the examples on the pages I Googled 
did not appear to be working for me.  

In the end I changed the relevant part of my code to the following and thanks 
to your help it is now working:

$params = array();
$values = array();
foreach ($metadata as $object) {
$params[] = &$values[$object->orgname];
}
call_user_func_array(array($ps, 'bind_result'), $params);
$ps->fetch();
   
print "";
var_dump($values);
print "";

Thanks again and happy holidays!

Re: [PHP] Headers on smart phone browsers

2012-02-05 Thread Mari Masuda

On Feb 5, 2012, at 9:58 PM, Paul M Foster wrote:

[snip]

> 3) Bonus question: Is there a preferred method amongst coders to
> determine what type of environment is being browsed from, so as to serve
> up the proper type of page (desktop or smart phone version of a
> webpage)?

[snip]

You should read up on responsive web design.  
http://www.alistapart.com/articles/responsive-web-design/ should get you 
started.  HTH!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Headers on smart phone browsers

2012-02-06 Thread Mari Masuda

On Feb 6, 2012, at 1:01 PM, Stuart Dallas wrote:

[snip]

> Generally speaking you're better off with a design that automatically adapts 
> to the viewport on which it's being displayed.

[snip]

For a concrete example of responsive design in action, point your browser to 
http://www.sasquatchfestival.com/ and then slowly make the window 
wider/skinnier to see how the design adapts to different viewport sizes.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] iphone & php

2012-03-05 Thread Mari Masuda
On Mar 5, 2012, at 9:52 AM, Jim Giner wrote:

> 
> "Jay Blanchard"  wrote in message 
> news:4f54faf8.4030...@sigmaphinothing.org...
>> [snip]In the last few mins I re-booted my phone and it is now doing 
>> something even worse! [/snip]
>> 
>> Have you also cleared the cache and the cookies?
>> 
>> You can also add Firebug to your iPhone - 
>> http://www.iphone-my.com/ipad/geting-firebug-iphone-ipad/
> 
> No - I didn't go that far, but I can.  More testing has revealed that Safari 
> running on my PC also doesn't like to accept the date I'm inputting.  As 
> soon as I tab off the field, it changes itself to whatever my first two 
> digits were. 

Do you have a maxlength set by accident?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] To ?> or not to ?>

2012-04-03 Thread Mari Masuda

On Apr 3, 2012, at 2:29 PM, Tedd Sperling wrote:

> Hi gang:
> 
> Let me start a religious war -- should one end their scripts with "?>" or not?
> 
> After years of never having a problem with ending any of my scripts with 
> "?>", I found that several students in my class had scripts that did not 
> produce the desired result even after they were given the scripts via 
> highlight_file(") to cut and paste.
> 
> As it turned out, several students copy/pasted the script with an addition 
> whitespace after the ending "?>" and as such the scripts did not run as 
> expected. You see, the scripts created image but apparently the image 
> delivery method objected to the additional whitespace.
> 
> Does anyone have more examples of where scripts will fail IF they end with 
> "?> " (note the additional space)?
> 
> Cheers,
> 
> tedd

I believe this can also be problematic if script A ends with "?> " (with 
additional space) and script B includes script A at the top, which will cause 
the headers to be sent.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php