php-windows Digest 14 Jan 2005 05:24:30 -0000 Issue 2534
Topics (messages 25302 through 25324):
Error when trying to get global variables
25302 by: Louis Young
25306 by: Jason Barnett
Re: HTML in PHP to a File
25303 by: David Elliott
25304 by: Jason Barnett
25305 by: Michael Adams
Reg Ex help
25307 by: Ron.Herhuth.tatumpartners.com
25311 by: Leif Gregory
25312 by: Wagner, Aaron
25313 by: Rafael Soares
25317 by: trystano.aol.com
25318 by: Jason Barnett
25319 by: Randy Clamons
Application variables
25308 by: Louis Young
25309 by: Jason Barnett
This is a tricky one
25310 by: Louis Young
25315 by: David OBrien
25316 by: Randy Clamons
including an HTML file
25314 by: Gaetano Savoca
25323 by: Gaetano Savoca
Re: weird problem php mssql
25320 by: Frank M. Kromann
Re: [PHP] php editor
25321 by: tg-php.gryffyndevelopment.com
25322 by: Jason Barnett
25324 by: Dean Hayes
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hi there
I've used a tool called asp2php to convert all my asp files to php
files, but now in ASP you have the global.asa file. I've converted this
to global.php. So now part of it looks as follows:
function Application_OnStart()
{
extract($GLOBALS);
$Application["ConnectionString"]="PROVIDER=SQLOLEDB;DATA
SOURCE=MYDB;UID=myuser;PWD=mypwd;DATABASE=mydb";
return $function_ret;
}
Now from one of the other pages:
<?
include "global.php";
session_start();
session_register("Login_session");
session_register("Outlet_session");
echo $Application["ConnectionString"];
?>
But I get the following warning:
*Warning*: session_start(): Cannot send session cache limiter - headers
already sent (output started at C:\Program Files\Apache
Group\Apache2\htdocs\spar\admin\global.php:52) in *C:\Program
Files\Apache Group\Apache2\htdocs\spar\admin\login.php* on line *3
On line 52 in global.php there is nothing. This is the end of the file.
Line 3 in login.php is:
session_start();
*echo $Application["ConnectionString"];
also doesn't print out anything.
What am I doing wrong?
Cheers
Louis
--- End Message ---
--- Begin Message ---
Louis Young wrote:
Hi there
I've used a tool called asp2php to convert all my asp files to php
files, but now in ASP you have the global.asa file. I've converted this
to global.php. So now part of it looks as follows:
It actually worked? Cool!
function Application_OnStart()
{
extract($GLOBALS);
$Application["ConnectionString"]="PROVIDER=SQLOLEDB;DATA
SOURCE=MYDB;UID=myuser;PWD=mypwd;DATABASE=mydb";
return $function_ret;
}
Now from one of the other pages:
<?
include "global.php";
session_start();
session_register("Login_session");
session_register("Outlet_session");
echo $Application["ConnectionString"];
?>
But I get the following warning:
*Warning*: session_start(): Cannot send session cache limiter - headers
already sent (output started at C:\Program Files\Apache
Group\Apache2\htdocs\spar\admin\global.php:52) in *C:\Program
Files\Apache Group\Apache2\htdocs\spar\admin\login.php* on line *3
Unless you are specifically doing a header() call this is caused by
sending output to stdout.
On line 52 in global.php there is nothing. This is the end of the file.
Is there a line of blank text at the end of the code? This has been
known to cause this problem and while it isn't obvious from viewing your
code... it's being sent as content. Or at least this is oftentimes what
causes this error.
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
--- End Message ---
--- Begin Message ---
Hail Mike,
The ancient mystics foretold that on 13 January 2005, at 03:05:02 +0100
(which was 01:46 where I live) Mike rearranged electrons to get
> I have a PHP file that outputs HTML to the Internet to a user. The user
> also wants to be able to print that output to a printer. The user wants
> it formatted with page breaks in the proper place and so on. Using one
> PHP script to do both, short of a line to display and a line to print, is
> there a way to do this easily or am I in a pond of alligators? Most of
> the output is using an echo statement. I thought of trying to take a var
> and set it top echo or write according to what is needed at that time.
> Here is my minitest.
> <?php
> echo "<P>The test is starting";
> $echowrite = "echo ";
> $echowrite."<P>This is the first line.";
> echo "<P>You should have seen the first line by now.";
?>>
> Did not work! Hey I'll try anything to get this to work! LOL
> Seriously, how can this be done?
I am not sure what you problem is here. I think that you are trying to put
a page break into HTML. If so them have a look at
http://slackerhtml.tripod.com/stylesheets/pagebreaks.html
However this is for CSS2 comparable browsers IE4 and above, I have not
tested it with other browsers.
--
BFN, _______________________________________________
David | David Elliott | Software Engineer |
_________________________| [EMAIL PROTECTED] | PGP Key ID 0x650F4534 |
| Guns don't kill people off-line readers do. |
pgpoBJWIcaTkM.pgp
Description: PGP signature
--- End Message ---
--- Begin Message ---
*Warning* I don't really suggest that you use eval() unless absolutely
necessary. But in this case it does what I *think* you want it to do.
http://www.php.net/manual/en/function.eval.php
Luis Moreira wrote:
What do you mean by "it doesn't work" ?
It does (the minitest, I mean).
Luis
MikeA wrote:
I have a PHP file that outputs HTML to the Internet to a user. The
user also wants to be able to
print that output to a printer. The user wants it formatted with page
breaks in the proper place
and so on. Using one PHP script to do both, short of a line to
display and a line to print, is
there a way to do this easily or am I in a pond of alligators? Most
of the output is using an echo
statement. I thought of trying to take a var and set it top echo or
write according to what is
needed at that time. Here is my minitest.
<?php
echo "<P>The test is starting";
$echowrite = "echo ";
$echowrite."<P>This is the first line.";
eval ($echowrite);
echo "<P>You should have seen the first line by now.";
?>
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
--- End Message ---
--- Begin Message ---
On Wed, 12 Jan 2005 20:46:46 -0500
"MikeA" <[EMAIL PROTECTED]> wrote:
> I have a PHP file that outputs HTML to the Internet to a user. The
> user also wants to be able to print that output to a printer. The
> user wants it formatted with page breaks in the proper place and so
> on. Using one PHP script to do both, short of a line to display and a
> line to print, is there a way to do this easily or am I in a pond of
> alligators? Most of the output is using an echo statement. I thought
> of trying to take a var and set it top echo or write according to what
> is needed at that time. Here is my minitest.
>
> <?php
> echo "<P>The test is starting";
>
This line sends an incomplete paragraph as part of the HTML
> $echowrite = "echo ";
>
The variable $echowrite now contains "echo "
> $echowrite."<P>This is the first line.";
>
The variable $echowrite now contains "echo <P>This is the first line"
> echo "<P>You should have seen the first line by now.";
>
This line sends another incomplete paragraph as part of the HTML
> ?>
>
> Did not work! Hey I'll try anything to get this to work! LOL
>
How did you want it to work?
> Seriously, how can this be done?
>
How can what be done? My best guess is you want to echo the variable as
part of the HTML page:
echo $echowrite;
> Thanks.
>
> Mike
>
You need to be more specific about what does happen, and what you want
to happen.
You appear to be just starting out in both HTML and PHP. I suggest
following a few online tutorials at W3C schools.
HTH
Regards
Michael
--- End Message ---
--- Begin Message ---
I might be an idiot...
I am trying to do a simple check to make sure a string contains at least
an alphanumeric character before I print the string. How can I do this?
Ron
--- End Message ---
--- Begin Message ---
Hello Ron,
Thursday, January 13, 2005, 8:17:51 AM, you wrote:
R> I am trying to do a simple check to make sure a string contains at
R> least an alphanumeric character before I print the string. How can
R> I do this?
if (preg_match("/[a-zA-Z0-9]+/"),$str) {
echo $str;
}
There may be a more efficient means, but this will work.
Basically if there are any lowercase, and/or uppercase, and/or
numbers, it'll echo $str.
The '+' means one or more times.
You could write it like this too:
if (preg_match("/[a-z0-9]+/i"),$str)
Which is a bit shorter. The 'i' means case insensitive so you can get
rid of the A-Z part (or vice-versa a-z).
Another possibility is:
if (preg_match("/[\w]+/"),$str)
which is shorter still.
'\w' means letters and numbers, but also the underscore character, so
it may not be what you want.
Hope it helps.
--
Leif (TB lists moderator and fellow end user).
Using The Bat! 3.0.2.3 Rush under Windows XP 5.1
Build 2600 Service Pack 2 on a Pentium 4 2GHz with 512MB
--- End Message ---
--- Begin Message ---
couldn't you use
is_string ( mixed var )
aaron
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: January 13, 2005 10:18
> To: [email protected]
> Subject: [PHP-WIN] Reg Ex help
>
>
>
> I might be an idiot...
>
> I am trying to do a simple check to make sure a string
> contains at least
> an alphanumeric character before I print the string. How can
> I do this?
>
> Ron
>
>
>
>
>
>
--- End Message ---
--- Begin Message ---
No, you aren't na idiot. You just don't how to do it, nobody knows
everything.
I think you can use strlen(); it returns an integer with the lenght of the
variable (0 if it's blank).
Don't worry, I learned this function some weeks ago...
Happy new year, bye bye.
-----Mensagem original-----
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Enviada em: quinta-feira, 13 de janeiro de 2005 13:18
Para: [email protected]
Assunto: [PHP-WIN] Reg Ex help
I might be an idiot...
I am trying to do a simple check to make sure a string contains
at least an alphanumeric character before I print the string.
How can I do this?
Ron
--- End Message ---
--- Begin Message ---
>if (preg_match("/[a-z0-9]+/i"),$str)
So what denotes the end of the reg ex here? (if the '/' at the begin
identifies the start?
Tryst
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
if (preg_match("/[a-z0-9]+/i"),$str)
So what denotes the end of the reg ex here? (if the '/' at the begin
identifies the start?
Tryst
Surely there is a manual page somewhere for "Perl Compatible Regular
Expressions" :)
Hint: actually, never mind, it's worth making you go read that page.
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
--- End Message ---
--- Begin Message ---
Aaron,
is_string() will return true even if there are no alphanumeric characters in
the variable, even if the variable is empty. My best guess is that is_string()
will not work in this case.
Randy Clamons
Systems Programming
Astro-auction.com
> ------------Original Message------------
> From: "Wagner, Aaron" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED], [email protected]
> Date: Thu, Jan-13-2005 1:31 PM
> Subject: RE: [PHP-WIN] Reg Ex help
>
> couldn't you use
>
> is_string ( mixed var )
>
> aaron
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]
> > Sent: January 13, 2005 10:18
> > To: [email protected]
> > Subject: [PHP-WIN] Reg Ex help
> >
> >
> >
> > I might be an idiot...
> >
> > I am trying to do a simple check to make sure a string
> > contains at least
> > an alphanumeric character before I print the string. How can
> > I do this?
> >
> > Ron
--- End Message ---
--- Begin Message ---
Hi guys
I know PHP doesn't support application variables. Anybody have a good
workaround for this?
Cheers
Louis
--- End Message ---
--- Begin Message ---
Louis Young wrote:
Hi guys
I know PHP doesn't support application variables. Anybody have a good
workaround for this?
Cheers
Louis
There is a PEAR package for this. Offhand I can't remember the name of
it... but look and ye shall find.
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
--- End Message ---
--- Begin Message ---
Hi
I have a header which I just include every time from all my pages, but
the headers caption needs to change according to the page which has been
loaded. I've tried global variables, but as soon as I jump into a
different session they seem to lose their values. So, what I did was
created a table in the database with two fields pagename and header.
Pagename is the name of the page and header is the header which I want
to display, then I can send the page name as a parameter to a query to
get the header.
The only problem now is the header doesn't know what the name of the
page is that is loading underneath it. At first I thought I could use
HTTP_REFERER, but this would only be true if the page is the loader of
the header, which is not always the case.
Any help will be appreciated.
Cheers
Louis
--- End Message ---
--- Begin Message ---
$PHP_SELF is the name of the current page.
-Dave
At 11:11 AM 1/13/2005, Louis Young wrote:
Hi
I have a header which I just include every time from all my pages, but the
headers caption needs to change according to the page which has been
loaded. I've tried global variables, but as soon as I jump into a
different session they seem to lose their values. So, what I did was
created a table in the database with two fields pagename and header.
Pagename is the name of the page and header is the header which I want to
display, then I can send the page name as a parameter to a query to get
the header.
The only problem now is the header doesn't know what the name of the page
is that is loading underneath it. At first I thought I could use
HTTP_REFERER, but this would only be true if the page is the loader of the
header, which is not always the case.
Any help will be appreciated.
Cheers
Louis
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Louis,
Try using $_SERVER['REQUEST_URI']. That will tell you the name of the page
requested.
Randy Clamons
Systems Programming
Astro-auction.com
> ------------Original Message------------
> From: Louis Young <[EMAIL PROTECTED]>
> To: [email protected], [EMAIL PROTECTED]
> Date: Thu, Jan-13-2005 11:44 AM
> Subject: [PHP-WIN] This is a tricky one
>
> Hi
>
> I have a header which I just include every time from all my pages, but
> the headers caption needs to change according to the page which has
> been
> loaded. I've tried global variables, but as soon as I jump into a
> different session they seem to lose their values. So, what I did was
> created a table in the database with two fields pagename and header.
> Pagename is the name of the page and header is the header which I want
> to display, then I can send the page name as a parameter to a query to
> get the header.
>
> The only problem now is the header doesn't know what the name of the
> page is that is loading underneath it. At first I thought I could use
> HTTP_REFERER, but this would only be true if the page is the loader of
> the header, which is not always the case.
>
> Any help will be appreciated.
>
> Cheers
> Louis
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
How i can include in a HTML (with .php extension) file another HTML file, i
mean not all teh page but only the element of the <BODY> tag?
I would to include with the
include (nomefile);
the body of other page
There are some php function or some other way to do this?
_________________________________
Gaetano Savoca
http://gsweb.altervista.org
--- End Message ---
--- Begin Message ---
On Friday, January 14, 2005 1:06 AM [GMT+1=CET],
Gaetano Savoca <[EMAIL PROTECTED]> ha scritto:
So i must do all manually
i write this
<?php
if(file_exists($corpo)){// controll for the file
//Creating the filehandle for our input file
$fh=fopen("$corpo", "r");
//Seeding the while loop below with the first line of the
input file
$line=fgets($fh);
while (!feof($fh)){
//Once we hit the <BODY> tag, start echoing out lines
until we hit </BODY>
if (preg_match("/<BODY/i", $line)){
while (!preg_match("/<\/BODY/i", $line =
fgets($fh))) echo $line;
}
$line = fgets($fh);
}
fclose ($fh);
}
where $corpo is a variable for the name of the file.
if the file not existe the page have a blank body
Thanks
_________________________________
Gaetano Savoca
http://gsweb.altervista.org
On Thursday, January 13, 2005 11:16 PM [GMT+1=CET],
Leif Gregory <[EMAIL PROTECTED]> ha scritto:
Hello Gaetano,
Thursday, January 13, 2005, 11:56:41 AM, you wrote:
How i can include in a HTML (with .php extension) file another HTML
file, i mean not all teh page but only the element of the <BODY>
tag?
I would to include with the include (nomefile); the body of other
page
There are some php function or some other way to do this?
Uhmmm.. Lesse. I did something similar to this when I wrote some code
to give me the headers from webservers. I had to use regexps to do
it.
Basically you could do something like this:
<?php
//Creating the filehandle for our input file
$fh=fopen("myIncludeFile.html", "r");
//Seeding the while loop below with the first line of the input file
$line=fgets($fh);
while (!feof($fh))
{
$line = fgets($fh);
//Once we hit the <BODY> tag, start echoing out lines until we hit
</BODY> if (preg_match("/<BODY/i", $line))
{
while (!preg_match("/<\/BODY/i", $line))
{
echo $line;
$line = fgets($fh);
}
}
else
{
$line = fgets($fh);
}
}
fclose ($fh);
I didn't actually test this, but it should work. I just took some
odds and ends pieces from something else I wrote that was similar.
There's room for improvement. Like right now it'll continue
processing the outer while loop after the </BODY> but since </HTML>
usually follows on the next line I didn't think it too inefficient.
You could make the outer while stop by ANDing with the condition of
the inner while loop.
As always... There's going to be other ways to do this. Some of them
are probably a heck of a lot better than mine.
--- End Message ---
--- Begin Message ---
Are you using the same SAPI and context on both maschines?
The mssql extension can give different results depending on the context
the driver is used in (OEM to ansi convertion). If your data is stored in
a binary column (not a text column) it should not matter though.
- Frank
> Hi,
> I've strange problem with a blob field in a mssql db containing a ms
> word document:
>
> <?php
> $conn = mssql_connect('hostname','xxxxx','yyyyy');
> mssql_select_db ('docs');
> $i_result=mssql_query('Select * from documenti_file where
> file_esercizio_doc = 2004 and file_id_doc = 200');
> $ar_row = mssql_fetch_array ( $i_result);
> echo $ar_row[7];
> $file = fopen('test.doc','wb');
> fwrite($file,$ar_row[7]);
> fclose($file);
> mssql_free_result($i_result);
> echo "<br>". strlen($ar_row[7]);
> ?>
> works ok using my box as server (apache 1.3.29 and php 4.3.4 - win xp)
> and I can read the written file with ms-word; now the strange thing:
> running same script on another server (apache 1.3.28 and php 4.3.4 win
> nt) I got the same result on the screen (echo), but the file written is
> corrupt and it shows weird things when opened with ms-word. It seems
> like data got corrupted in the write() task. File size is exactely the
> same. Database used is the same and resides on a third box. I've the
> same mssql client dll on the two boxes (ntwdblib.dll ver.
2000.80.194.0)
> Any idea ?
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
It's true that googling would produce a list of PHP-happy editors, but the
intended question seems to be more along the lines of "What does everyone like?
Use? Prefer?" That's not something that's always found on lists you'd get
off of google.
Helpful responses aren't always ones that are technically correct.
-TG
= = = Original message = = =
"Know any goog ones?"
funny you should mention goog.. if you google'd "php editor" youd have
your answer by now..
cheers
phpninja
-----Original Message-----
From: William Stokes [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 13, 2005 8:02 AM
To: [email protected]
Subject: [PHP] php editor
Hello,
I'm quite new with writing php code. I was considering of using some kind of
php editor program to help with the syntax. Know any goog ones?
Thanks
-Will
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
I use Wordpad. Seriously ;)
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
--- End Message ---
--- Begin Message ---
Windows Wordpad again tho i have found Homesite 5 is good color coded an u
can see the line numbers if that is any help to u.
Nothing beats raw code html or php Notepad is the best ever yeah
Dean "The Insane Guy" Hayes
<-- I design and i redesign but still i never designed true beauty like you
-->
~~~ Call me Insane call me Crazy but there is one thing i know i am That is
someone that shall reach peoples hearts with words ~~~
~~ PHP seems easy enough but what about this ASP now that looks hard ~~
From: Jason Barnett <[EMAIL PROTECTED]>
To: [email protected]
Subject: [PHP-WIN] Re: [PHP] php editor
Date: Thu, 13 Jan 2005 17:06:55 -0500
I use Wordpad. Seriously ;)
--
Teach a person to fish...
Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://www.php.net/manual/en/index.php
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---