[PHP] Re: Newbie Question about Conditionals

2010-03-31 Thread Shawn McKenzie
Matty Sarro wrote:
 Hey all!
 This is probably my second post on the list, so please be gentle. Right now
 I am running through the Heads First PHP and MySQL book from O'Reilly.
 It's been quite enjoyable so far, but I have some questions about some of
 the code they're using in one of the chapters.
 
 Basically the code is retreiving rows from a DB, and I'm just not getting
 the explanation of how it works.
 
 Here's the code:
 
 $result=mysqli_query($dbc,$query)
 
 while($row=mysqli_fetch_array($result)){
 echo $row['first_name'].' '.$row['last_name'].' : '. $row['email'] . 'br
 /';
 }
 
 Now, I know what it does, but I don't understand how the conditional
 statement in the while loop works. Isn't an assignment operation always
 going to result in a true condition? Even if mysqli_fetch_array($result)
 returned empty values (or null) wouldn't the actual assignment to $row still
 be considered a true statement? I would have sworn that assignment
 operations ALWAYS equated to true if used in conditional operations.
 Please help explain! :)
 
 Thanks so much!
 -Matty
 

Others have explained in detail, but I will tell you why you and many
beginners may have been confused by this.  On this list as well as in
other help sites for PHP, beginners post code that contains something
like this, and wonder why it always echoes TRUE:

$value = 'bob';

if($value = 'test') {
echo 'TRUE';
} else {
echo 'FALSE';
}

They normally get an answer such as:  You need to use == for
comparison, = is an assignment operator and the assignment will always
evaluate to true.  Well, this is true for this assignment because the
non-empty string 'test' evaluates to true.  But without explanation it
may sound as though ANY assignment will evaluate to true just because
the actual assignment itself was successful. This is obviously not the
case. This echoes FALSE:

$value = 'bob';

if($value = '') {
echo 'TRUE';
} else {
echo 'FALSE';
}


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

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



[PHP] Re: newbie question - php parsing

2009-07-23 Thread Peter Ford
João Cândido de Souza Neto wrote:
 You made a mistake in your code:
 
 ?php the_title(); ?
 
 must be:
 
 ?php echo the_title(); ?
 

Not necessarily: what if you have

function the_title()
{
echo Title;
}

for example...


In response to Sebastiano:

There would be not much point in using something like PHP if it ignored the if
statements in the code!
What effectively happens in a PHP source file is that all the bits outside of
the ?php ? tags are treated like an echo statement (except that it handles
quotes and stuff nicely)

Your original code:

?php if (the_title('','',FALSE) != 'Home') { ?
h2 class=entry-header?php the_title(); ?/h2
?php } ?

can be read like:

?php
if (the_title('','',FALSE) != 'Home') {
echo 'h2 class=entry-header';
the_title();
echo '/h2';
}
?

You might even find a small (but probably really, really, really small)
performance improvement if you wrote it that way, especially if it was in some
kind of loop.
Note that I prefer to keep HTML separate from PHP as much as possible because it
helps me to read it and helps my editor check my syntax and HTML structure 
better...


-- 
Peter Ford  phone: 01580 89
Developer   fax:   01580 893399
Justcroft International Ltd., Staplehurst, Kent

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



Re: [PHP] Re: newbie question - php parsing

2009-07-23 Thread Sebastiano Pomata
Thanks, it's now much more clear. I thought that html parts outside
php tags were just dumped to output, no matter of if-else statements
and other conditions. I was *definitely* wrong

2009/7/23 Peter Ford p...@justcroft.com:

 In response to Sebastiano:

 There would be not much point in using something like PHP if it ignored the 
 if
 statements in the code!
 What effectively happens in a PHP source file is that all the bits outside of
 the ?php ? tags are treated like an echo statement (except that it handles
 quotes and stuff nicely)

 Your original code:

 ?php if (the_title('','',FALSE) != 'Home') { ?
 h2 class=entry-header?php the_title(); ?/h2
 ?php } ?

 can be read like:

 ?php
 if (the_title('','',FALSE) != 'Home') {
    echo 'h2 class=entry-header';
    the_title();
    echo '/h2';
 }
 ?

 You might even find a small (but probably really, really, really small)
 performance improvement if you wrote it that way, especially if it was in some
 kind of loop.
 Note that I prefer to keep HTML separate from PHP as much as possible because 
 it
 helps me to read it and helps my editor check my syntax and HTML structure 
 better...


 --
 Peter Ford                              phone: 01580 89
 Developer                               fax:   01580 893399
 Justcroft International Ltd., Staplehurst, Kent

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



[PHP] Re: newbie question - php parsing

2009-07-22 Thread Jo�o C�ndido de Souza Neto
You made a mistake in your code:

?php the_title(); ?

must be:

?php echo the_title(); ?

-- 
João Cândido de Souza Neto
SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
Fone: (0XX41) 3033-3636 - JS
www.siens.com.br

Sebastiano Pomata lafayett...@gmail.com escreveu na mensagem 
news:70fe20d60907221355m3fa49a75ua053d2f1b9aca...@mail.gmail.com...
 Hi all,

 A little doubt caught me while I was writing this snippet of code for
 a wordpress template:

 ?php if (the_title('','',FALSE) != 'Home') { ?
 h2 class=entry-header?php the_title(); ?/h2
 ?php } ?

 I always thought that php was called only between the ?php ? tags,
 and I'm pretty sure that's right, while HTML code was simply wrote in
 document as is, without further logic.
 Now, I can't figure out how this snippet works: I mean, shouldn't HTML
 code be simply put on document, as it is outside php invoke?
 Effectively if the title of page is 'Home', the HTML part is totally
 skipped.

 Is the if construct that does all the magic inside? 



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



Re: [PHP] Re: newbie question - php parsing

2009-07-22 Thread Shane Hill
2009/7/22 João Cândido de Souza Neto j...@consultorweb.cnt.br

 You made a mistake in your code:

 ?php the_title(); ?

 must be:

 ?php echo the_title(); ?


?= the_title(); ?

also works.

-Shane





 --
 João Cândido de Souza Neto
 SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
 Fone: (0XX41) 3033-3636 - JS
 www.siens.com.br

 Sebastiano Pomata lafayett...@gmail.com escreveu na mensagem
 news:70fe20d60907221355m3fa49a75ua053d2f1b9aca...@mail.gmail.com...
  Hi all,
 
  A little doubt caught me while I was writing this snippet of code for
  a wordpress template:
 
  ?php if (the_title('','',FALSE) != 'Home') { ?
  h2 class=entry-header?php the_title(); ?/h2
  ?php } ?
 
  I always thought that php was called only between the ?php ? tags,
  and I'm pretty sure that's right, while HTML code was simply wrote in
  document as is, without further logic.
  Now, I can't figure out how this snippet works: I mean, shouldn't HTML
  code be simply put on document, as it is outside php invoke?
  Effectively if the title of page is 'Home', the HTML part is totally
  skipped.
 
  Is the if construct that does all the magic inside?



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




Re: [PHP] Re: newbie question - php parsing

2009-07-22 Thread Lenin
Ted Turner http://www.brainyquote.com/quotes/authors/t/ted_turner.html  -
Sports is like a war without the killing.

2009/7/23 Shane Hill shanehil...@gmail.com

 2009/7/22 João Cândido de Souza Neto j...@consultorweb.cnt.br

  You made a mistake in your code:
 
  ?php the_title(); ?
 
  must be:
 
  ?php echo the_title(); ?


 ?= the_title(); ?


Short tag and not recommended as its deprecated now, would be void at PHP
6.0


Re: [PHP] Re: newbie question - php parsing

2009-07-22 Thread Martin Scotta
This is how I'd write this snippet

?php
if ( 'Home' !== ( $title = the_title('','',FALSE)))
{
echo 'h2 class=entry-header',
$title,
'/h2';
}
?

On Wed, Jul 22, 2009 at 6:31 PM, Lenin le...@phpxperts.net wrote:

 Ted Turner http://www.brainyquote.com/quotes/authors/t/ted_turner.html
  -
 Sports is like a war without the killing.

 2009/7/23 Shane Hill shanehil...@gmail.com

  2009/7/22 João Cândido de Souza Neto j...@consultorweb.cnt.br
 
   You made a mistake in your code:
  
   ?php the_title(); ?
  
   must be:
  
   ?php echo the_title(); ?
 
 
  ?= the_title(); ?


 Short tag and not recommended as its deprecated now, would be void at PHP
 6.0




-- 
Martin Scotta


[PHP] Re: newbie question - php parsing

2009-07-22 Thread Shawn McKenzie
João Cândido de Souza Neto wrote:
 You made a mistake in your code:
 
 ?php the_title(); ?
 
 must be:
 
 ?php echo the_title(); ?
 

I haven't used worpress in a long time, but the the_title() function
might echo the title unless you pass the FALSE parameter, in which case
it just returns it.

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

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



[PHP] Re: Newbie Question - Form To Email Needed

2007-05-05 Thread itoctopus
1st page:

form
textarea name='thebody'/texarea
/form

2nd page:

$str_body = $_POST['thebody'];
mail('[EMAIL PROTECTED]', 'This is the 
subject', $str_body);

Of course you can have the email and the subject fields come also from the 
1st page.

Hope that helps!

-- 
itoctopus - http://www.itoctopus.com
revDAVE [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi folks,

 I have a form on page one - and would like to submit to a second page in 
 PHP
 that could grab the fields and send it out as an e-mail.

 Are there any links that show how do this?


 Thanks in advance - Dave


 --
 Thanks - RevDave
 [EMAIL PROTECTED]
 [db-lists] 

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



Re: [PHP] Re: newbie question about storing big5 codes into mysql-5.0.24a

2007-03-25 Thread Stut
Man-wai Chang wrote:
 create table temp ( big5 char(2) ) character set big5 collate big5_bin;
 insert into temp ( big5 ) values ( 0x9f54 );
 insert into temp ( big5 ) values ( 0x9f53 );
 The 2nd query will report duplicated key. How should I fix the problem?
 What does this has to do with PHP?
 First of all I don't see any PHP code, and second this is an error in
 your SQL query, so you should be on the MySQL list.
 
 I used mysqli_query() to send the SQL. How could I make it work?

That really doesn't make this question PHP-related. You really do need
to ask on a MySQL mailing list. This has nothing to do with PHP, and
you're more likely to get a useful answer from a MySQL-specific list.

If you really want to try and justify asking this question here, try the
queries in the command-line MySQL client. If it works there but not
through mysqli_query() then you might have a case for asking here.

-Stut

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



[PHP] Re: newbie question about storing big5 codes into mysql-5.0.24a

2007-03-25 Thread Man-wai Chang
 queries in the command-line MySQL client. If it works there but not
 through mysqli_query() then you might have a case for asking here.

For the 13081 chinese alphabets I tried, only 1 one failed, and it's
0x9f54. mysqli_query() should have escaped the string for me. So ...

I suppose most PHP programmers are also experts in MySQL (they are
basically tied). SO I tried my luck here. :)

-- 
  .~.   Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
 / v \  Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10)  Linux 2.6.20.4
  ^ ^   21:24:01 up 1 day 8:36 0 users load average: 1.00 1.02 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

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



Re: [PHP] Re: newbie question about storing big5 codes into mysql-5.0.24a

2007-03-25 Thread Jochem Maas
Man-wai Chang wrote:
 queries in the command-line MySQL client. If it works there but not
 through mysqli_query() then you might have a case for asking here.
 
 For the 13081 chinese alphabets I tried, only 1 one failed, and it's
 0x9f54. mysqli_query() should have escaped the string for me.

mysqli_query() doesn't escape anything for you - your assumption that
it *should* is WRONG.

try this: http://php.net/manual/en/function.mysqli-real-escape-string.php

 So ...
 
 I suppose most PHP programmers are also experts in MySQL (they are
 basically tied). 

incorrect supposition. most php programmers have experience using
RDBMs because of the dynamic nature of the websystems they build.

mysql and php and not tied at all .. they just happen to be used together
frequently.

 SO I tried my luck here. :)
 

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



[PHP] Re: newbie question about storing big5 codes into mysql-5.0.24a

2007-03-24 Thread Man-wai Chang
 create table temp ( big5 char(2) ) character set big5 collate big5_bin;
 insert into temp ( big5 ) values ( 0x9f54 );
 insert into temp ( big5 ) values ( 0x9f53 );
 The 2nd query will report duplicated key. How should I fix the problem?
 What does this has to do with PHP?
 First of all I don't see any PHP code, and second this is an error in
 your SQL query, so you should be on the MySQL list.

I used mysqli_query() to send the SQL. How could I make it work?

-- 
  .~.   Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
 / v \  Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.10)  Linux 2.6.20.4
  ^ ^   14:43:01 up 1 day 1:55 0 users load average: 1.01 1.02 1.00
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

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



[PHP] Re: newbie question

2007-03-21 Thread itoctopus
Means you're passing the variable as reference.
This means that any change in the variable inside your function will affect
the variable outside your function, in other terms:

if you have

function myfunc($var){
$var = 5;
}

$a = 6;
myfunc($a);

will result in having $a=5 after the function all.

--
itoctopus - http://www.itoctopus.com
bob pilly [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi all

 Can anyone tell me what '' means before a var?

 e.g function($var)

 Thanks for any help in advance





 ___
 What kind of emailer are you? Find out today - get a free analysis of your
email personality. Take the quiz at the Yahoo! Mail Championship.
 http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread Jon Anderson

Satyam wrote:

for ($x=0;$x1000;$x++) {
   echo ' trtdX is ' , $x , '/td/tr';
}
This seems to be a hair faster. I extended the test to 1 requests 
(still concurrency 10) to make the test a little more reproducible:


echo str,var,str did 604.65 requests a second where trtd?= $x 
?/td/tr did 599.63 requests a second. I also tried echo str . var . 
str, and it came in at about 584.55 requests a second.  printf(str %i 
str,var) came out at 547.01 requests a second and printf(str %s 
str,var) was only 452.03 requests a second.
Can you try and time that one so we have comparable results?  This one 
should be second best:


for ($x=0;$x1000;$x++) {
   echo trtdX is $x/td/tr;
}

Approximately 330 (?!) requests a second for that one.
Back again to what would be 'longer', well, in your example, the whole 
header, up to the loop itself should be faster if sent out of PHP. 
Likewise, you could echo $buffer right after the loop, drop out of PHP 
and send the footer as plain HTML.  This, of course, is harder to time 
since it happens only once.  I admit though that I did time the 
options I listed and on the 'dropping in and out of PHP' I'm relying 
on the PHP manual ( see 
http://www.php.net/manual/en/language.basic-syntax.php, the first 
paragraph after the examples) and the source of the lexical scanner, 
which supports that, though your numbers do contradict it.  Interesting. 
I'm not sure that my results would count as contradictory - I'm running 
APC which would likely throw performance related numbers out of whack as 
compared to out-of-the-box PHP.


Because of that, I wouldn't recommend anyone take my numbers too 
seriously - they're just an example taken from my server: 1.8 GHz 
SMP/1G/RAID5/Linux 2.6.17.7/Apache 2.2.3/PHP 5.1.6/APC 3.0.12p2. Anyone 
else's results would probably vary widely.


jon

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread Stut

How bored am I?

This bored: http://dev.stut.net/phpspeed/

Server is running PHP 5.1.2 (really should upgrade that) with no caches 
of any sort.


-Stut

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread tedd

At 4:56 PM +0100 9/11/06, Stut wrote:

How bored am I?

This bored: http://dev.stut.net/phpspeed/

Server is running PHP 5.1.2 (really should upgrade that) with no 
caches of any sort.


-Stut


Which begs the question, does it make much of a difference? (not you 
being bored, but the rather speed concers).


With all the things out there that can slow your browsers reaction 
time in presenting some result, does a couple of seconds count much 
in the over all scheme of things?


I know, purest will say that they want to make whatever they do as 
fast as possible, but is that time to make it faster be better spent 
elsewhere? We used to have to worry about the size of our strings, 
but now we can place the kjv of the bible in one. So, what's the 
point of counting characters in strings now?


I suspect at some point, probably soon, speed isn't going to matter much.

Opinions?

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread Satyam
I admit I'm totally surprised about the buffered results.  Nevertheless, may 
I sugest you add the following to the series of tests?:


   h3Using line-by-line single-quoted echobr/with comma separated 
arguments/h3

?php
   $start = mt();
   print 'table style=display:none; id=table2a';
   for ($x = 0; $x  $iterations; $x++)
   {
   echo 'trtdX is/tdtd',$x,'/td/tr';
   }
   print '/table';

   $duration = mt() - $start;
   print 'pTook '.number_format($duration, 4).' seconds/p';
?
   praquo; a id=table2alink
   href=# 
onclick=document.getElementById('table2a').style.display='block';
   document.getElementById('table2alink').style.display='none';return 
false;

   Reveal output/a/p

There seems to be one thing rarely anybody remembers, echo admits multiple 
arguments, and as the numbers will show, (or at least they do in my 
machine), they are the second best option.


Satyam


- Original Message - 
From: Stut [EMAIL PROTECTED]

To: Jon Anderson [EMAIL PROTECTED]
Cc: Satyam [EMAIL PROTECTED]; php-general@lists.php.net
Sent: Monday, September 11, 2006 5:56 PM
Subject: Re: [PHP] Re: Newbie question about ?= ?



How bored am I?

This bored: http://dev.stut.net/phpspeed/

Server is running PHP 5.1.2 (really should upgrade that) with no caches of 
any sort.


-Stut

--
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] Re: Newbie question about ?= ?

2006-09-11 Thread Stut

Satyam wrote:
I admit I'm totally surprised about the buffered results.  
Nevertheless, may I sugest you add the following to the series of tests?:


   h3Using line-by-line single-quoted echobr/with comma 
separated arguments/h3

snip

There seems to be one thing rarely anybody remembers, echo admits 
multiple arguments, and as the numbers will show, (or at least they do 
in my machine), they are the second best option.


Done, but again it doesn't seem to make any significant difference to 
the performance.


-Stut

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread Stut

tedd wrote:

At 4:56 PM +0100 9/11/06, Stut wrote:

How bored am I?

This bored: http://dev.stut.net/phpspeed/

Server is running PHP 5.1.2 (really should upgrade that) with no 
caches of any sort.


-Stut


Which begs the question, does it make much of a difference? (not you 
being bored, but the rather speed concers).


With all the things out there that can slow your browsers reaction 
time in presenting some result, does a couple of seconds count much in 
the over all scheme of things?


I know, purest will say that they want to make whatever they do as 
fast as possible, but is that time to make it faster be better spent 
elsewhere? We used to have to worry about the size of our strings, but 
now we can place the kjv of the bible in one. So, what's the point of 
counting characters in strings now?


I suspect at some point, probably soon, speed isn't going to matter much.

Opinions?


I would have to agree. Having watched the server CPU load while playing 
with this test script it would  appear that the performance can be 
skewed a lot more by that than by the method you use for squidging out 
the output.


As a curiosity I've also added a test using ?php print $x; ? and 
bizarrely that appears to be slightly faster than ?=$x?.


Weird.

-Stut

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread Stut

Jon Anderson wrote:

Stut wrote:

How bored am I?

This bored: http://dev.stut.net/phpspeed/

Server is running PHP 5.1.2 (really should upgrade that) with no 
caches of any sort. 
Just looking through the source, could you try changing the first 
example to put the output all on one line? It's the only one that does 
the row output on multiple indented lines - I'm kind of curious what 
effect (if any) that has on the results.


Done. Doesn't seem to make a difference - I didn't expect it to.

I also tried this on my own server. With the opcode cache, the results 
seem to be the inverse of yours without.


I would have been surprised if an opcode cache had made a huge 
difference. I don't think the Zend Engine is intelligent enough to 
compile the various different tests to the same set of opcodes - but I 
could be wrong. I'm still quite new to the PHP internals.


Also, with either server, the first three results seem to vary wildly, 
but the last two always seem to come out the same. I'm not sure why 
that is...


As I said in another post, the performance varies wildly with the load 
on the server.


-Stut

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread Satyam
- Original Message - 
From: Stut [EMAIL PROTECTED]

To: Satyam [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Sent: Monday, September 11, 2006 6:32 PM
Subject: Re: [PHP] Re: Newbie question about ?= ?



Satyam wrote:

I admit I'm totally surprised about the buffered results.  Nevertheless,
may I sugest you add the following to the series of tests?:

   h3Using line-by-line single-quoted echobr/with comma separated
arguments/h3
snip

There seems to be one thing rarely anybody remembers, echo admits
multiple arguments, and as the numbers will show, (or at least they do in
my machine), they are the second best option.


Done, but again it doesn't seem to make any significant difference to the
performance.

-Stut




When I run those tests locally, the numbers are totally different and the
performance of one over the other comes out far clearer.  I can only assume
that the numbers in the test run  in a remote server are so much influenced
by the ability of the server to push out the characters into the output
stream that the processing time itself is of very little relevance.  This
table shows the numbers for the different tests as run on my machine,
locally (where output streaming is irrelevant) and run from your site:

Using ?=$x?Took 0.2801 secondsTook
3.5937 seconds

Using ?php print $x; ?Took 0.3286 secondsTook 5.2654 seconds

Using line-by-line single-quoted print:Took 0.1215 secondsTook
3.2256 seconds

Using line-by-line single-quoted echo
with comma separated argumentsTook 0.2542 secondsTook 3.2220
seconds

Using line-by-line double-quoted print Took 0.1782 secondsTook
3.3129 seconds

Using buffered single-quoted printTook 0.0277 secondsTook 3.3077
seconds

Using buffered double-quoted printTook 0.2038 seconds Took 3.3012
seconds

It would seem that it takes about 3 seconds to push those bytes into the
network, the actual processing times get completely masked behind a simple
glitch in the throughput of the communication line.  While the differences
on the rightmost column (except for the second one, which is way off) are no
more than 5%, in the middle column the differences are up to 10 to 1.  But
then there is that second row, which is so much higher and it is so in both
columns.

Unfortunately, I cannot make much sense about all this.  I don't get it.
Nevertheless, something it is clear is that buffering all the output first
and then pushing it out all at once seems to beat them all, specially using
single quoted strings.  Run locally, the differences are amazing!

Satyam

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-11 Thread tedd

At 5:36 PM +0100 9/11/06, Stut wrote:

tedd wrote:

Opinions?


I would have to agree. Having watched the server CPU load while 
playing with this test script it would  appear that the performance 
can be skewed a lot more by that than by the method you use for 
squidging out the output.


As a curiosity I've also added a test using ?php print $x; ? and 
bizarrely that appears to be slightly faster than ?=$x?.


Weird.


My guess would be that it's in the interpreter -- the look-up for 
? as compared to ?php may be delayed because of checking for 
the short-tag option-on, or something similar. But, I admittedly 
don't know.


However, I strongly suspect that drawing to the screen will take 
longer than executing any = or print statement anyway. So 
regardless of the time saved in computation, the delivery would 
appear identical. It reminds me of the hurry-up and wait saying we 
had in the Army some 50 years back.


tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Re: Newbie question about ?= ?

2006-09-10 Thread Al

Mike Borrelli wrote:

Good day,

While I've been using php for more than a little while now, I've never
understood why the use of the ?= ...? short tag is noted to be
avoided.

Or rather, I understand that there's an option to disable it, and that's
why it's noted in this way, but I don't understand why it's disabled? 
What's gained by writing ?php echo some_function(); ? over ?=

some_function(); ?

Thanks in advance.

Cheers,
Mike
Structurally, there is a far better way to compile your html pages.  This approach is easier to design and debug and it 
is faster since it sends one complete packet instead of one for every short tag. And, it saves using ob_start() and 
ob_flush().


Consider:

$report= '';

$report .= function() [or whatever]

. repeat as necessary to assemble your complete page.

Then simply

echo $report;

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-10 Thread Satyam


- Original Message - 
From: Al [EMAIL PROTECTED]

To: php-general@lists.php.net
Sent: Sunday, September 10, 2006 5:52 PM
Subject: [PHP] Re: Newbie question about ?= ?



Mike Borrelli wrote:

Good day,

While I've been using php for more than a little while now, I've never
understood why the use of the ?= ...? short tag is noted to be
avoided.

Or rather, I understand that there's an option to disable it, and that's
why it's noted in this way, but I don't understand why it's disabled? 
What's gained by writing ?php echo some_function(); ? over ?=

some_function(); ?

Thanks in advance.

Cheers,
Mike
Structurally, there is a far better way to compile your html pages.  This 
approach is easier to design and debug and it is faster since it sends one 
complete packet instead of one for every short tag. And, it saves using 
ob_start() and ob_flush().


Consider:

$report= '';

$report .= function() [or whatever]

. repeat as necessary to assemble your complete page.

Then simply

echo $report;



Actually, in my experience, that is not the case, my e-mail from more than a 
year ago must be somewhere there in the archives, but what you sugest is not 
the fastest.


The fastest is to escape out of php (with a ? ) for the longer invariable 
parts of immutable HTML. Stepping out from PHP and in again is handled by 
the lexical scanner, it doesn't even reach the parser level so, for all 
effects, the PHP interpreter is basically frozen at the point before the ? 
was found. For the sake of completeness, the ? is translated as a ; for the 
parser so it ends any statement that could have been left open, but it does 
not bother the parser at all for all the rest of the characters found until 
a ?php tag (or equivalent) is found.  If the lexer didn't issue a ; for a 
?, the following code would be valid:


echo 'This ' , ? is ?php 'not valid';

For the variable parts, the best is to issue as little echos as possible 
with its arguments separated by commas, not with dots.  Most people don't 
realize that echo taks a list of arguments, a list separated by commas. 
Thus, in the ratings, from best to worst, it goes:


echo 'p' , $something, '/p';
echo p$something/p
echo 'p' . $something . '/p';
echo 'p'; echo $something; echo '/p';

The reason for this is that generating a single string either from variable 
interpolation as in the second case or by concatenating the arguments, as in 
the third,  requires a lot of memory handling for the strings and its 
intermediate and final results.  Some of it might be delayed until the page 
is served so the time the garbage collector takes to clean it up might not 
be fully reflected in the processing time of a single page, but it does 
affect the overall throughput of the server.  Notice also that I have used 
single quotes whenever possible, which is slightly faster since the parser 
has much less to look for within it.


Finally, the first option is the fastest just as a C++ iostream or a Java 
StringBuffer are faster than plain strings: since you know you will only 
append to the end of them, the characters echoed go into a much more 
efficient character buffer instead of a more complex string which has to be 
available for all sorts of string operations.


Satyam

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-10 Thread Jon Anderson

Al wrote:
Structurally, there is a far better way to compile your html pages.  
This approach is easier to design and debug and it is faster since it 
sends one complete packet instead of one for every short tag. And, it 
saves using ob_start() and ob_flush().


Consider:

$report= '';

$report .= function() [or whatever]

. repeat as necessary to assemble your complete page.

Then simply

echo $report;
I thought I'd look into this, because I'm a bit of a performance nut - I 
like  my code to run as fast as possible at all times. I wrote up a 
quick buffer v.s. direct benchmark for this, and the winner is clear: 
direct output is much faster. (If my example below isn't  what you 
meant, please let me know. I'm always happy to hear  new ways  to 
improve my code.)


Best of 3 runs with apache bench (concurrency 10, 1000 requests total):
Direct output: 582 requests a second
Buffer var: 286 requests a second

I believe the margin would get wider with real-world usage, as the 
buffer variable would increase in size. My test code is copied below.


jon

--- Direct output: testecho.php ---

html
head
style type=text/wastespacetosimulateastylesheet
style1 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style2 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style3 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style4 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
/style
/head
bodytable

?php for ($x=0;$x1000;$x++) { ?
   trtdX is ?= $x ?/td/tr
?php } ?

/table/body
/html

--- Buffered output: testbuffer.php ---

?php

$buffer = '
html
head
style type=text/wastespacetosimulateastylesheet
style1 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style2 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style3 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style4 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
/style
/head
bodytable';

for ($x=0;$x1000;$x++) {
   $buffer .= trtdX is $x/td/tr;
}

$buffer .= '/table/body
/html';

echo $buffer;
?

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



Re: [PHP] Re: Newbie question about ?= ?

2006-09-10 Thread Satyam


- Original Message - 
From: Jon Anderson [EMAIL PROTECTED]

To: php-general@lists.php.net
Cc: Al [EMAIL PROTECTED]
Sent: Sunday, September 10, 2006 9:16 PM
Subject: Re: [PHP] Re: Newbie question about ?= ?



Al wrote:
Structurally, there is a far better way to compile your html pages.  This 
approach is easier to design and debug and it is faster since it sends 
one complete packet instead of one for every short tag. And, it saves 
using ob_start() and ob_flush().


Consider:

$report= '';

$report .= function() [or whatever]

. repeat as necessary to assemble your complete page.

Then simply

echo $report;
I thought I'd look into this, because I'm a bit of a performance nut - I 
like  my code to run as fast as possible at all times. I wrote up a quick 
buffer v.s. direct benchmark for this, and the winner is clear: direct 
output is much faster. (If my example below isn't  what you meant, please 
let me know. I'm always happy to hear  new ways  to improve my code.)


Best of 3 runs with apache bench (concurrency 10, 1000 requests total):
Direct output: 582 requests a second
Buffer var: 286 requests a second

I believe the margin would get wider with real-world usage, as the buffer 
variable would increase in size. My test code is copied below.


jon

--- Direct output: testecho.php ---

html
head
style type=text/wastespacetosimulateastylesheet
style1 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style2 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style3 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style4 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
/style
/head
bodytable

?php for ($x=0;$x1000;$x++) { ?
   trtdX is ?= $x ?/td/tr
?php } ?

/table/body
/html

--- Buffered output: testbuffer.php ---

?php

$buffer = '
html
head
style type=text/wastespacetosimulateastylesheet
style1 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style2 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style3 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
style4 {
   a = 1;
   b = 2;
   c = 3;
   d = 4;
   e = 5;
   f = 6;
}
/style
/head
bodytable';

for ($x=0;$x1000;$x++) {
   $buffer .= trtdX is $x/td/tr;
}

$buffer .= '/table/body
/html';

echo $buffer;
?

--
In my message I was careful to mention that stepping in and out of PHP was 
good 'for the longer invariable  parts of immutable HTML'.  What could be 
considered 'longer' is certainly a matter discussion, your results prove 
that this is not long enough.  Notice that when the parser finds the '?=', 
it converts it into the equivalent of ? echo, thus, though the echo is 
not explicitly there, from the parser on is as if it were.   Then, since you 
have an echo, why not use it for all of the output?The equivalent to 
what I showed as the second best, which would be the first best with 
'shorter' strings would be the following:


for ($x=0;$x1000;$x++) {
   echo ' trtdX is ' , $x , '/td/tr';
}

Can you try and time that one so we have comparable results?  This one 
should be second best:


for ($x=0;$x1000;$x++) {
   echo trtdX is $x/td/tr;
}

Back again to what would be 'longer', well, in your example, the whole 
header, up to the loop itself should be faster if sent out of PHP. 
Likewise, you could echo $buffer right after the loop, drop out of PHP and 
send the footer as plain HTML.  This, of course, is harder to time since it 
happens only once.  I admit though that I did time the options I listed and 
on the 'dropping in and out of PHP' I'm relying on the PHP manual ( see 
http://www.php.net/manual/en/language.basic-syntax.php, the first paragraph 
after the examples) and the source of the lexical scanner, which supports 
that, though your numbers do contradict it.  Interesting.


Satyam

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



[PHP] Re: Newbie Question Can't insert values into MySQL DB via PHP

2006-02-10 Thread Barry

Duggles Temple wrote:

Hi,

I'd like to say in advance that I am sorry about the silly and very newbie
question I'm asking.

I am having a problem with a shop system. I can't add values into the MySQL
DB via a PHP statement. The values are being transferred from one page to
another (know that from the echo statement), but the SQL statement isn't
working.



What error do you get?



The statement is as follows:

$conn = mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect to
database');
$t = $_GET['newdvdtitle'];
$y = $_GET['newdvdyear'];
$c = $_GET['newdvdcost'];
$p = $_GET['newdvdpurchased'];
@mysql_select_db($DBName) or die(Unable to select database $DBName);
$sqladd = INSERT INTO 'dvd' ('id', 'title', 'year','cost','purchased')
VALUES (  NULL , '$t', '$y', '$c' , '$p' );
echo $sqladd;
$result = mysql_query($sqladd);


Insert Into dvd (title, year,cost,purchased)

When the id is auto_increment you dont have to add it to the query.
Barry


--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



RE: [PHP] Re: Newbie Question Can't insert values into MySQL DB via PHP

2006-02-10 Thread Dan Parry
Also when specifying the field list (and table name) it may be a better idea
to wrap the values in backticks (`) rather than quotes (')

Always works for me

Dan

-Original Message-
From: Barry [mailto:[EMAIL PROTECTED] 
Sent: 10 February 2006 10:31
To: php-general@lists.php.net
Subject: [PHP] Re: Newbie Question Can't insert values into MySQL DB via
PHP

Duggles Temple wrote:
 Hi,
 
 I'd like to say in advance that I am sorry about the silly and very newbie
 question I'm asking.
 
 I am having a problem with a shop system. I can't add values into the
MySQL
 DB via a PHP statement. The values are being transferred from one page to
 another (know that from the echo statement), but the SQL statement isn't
 working.
 

What error do you get?


 The statement is as follows:
 
 $conn = mysql_connect($DBhost,$DBuser,$DBpass) or die('Unable to connect
to
 database');
 $t = $_GET['newdvdtitle'];
 $y = $_GET['newdvdyear'];
 $c = $_GET['newdvdcost'];
 $p = $_GET['newdvdpurchased'];
 @mysql_select_db($DBName) or die(Unable to select database $DBName);
 $sqladd = INSERT INTO 'dvd' ('id', 'title', 'year','cost','purchased')
 VALUES (  NULL , '$t', '$y', '$c' , '$p' );
 echo $sqladd;
 $result = mysql_query($sqladd);

Insert Into dvd (title, year,cost,purchased)

When the id is auto_increment you dont have to add it to the query.
Barry


-- 
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

-- 
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] Re: Newbie question

2004-11-28 Thread Brad Ciszewski
try, ?PHP header(Location: Page_here); ?

www.BradTechnologies.com
99.9% Uptime
24/7 FREE Support
Plans starting at $3.50 per month
www.BradTechnologies.com


Pascal Platteeuw [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello everyone,

 Here is a newbie question for you guys who are much more advanced than me
 :-)
 I want ot do an automatic redirection in a php page... Is there something
 equivalent to response.redirect used in ASP?

 Thanks in advance,

 Pascal Platteeuw

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



[PHP] Re: Newbie question about operators

2004-04-08 Thread Gabe
Thanks Ligaya


Ligaya Turmelle [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 it is refering to the associative array, specifically the $key = $value .
 Note here (http://www.php.net/manual/en/language.types.array.php).

 Respectfully,
 Ligaya Turmelle

 Gabe [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Looking at the code below, what exactly is happening with the
 $name=$value
  part?  I looked in the PHP online documentation and I can't find that
  operator.  What is it doing exactly and what is it called?
 
  foreach ($some_array as $name=$value)
  {
   ... some code ...
  }
 
  Thanks alot!

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



[PHP] Re: Newbie question about operators

2004-04-07 Thread Ligaya Turmelle
it is refering to the associative array, specifically the $key = $value .
Note here (http://www.php.net/manual/en/language.types.array.php).

Respectfully,
Ligaya Turmelle

Gabe [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Looking at the code below, what exactly is happening with the
$name=$value
 part?  I looked in the PHP online documentation and I can't find that
 operator.  What is it doing exactly and what is it called?

 foreach ($some_array as $name=$value)
 {
  ... some code ...
 }

 Thanks alot!

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



[PHP] Re: Newbie question on arrays

2004-03-28 Thread ma.siebeneicher
you need to declare your $monthname var as global, now you can use it!

function show_lang_date($timestamp, $country)
{
  GLOBAL $monthname;

  $date = getdate($timestamp);
  echo mday = . $date['mday'] .  ;
  echo country = $country ;
  $mon = $date[mon];
  echo mon = . $mon .  ;
  echo $monthname[$country][$mon];
  echo \n;
}



Willem Van Der Scheun [EMAIL PROTECTED] schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
Hi,

I've written the piece of code below and I do not get any output out of the
2 dimensional array. I do not see what's wrong. Must be something obvious I
guess.

?php

$monthname[NL][1] = Januari;
$monthname[NL][2] = Februari;
$monthname[NL][3] = Maart;
$monthname[NL][4] = April;
$monthname[NL][5] = Mei;
$monthname[NL][6] = Juni;
$monthname[NL][7] = Juli;
$monthname[NL][8] = Augustus;
$monthname[NL][9] = September;
$monthname[NL][10] = Oktober;
$monthname[NL][11] = November;
$monthname[NL][12] = December;

$monthname[BR][1] = Janeiro;
$monthname[BR][2] = Fevreiro;
$monthname[BR][3] = Março;
$monthname[BR][4] = Abril;
$monthname[BR][5] = Maio;
$monthname[BR][6] = Junho;
$monthname[BR][7] = Julho;
$monthname[BR][8] = Augosto;
$monthname[BR][9] = Setembro;
$monthname[BR][10] = Outobro;
$monthname[BR][11] = Novembro;
$monthname[BR][12] = Decembro;

$monthname[EN][1] = January;
$monthname[EN][2] = February;
$monthname[EN][3] = March;
$monthname[EN][4] = April;
$monthname[EN][5] = May;
$monthname[EN][6] = June;
$monthname[EN][7] = July;
$monthname[EN][8] = August;
$monthname[EN][9] = September;
$monthname[EN][10] = October;
$monthname[EN][11] = November;
$monthname[EN][12] = December;

function show_lang_date($timestamp, $country)
{
  $date = getdate($timestamp);
  echo mday = . $date['mday'] .  ;
  echo country = $country ;
  $mon = $date[mon];
  echo mon = . $mon .  ;
  echo $monthname[$country][$mon];
  echo \n;
}

$timestamp = time();
show_lang_date($timestamp, NL);
show_lang_date($timestamp, BR);
show_lang_date($timestamp, EN);

?

When I run this I get the following output

Content-type: text/html
X-Powered-By: PHP/4.3.3

mday = 28 country = NL mon = 3
mday = 28 country = BR mon = 3
mday = 28 country = EN mon = 3

so no monthname!

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



[PHP] Re: Newbie question on Array

2004-03-28 Thread DvDmanDT
You can't do it that way.. You'll probably get parse error..
-- 
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
[EMAIL PROTECTED] skrev i meddelandet
news:[EMAIL PROTECTED]

 Sorry, I am new and could not supply the correct search strings on search
 sites to answer by question.


 I am trying to construct an array with key-value from a resultSet which
will
 be used often within the page or between pages.

 Which looks like this:

  $optionBox=select used_1, rub from rub_table order by rub asc;
 $rs_box=mysql_query($optionBox,$con);
 $arr=Array(
 while($row=mysql_fetch_array($rs_box))
 {
'$row[used_1]' = '$row[rub]'  ,
 });

  ,--- This does not need to appear in the last loop.

 Is this possible?, if yes what is wrong with my code?.

 many thanks for your help..

 (._.)---Carlson

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



[PHP] Re: Newbie question

2004-01-13 Thread Luke
it sounds like maybe you dont have the mysql php extension turned on in the
php ini file, or your php doesnt have mysql support?

Luke

James Marcinek [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hello Everyone,

 I'm new to this so forgive my ignorance. I'm trying to use php with MySQL
 as a database. I'm using apache 2.0 in addition to Mysql 4.1.

 I created a simple page (using book to learn) and when I try to go to a
 simple  php script I recieve the following error:

 Call to undefined function:  mysql_connect()

 I've followed the instructions and the mysql_connect() function has the
 correct arguments supplied (host, user, passwd);

 Can anyone shed any light on this? I've looked at the php.ini file and it
 looks ok. the apache has the php.conf file in the conf.d directory.

 The book I'm learning from had some simple examples pages that I created
 early on and they work; however this is the first attempt at trying to use
 php to connect.

 Any help would be appreciated.

 Thanks,

 James

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



[PHP] Re: newbie question about scope

2003-11-12 Thread pete M
things to check..
check the register_globals flag in php.ini - you can also set this using 
ini_set()

Check the short_open_tags are either on/off - again this chan be changes 
in ini_set()

pete

News.Comcast.Giganews.Com wrote:

I am an experienced web developer who is just getting into php.  I have had
a php project fall into my lap and wanted a little advice.  Here is the
scoop:
A client moved their site from a server (unknown details) to a hosting
facility (php 4.3.2).  Now none of the scripts work.  I have guessed that
they are coming from an earlier version of apache/php.  Anyway it appears
that whoever created the site in the first place did not believe in scoping
variables.  Now any variable that is not properly scoped will not be read by
the server.  I know I can simply scope all of the variables, but I was
hoping there may be an easier way.  Also, how bad is the _REQUEST scope I
read that it could not be trusted, however the previous developer created
the app in such a way that several places a variable could be _GET or _POST.
I apologize for the rambling and possible incoherency of this message, I am
a bit tired.
Matthew

PS. How do you scope queries?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: newbie question

2002-09-03 Thread Richard Lynch

How do I get PHP to automatically open another PHP page in a browser if a
condition is met?

 I have a pull down HTML table that submits a form to a PHP script.  That
script then uses a little logic to figure out which web page to go to.  I
have 5 different pages, and each has different content.  Right now, I can
make it bring up links, but I can't figure a way out to make it
automatically go to the proper web page.

I know this has to be easy, but I can't find any info one it.

First some Good News:

Here's a couple quickie options:

1. Use http://php.net/include to just suck in the other file to the shell
that you've built.
2. Use http://php.net/header as header(Location: $otherpage); to re-direct
the browser.

Now, some meta-comments about these techniques.

1. Seems really nice, until you have to come back to the page and maintain
it a couple years down the line.  It gets really messy to figure out what
variables are coming from where when you have this shell game going on
sucking in different files based on a variable.  You can work with it, but
expect to end up investing more in maintenance than you should

2. is really an abusive use of a mechanism for pages that *MOVED* --
header(Location: ) is really not the right weapon for programming
site/layout.  It was designed for pages that have literally been picked up
and moved to another URL/server/whatever.  It *can* be used to force the
user to jump around inside your site, but that was not its intent, and will
be problematic.  One specific instance is that you'll end up not being able
to use Cookies/Sessions reliably because the re-location happens before
the Cookie makes it out the door.

Now, for the Bad News:
You really need to re-think the big picture of the design of your web-site
so that you don't have to do this.

You can use JavaScript in your HTML to re-direct the user to a different
page, and leave PHP out of the page-choosing logic.  But then you are
relying on JavaScript which is unreliable, and some users don't even have
it.

It may work for the sites you visit (for *you*) and you may find it
attractive, but there *will* be users who leave your site because it doesn't
work.

Your best bet is to not use an HTML pop-up menu for navigation at all. 
There is no reliable way using maintainable code that will make it really
work.

-- 
Like Music?  http://l-i-e.com/artists.htm

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




[PHP] Re: Newbie question about SQL result formatting

2002-08-09 Thread Philip Hallstrom

see nl2br().  You might also want to convert spaces to nbsp;'s

On Fri, 9 Aug 2002, Kristoffer Strom wrote:

 Ok, this is totally newbie but I just started messing around with PHP after
 programming IBM's NetData for a while.

 My first big problem I haven't been able to solve myself is how to format
 the result of an SQL query into HTML code.
 In the (MySQL) database, I have one field for very long texts. One test
 entry looks like this:
 --
 test

test

  test
 --
 But when printing the result, even with HTMLENTITIES and HTMLSPECIALCHARS,
 just looks like:
 -
 test   test   test
 -

 How do I convert the result to HTML code, I especially want the linebreaks!!

 The answer is probably very simple

 /Kris



 --
 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] Re: Newbie question about SQL result formatting

2002-08-09 Thread Kristoffer Strom

There we go :)

If there's any consolation, you just helped NataliePortman.com become a
better website :)

Thx

/Kris

Philip Hallstrom [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 see nl2br().  You might also want to convert spaces to nbsp;'s

 On Fri, 9 Aug 2002, Kristoffer Strom wrote:

  Ok, this is totally newbie but I just started messing around with PHP
after
  programming IBM's NetData for a while.
 
  My first big problem I haven't been able to solve myself is how to
format
  the result of an SQL query into HTML code.
  In the (MySQL) database, I have one field for very long texts. One test
  entry looks like this:
  --
  test
 
 test
 
   test
  --
  But when printing the result, even with HTMLENTITIES and
HTMLSPECIALCHARS,
  just looks like:
  -
  test   test   test
  -
 
  How do I convert the result to HTML code, I especially want the
linebreaks!!
 
  The answer is probably very simple
 
  /Kris
 
 
 
  --
  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] Re: Newbie question : PHP variables are not posted by this

2002-05-31 Thread Michael Davey

Can you send the code that is failing to the list - it will help in working
out the problem...

Mikey

FréDéRick St-Hilaire [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 It a BASIC question,

 With the following:

 FORM NAME='Job_Application' ACTION=job_action.php METHOD=post
 ENCTYPE=multipart/form-data
 INPUT TYPE=text NAME=name
  Name : BR
 INPUT TYPE=HIDDEN NAME=MAX_FILE_SIZE VALUE=20
 INPUT TYPE=FILE NAME=userfileBRBR
 INPUT TYPE=submit NAME=enter VALUE=SendBR
 INPUT TYPE=reset value=reset name=resetBR
 /FORM

 With the job_action.php I want to display the resaults to the user.

 But the variable name is empty.

 What's the problem?

 Thanks

 Frédérick St-Hilaire





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




Re: [PHP] Re: Newbie question : PHP variables are not posted by this

2002-05-31 Thread Stuart Dallas

On Friday, May 31, 2002, 5:17:49 PM, you wrote:
 Can you send the code that is failing to the list - it will help in working
 out the problem...

And include your platform details (OS, PHP version, etc).

-- 
Stuart


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




[PHP] Re: Newbie question about PHP and Oracle

2002-05-28 Thread Markus Mirsberger

Hi,

I think you mean hwo u can get the data into an array
well here is an example :

$query = select ...;
$stmt = ociparse( $connectionhandle, $query );

if( ociexecute( $stmt, OCI_DEFAULT ) ){
ocifetchinto( $stmt, $row, OCI_ASSOC+OCI_RETURN_NULLS );
}

and now you got 1 resultset in an associative array called $row.
take a look at the oci-functions in the manual for the different flags u can
set.



regards
markus mirsberger


Michael Sweeney [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 a VERY newbie question, just how do I get data into a listbox? In mysql it
 was pretty easy with mysql_fetch_row, but for oracle I am totally lost.


 Thanks!







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




[PHP] Re: Newbie question to everybody....PHP

2002-05-11 Thread Austin Marshall

R wrote:
 Greetings people,
 Special greetings to all of you who have helped me in the past.
 
 As most of you know i am a newbie, I learned a bit of PHP via webmonkey and
 a few other places, seeing the power of PHP i decided to convert from Java
 servlets and JSP (JSP coz its expensive to host and not many hosting
 opportunities) so I baught a book called The PHP black book.
 Anyway, now that the background is done heres my questions:
 
 1)How many of you have seriously dug into arrays and has it been important
 in your programming?
 1.1)Do you think you could have done the same thing you did with arrays
 WITHOUT arrays?
 (The reason i ask this is theres a whole chapter dedicated to arrays in the
 book  its pretty frustrating)
 Last question:
 Is ther any function to make the program sleep for 10 seconds or so? or
 does anybody have a function that does this?
 
 ANY replies good,bad,flames will be welcome.
 Cheers,
 -Ryan.
 
 /* You cannot get to the top by sitting on your bottom. */
 
 
 
 

I couldn't imagine a world without arrays.  But even if you don't 
understand the creation of arrays, you should at least get familiar with 
the $_POST,$_GET,$_SERVER,etc... arrays as you probably won't be able to 
write any useful scripts without them.  Not to mention the fact that you 
will probably never be able interface with a database without using arrays.


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




[PHP] Re: Newbie Question

2002-04-08 Thread Michael Virnstein

try this:

html
head
titleSolid/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head

body bgcolor=#FF text=#00
table width=384 border=1

?php
 $fp = fopen (album.dat,r);
 while ($data = fgetcsv ($fp, 1000, ;))
 {
if (isset($data[0]))
{
print(tr);
print(td.$data[0]./td);
print(tdimg src=\images/.$data[1].\a href
=\prod.php?file=lecteur.dat\/a/td);
print(td.$data[2]./td);
print(td.$data[3]./td);
print(td.$data[4]./td);
print(td.$data[5]./td);
print(/tr);
}
 }
?
/table
/body
/html


Hubert Daul [EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


 Hi ,

 Here's my problem :

 I read a data file (no sql file) which contains 8 lines, and in each line,
8
 datas

 (ex: name1;picture1;title1;anything1;everything1;nothing1)

 and when i run it I see only one picture(the second data) and not all of
 them

 If someone could help me

 TYA

 Here the code :

 html
 head
 titleSolid/title
 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
 /head

 body bgcolor=#FF text=#00
 table width=384 border=1

 ?php
  $row = 1;
  $fp = fopen (album.dat,r);
   while ($data = fgetcsv ($fp, 1000, ;))
   {
 $num = count ($data);

 $row++;

 if (isset($vignette))
 {
 print(tr);
 print(td$vignette/td);
// I think it's wrong here but I dont know why
 ==   print(tdimg src=\images/$photo\a href =
 \prod.php?file=lecteur.dat\/a/td);
 print(td$marque/td);
 print(td$nom/td);
 print(td$pdfproduit/td);
 print(td$commprod/td);
 print(/tr);
 }


 for ($c=0; $c$num; $c++)
 switch ($c)  {
 case 0 :
 {
 $vignette = $data[$c];
 break;
 }

 case 1 :
 {
 $photo= $data[$c];
 break;
 }

 case 2 :
 {
 $marque= $data[$c];
 break;
 }

 case 3 :
 {
 $nom = $data[$c];
 break;
 }

 case 4 :
 {
 $pdfproduit= $data[$c];
 break;
 }

 case 5 :
 {
 $commprod = $data[$c];
 break;
 }
 }
  }
 ?
 /table
 /body
 /html








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




[PHP] Re: newbie question: how to recompile PHP?

2002-04-03 Thread Craig Donnelly

Strange..U sure you got the Win32 version??

Heres a mirror where u can get the installer:
http://www.evilwalrus.com/downloads/php/4.1.2/php-4.1.2-installer.exe

All the best,

Craig

Bogdan Popescu [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello all,

   I hope my newbie question don't bother you
   too much.

   I've downloaded the latest PHP for windows
   but when I try to use it I get a message
   that I have to re-compile it.

 (You may disable this restriction by recompiling the PHP binary
 with the --disable-force-cgi-redirect switch.)

   Can anybody tell me a couple of words about
   how to recompile PHP? Or this error message
   is just an issue of php.ini?
   I got the sources but what kind a compiler
   do I need, where from I can get it?

 --
 TIA,
 Bogdan  mailto:[EMAIL PROTECTED]




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




[PHP] Re: Newbie question...

2002-02-22 Thread J Smith


Try wget if it's installed. If not, lynx, a shell-based web browser, is 
installed on quite a few machines. 

J




Ben Turner wrote:

 This may be a bit off topic but I am trying to install the pdflib package
 for Linux so I can make pdfs through php and I was wondering if anyone
 might know the command to download a file via CRT from an http source.
 
 I apologize to the OT but I cant seem to get much of anything to work for
 me.
 
 Thanks!
 Ben


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




[PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Ben Crawford

You also seem to have an extra equals. Your loop should read:

while (false != ($file=readdir($handle))){

It should come up as an error, but I'm not sure.

Ben

Manuel Ritsch wrote:

 Hello There

 I'm new to PHP and trying to code a function that reads all teh files out of
 a directory and printing out a link and the filesize,
 but it seems that the filesize() function doesn't work, here's the code so
 far:

  $handle = opendir ('images');
  echo Files:brbr;
  while (false !== ($file = readdir ($handle))) {
  if($file != .  $file != ..)
  {
  $file_s = filesize($file);
  echo a href=images/$file$file/a Filesize:
 $file_sbr;
  }
  }
  closedir($handle);

 and the output is somethingl ike this:

 Files:
 button_test_04.gif Filesize:
 button_test_03-down.gif Filesize:
 lilextras_01.gif Filesize:
 (and so on)...

 You see, there's no Filesize and I don't know why, please help me

 -- manu


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




RE: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Martin Towell

that should be okay - it's to make sure that it is exactly equal to (as
opposed to equates to be equal to)

eg (0 === false)  = false
   (0 ==  false)  = true

-Original Message-
From: Ben Crawford [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 07, 2002 2:28 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Newbie: Question about filesize()


You also seem to have an extra equals. Your loop should read:

while (false != ($file=readdir($handle))){

It should come up as an error, but I'm not sure.

Ben

Manuel Ritsch wrote:

 Hello There

 I'm new to PHP and trying to code a function that reads all teh files out
of
 a directory and printing out a link and the filesize,
 but it seems that the filesize() function doesn't work, here's the code so
 far:

  $handle = opendir ('images');
  echo Files:brbr;
  while (false !== ($file = readdir ($handle))) {
  if($file != .  $file != ..)
  {
  $file_s = filesize($file);
  echo a href=images/$file$file/a
Filesize:
 $file_sbr;
  }
  }
  closedir($handle);

 and the output is somethingl ike this:

 Files:
 button_test_04.gif Filesize:
 button_test_03-down.gif Filesize:
 lilextras_01.gif Filesize:
 (and so on)...

 You see, there's no Filesize and I don't know why, please help me

 -- manu


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



Re: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Jeff Sheltren

At 10:27 AM 2/6/2002 -0500, Ben Crawford wrote:
You also seem to have an extra equals. Your loop should read:

while (false != ($file=readdir($handle))){

I think you could eliminate the false != in the while condition...

It should be just the same if you write
while (($file = readdir($handle)))

right?

-Jeff




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




Re: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Lars Torben Wilson

On Wed, 2002-02-06 at 07:27, Ben Crawford wrote:
 You also seem to have an extra equals. Your loop should read:
 
 while (false != ($file=readdir($handle))){
 
 It should come up as an error, but I'm not sure.
 
 Ben

No, that's the 'identical' operator, which returns true when its
operands are both equalivalent and of the same type:

  http://www.php.net/manual/en/language.operators.comparison.php


Cheers,

Torben

-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


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




Re: [PHP] Re: Newbie: Question about filesize()

2002-02-06 Thread Lars Torben Wilson

On Wed, 2002-02-06 at 15:33, Jeff Sheltren wrote:
 At 10:27 AM 2/6/2002 -0500, Ben Crawford wrote:
 You also seem to have an extra equals. Your loop should read:
 
 while (false != ($file=readdir($handle))){
 
 I think you could eliminate the false != in the while condition...
 
 It should be just the same if you write
 while (($file = readdir($handle)))
 
 right?
 
 -Jeff

Wrong, actually. If you have any files in that directory which have
names which would evaluate as false in PHP, then your way will fail on
them and you'll get a truncated directory listing. Do 'touch 0' in a 
directory and give it a shot; you'll see what I mean.

However, the original example does the same thing, since it only checks
whether the result of the readdir() evaluates to FALSE, not whether it
actually is a boolean FALSE value. The correct way to do this is:

  while (FALSE !== ($file = readdir($handle))) {
 . . . 
  }

Note the !== instead of !=.


Hope this helps,

Torben

-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


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




[PHP] Re: Newbie: Question about filesize()

2002-01-31 Thread Jim Winstead

Manuel Ritsch [EMAIL PROTECTED] wrote:
 $file_s = filesize($file);

you want $file_s = filesize(images/$file).

jim

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




[PHP] Re: Newbie question on Tutorials?

2001-12-06 Thread The Big Roach

Bunch of them!
Check php.net's links and sift through those.
Web Monkey has a good primer on PHP  MySQL.

Geoff E [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Okay, probably been asked zillions of times already, but I couldn't find
 reference to it in the last 5 minutes. :)

 Where can I find newbie-novice tutorials on php/mysql?

 My server is PHP4/MySql on a Apache/FreeBSD.

 I want to learn how to make these types of sites: Dating, BuySell,
Forums,
 etc...

 I have VB, Delphi, and C programming experience, so I'm hoping it won't be
 too hardcore. :)

 Cheers,

 - Geoff





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




[PHP] Re: Newbie Question

2001-11-21 Thread Lee Willmann

Ok, I think I have the solution to your problem.

Try using nl2br() on the data in that field..
Example:

I have a message table that allows one user to send an instant message to
another user on my site. There are several fields, one of which being a TEXT
column (MySQL db). I use a simple textarea form element to get the data. It
inserts into the DB as basically a single line regardless of the ENTER
keystrokes in the data. Now, when I pull it back out I use this:

$query = SELECT * FROM message WHERE msg_id = '$msg_id';
$query_result = mysql_query($query);
$query_row = mysql_fetch_array($query_result);

$message = $query_row[message];

echo Message text:.nl2br($message);

And that should do what you need.

Lee Willmann

Steve Brett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 have a look at get_html_translation_table() in the php manual.

 there is an example of conversion of all special chars so they can be
 inserted into the database as text (i.e. £pound) and a cool way of
 'decoding' them if you need to write them to a file. A Browser wil
interpret
 them correctly when they are displayed.

 This must be the question of the day as i have posted this answer three
 times today :-)

 Let me know if you need any more help

 Steve

 get_html_translation_table manual page is below:

   PHP Manual
   Prev  Next

 --
--
 

 get_html_translation_table
 (PHP 4 = 4.0b4)

 get_html_translation_table --  Returns the translation table used by
 htmlspecialchars() and htmlentities()
 Description

 string get_html_translation_table (int table [, int quote_style])


 get_html_translation_table() will return the translation table that is
used
 internally for htmlspecialchars() and htmlentities(). There are two new
 defines (HTML_ENTITIES, HTML_SPECIALCHARS) that allow you to specify the
 table you want. And as in the htmlspecialchars() and htmlentities()
 functions you can optionally specify the quote_style you are working with.
 The default is ENT_COMPAT mode. See the description of these modes in
 htmlspecialchars(). Example 1. Translation Table Example

 $trans = get_html_translation_table (HTML_ENTITIES);
 $str = Hallo  Frau  Krämer;
 $encoded = strtr ($str, $trans);



 The $encoded variable will now contain: Hallo amp; lt;Fraugt; amp;
 Krauml;mer.

 The cool thing is using array_flip() to change the direction of the
 translation.


 $trans = array_flip ($trans);
 $original = strtr ($str, $trans);




 The content of $original would be: Hallo  Frau  Krämer.
   Note: This function was added in PHP 4.0.


 See also: htmlspecialchars(), htmlentities(), strtr(), and array_flip().


 --
--
 
   Prev Home Next
   explode Up get_meta_tags





 Jay Fitzgerald [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]...
  Ok, I am still fairly new at PHP and MySQL also, so please bear with me.
 
 
  TASK: I have a client that wants to have job openings listed on their
site
  and they want to be able to add, edit and delete the postings
themselves.
 I
  would do this in flat-file format but there is the risk of that file
size
  getting too large and slowing down the server.
 
 
  SOLUTION: I have created a MySQL database that will hold all the
postings
  in a table called 'jobs' and have created a PHP form that will post this
  jobs into the db.
 
  PROBLEM: When I go to the PHP form and enter all of the pertinent job
  information, there is one specific field that will have to have carriage
  returns/line breaks in it between paragraphs. Everything is working
except
  for this. Is there a way whenever the user presses ENTER, that either
  PHP/MySQL will convert this into a BR tag only when being displayed in
a
  browser and not in the db??
 
 
  Can anyone out there please help me with this? I am available off-list
as
  well if it will be easier to pass code back and forth. Any assistance is
  greatly appreciated!
 
 
 
  Should you have any questions, comments or concerns, feel free to call
me
  at 318-338-2034.
 
  Thank you for your time,
 
  Jay Fitzgerald, Design Director - CSBW-A, CPW-A, CWD-A, CEMS-A
  ==
  Bayou Internet..(888)
  30-BAYOUhttp://www.bayou.com
  Mississippi Internet...(800)
  MISSISSIPPI...http://www.mississippi.net
  Vicksburg Online..(800)
  MISSISSIPPIhttp://www.vicksburg.com
  ==
  Tel: (318) 338-2034ICQ: 38823829
Fax:
  (318) 323-5053
 





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




[PHP] Re: Newbie question pleeze help

2001-11-15 Thread Richard Lynch

Rvb Pixels wrote:

 Hi,
 
 I'm new to the list and I have a problem with PHPNUKE 5.2 and W98.
 
 After installing some categories and links in the Web Links section, and
 then clicking on one of the links created I keep getting the following
 message error in W98SE.
 
 PHP caused an invalid page fault in module PHP4TS.DLL...
 
 
 Does anyone know why and how can I solve this problem ?

Your web server (Apache or IIS) has a log file with every error recorded, 
or at least, every error that isn't so horrendous that making a record is 
possible.

For Apache with the default installation Windows, it's in:
C:/Program Files/Apache Group/Apache/logs/error_log
(I think)

You may have some useful details in that file that can clue you in to what 
is happening.

There may also be instructions at http://bugs.php.net about how to track 
down these kinds of errors.

-- 
Like music?  http://l-i-e.com/artists.htm


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




[PHP] Re: Newbie Question re: Select boxes

2001-08-23 Thread jimw

Lb [EMAIL PROTECTED] wrote:
 1) I thought that PHP automatically created variables for all form elements
 on a page. When I run this, the dropdown box contains the first item, but
 $Report evaluates as null. I am unclear why.
 
 select name=ReportBR
 option value=1 Test Report A/option
 option value=2 Test Report B/option
 option value=3 Test Report C/option
 /select
 ? echo (the value is $Report); ?

you have set the value for each option to an empty string. you
probably mean either 'option value=1Test Report A/option' or
'option1 Test Report A/option'.

 2) Is there any way for PHP to detect the change even on the dropdown, or do
 I need to use javascript?

you have to use javascript.

jim

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




[PHP] Re: Newbie question: Page Counter

2001-04-19 Thread yanto


this counter'll increment the counter, no matter where are you go the page
from. If you only want that the counter increment for the first time
visitor visit the website, put the code at mainpage file, and check also
the page referrer weather it's a local url or not.


-toto-

Adam writes:

 make a file called counter.php and include this text:
 
 //-counter.php--
 ---//
 
 ?php
  //Simple PHP counter, v0.1. Send comments to [EMAIL PROTECTED]
  if (file_exists('count.inc'))
  {
   $fil = fopen('count.inc', r);
   $dat = fread($fil, filesize('count.inc'));
   echo $dat+1;
   fclose($fil);
   $fil = fopen('count.inc', w);
   fwrite($fil, $dat+1);
  }
  else
  {
   $fil = fopen('count.inc', w);
   fwrite($fil, 1);
   echo '1';
   fclose($fil);
  }
 php?
 
 //--
 --//
 
 
 then make a file called count.inc and chmod it to 777 so anyone can write to
 it. insert a number into the file.
 
 
 //--count.inc---
 --//
 some value

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