Re: [PHP] why won't this work?

2003-02-18 Thread Rick Emery
I did a View-Source on the generated code and got this for the Friday Feb 28 entry:
table width='95%'
tr bgColor=#99td
   center
  font face='arial' size='3' color='ff'Friday February 28th 8 AM to Noon
  /td/tr
  
trtdcenterJohn/tr/tdtrtdcenter/tr/tdtrtdcenter/tr/td
 /table

Look at the last trTD... line.  Fix that, and your problems may go away.
- Original Message - 
From: Edward Peloke [EMAIL PROTECTED]
To: Php-General@Lists. Php. Net [EMAIL PROTECTED]
Sent: Tuesday, February 18, 2003 7:24 AM
Subject: [PHP] why won't this work?


Why won't this work? I have a form that people enter in a time to volunteer,
when the submit it, I call the same page and want the time to then show on
the page but I have to refresh it to see the time and sometimes it just
doesn't show up.  It is like the page loads before all the sql statements
are run because if I print them and run them in mysql, I get results.

the test page is here...I know it is ugly...
http:\\peloke.webhop.org\mom\bikers.php

Thanks,
Eddie


?
if ($bikers){$SQL = insert into bbreak(name,time) values ('$name','$time')
;
 $result = mysql_db_query($db,$SQL,$connection);
}


?
center
Please sign up for the hours that you can work.  We need a minimum of 3
men there for each shift. They will be doing the tire pressure checks and
any other minor maintenance that might be required. Ladies are also urged to
come as we are hoping there will be women bikers that we can minister to in
whatever way is needed.  Anyone can come anytime but we need to have enough
commitments that we know the break will be staffed adequately every shift.
We cannot give away anything that would compete with the drinks and
snacks that are sold at the rest stop but we can give away ice water and
possibly coffee. Thanks for your help!
 br
 br
 SIGN Up
 FORM name=bikers action=bikers.php method=post
 Name input type='text' name='name' maxlength='25'
Time SELECT name=time
OPTION value=288 selectedFriday, February 28, 8
a.m.-12 p.m./OPTION
OPTION value=2812Friday, February 28, 12 p.m.-4
p.m./OPTION
OPTION value=284Friday, February 28, 4 p.m.-8
p.m./OPTION
OPTION value=18Saturday, March 1, 8 a.m.-12
p.m./OPTION
OPTION value=112Saturday, March 1, 12 p.m.-4
p.m./OPTION
OPTION value=14Saturday, March 1, 4 p.m.-8
p.m./OPTION
OPTION value=28Sunday, March 2, 8 a.m.-12
p.m./OPTION
OPTION value=212Sunday, March 2, 12 p.m.-4
p.m./OPTION
OPTION value=24Sunday, March 2, 4 p.m.-8 p.m./OPTION
/SELECT
INPUT type=submit value=SignUp name=bikers
br
br
center

table width='95%'
tr bgColor=#99td
 ?
 $SQL = select * from bbreak where time=288 ;
 $result = mysql_db_query($db,$SQL,$connection);
 $myrow = mysql_fetch_array($result);
 ?
  center
  font face='arial' size='3' color='ff'Friday February 28th 8
AM to Noon
  /td/tr
  ? while ($myrow = mysql_fetch_array($result)){
 print trtdcenter;
 print $myrow[name];
 print /tr/td;
 }
  ?

 /table
table width='95%'
tr bgColor=#99td
 ?
 $SQL1 = select * from bbreak where time=2812 ;
 $result1 = mysql_db_query($db,$SQL1,$connection);
 $myrow1 = mysql_fetch_array($result1);
 ?
  center
  font face='arial' size='3' color='ff'Friday February 28th 12
p.m  to 4 p.m.
  /td/tr
  ? while ($myrow1 = mysql_fetch_array($result1)){
 print trtdcenter;
 print $myrow1[name];
 print /tr/td;
 }
  ?

 /table

 table width='95%'
tr bgColor=#66td
 ?
 $SQL2 = select * from bbreak where time=284;
 $result2 = mysql_db_query($db,$SQL2,$connection);
 $myrow2 = mysql_fetch_array($result2);
 ?
  center
  font face='arial' size='3' color='ff'Friday February 28th 4
p.m. to 8 p.m.
  /td/tr
  ? while ($myrow2 = mysql_fetch_array($result2)){
 print trtdcenter;
 print $myrow2[name];
 print /tr/td;
 }
  ?

 /table

table width='95%'
tr bgColor=#99td
 ?
 $SQL3 = select * from bbreak where time=18;
 $result3 = mysql_db_query($db,$SQL3,$connection);
 $myrow3 = mysql_fetch_array($result3);
 ?
  center
  font face='arial' size='3' color='ff'Saturday March 1st 8 AM
to Noon
  /td/tr
  ? while ($myrow3 = mysql_fetch_array($result3)){
 print 

Re: [PHP] Why won't this work?

2002-07-19 Thread Mantas Kriauciunas

Hello John,

Friday, July 19, 2002, 12:25:12 AM, you wrote:

JW Any ideas on why this won't work?  It will only include(inc/entrance.php)
JW It never, no matter what the value of $mode, displays collection.php.

thinking logicaly:

JW?php
JW$mode = entrance; $mode is entrance
JWif ($mode = entrance) {  looks if mode is entrance which is
JW include(inc/entrance.php);if was true so it includes entrance
JW}
JWelse if ($mode = collection) { looking again if for same $mode if it 
is collection but it was in first line entrance
JW include(inc/collection.php); if was false it never executes this 
part!
JW}

JW?

so what are you trying to get? both included?
if yes this will include both:

  ?php
   $mode = entrance;
   if ($mode = entrance) {
include(inc/entrance.php);
   }
   $mode = collection;
   if ($mode = collection) {
include(inc/collection.php);
   }

   ?


   sorry if i didn't understood the question!

-- 
Best regards,
 Mantasmailto:[EMAIL PROTECTED]


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




Re: [PHP] Why won't this work?

2002-07-19 Thread Rasmus Lerdorf

You need == instead of = there

On Fri, 19 Jul 2002, John Wulff wrote:

 Any ideas on why this won't work?  It will only include(inc/entrance.php)
 It never, no matter what the value of $mode, displays collection.php.

?php
$mode = entrance;
if ($mode = entrance) {
 include(inc/entrance.php);
}
else if ($mode = collection) {
 include(inc/collection.php);
}

?



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



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




Re: [PHP] Why won't this work?

2002-07-19 Thread René Moonen

You probably do not have a background of C / C++ programming ;-)

assignments:single equal sign
comparison:dual equal sign

The *assignments* in your if statements are always TRUE, so it will 
always execute the statements after the first *if*

So use
if ($mode == entrance) {
and
else if ($mode == collection) {

And all works well...


René



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




Re: [PHP] Why won't this work?

2002-07-19 Thread jusob

En réponse à Mantas Kriauciunas [EMAIL PROTECTED]:
Hi
You use = instead of ==
So, the first condition is always true

Regards
Julien
 Hello John,
 
 Friday, July 19, 2002, 12:25:12 AM, you wrote:
 
 JW Any ideas on why this won't work?  It will only
 include(inc/entrance.php)
 JW It never, no matter what the value of $mode, displays
 collection.php.
 
 thinking logicaly:
 
 JW?php
 JW$mode = entrance; $mode is entrance
 JWif ($mode = entrance) {  looks if mode is
 entrance which is
 JW include(inc/entrance.php);if was true so it
 includes entrance
 JW}
 JWelse if ($mode = collection) { looking again if for
 same $mode if it is collection but it was in first line entrance
 JW include(inc/collection.php); if was false it never
 executes this part!
 JW}
 
 JW?
 
 so what are you trying to get? both included?
 if yes this will include both:
 
   ?php
$mode = entrance;
if ($mode = entrance) {
 include(inc/entrance.php);
}
$mode = collection;
if ($mode = collection) {
 include(inc/collection.php);
}
 
?
 
 
sorry if i didn't understood the question!
 
 -- 
 Best regards,
  Mantasmailto:[EMAIL PROTECTED]
 
 
 -- 
 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] Why won't this work?

2002-07-19 Thread René Moonen

snip

   $mode = entrance;
   if ($mode == entrance) {

/snip
I suppose you added the first line ($mode = entrance; ) for testing 
purposes during debugging, but in order for the script to work you 
should now remove it, because now $mode will always have the value 
entrance

good luck


René



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




Re: [PHP] Why won't this work?

2002-07-19 Thread René Moonen

hmm... seems a MySQL topic.
I suppose that your table is filled with correct data at some other 
point. So what you need is a count query that returns
*one* result and not all records in that table. You do not want a 
*while* loop in your PHP script, because that would show a list of
unique ips. So my gues would be:

$result = mysql_query(SELECT COUNT(DISTINCT IP) AS ips FROM ma_counter);
$ips = mysql_fetch_row($result);
pintf(Visitors = %d,$ips);

Disclaimer: code not tested. You might want to check the MySQL manual 
for syntax details of the query.

Good luck

René


John Wulff wrote:

You're a savior, don't know how i missed that.  Thanks a bunch.  Now, one
more quick question if you don't mind.  I've got this query at the bottom
of my page for the purpose of a counter.  But naturally i don't want a
list of all the ips logged, i just want a count of how many unique ips
there are in the table.  How do i go about this??php
$result = mysql_query(SELECT distinct ip from ma_counter);
while(list($ip) = mysql_fetch_row($result))
{
print ($ip);
}
?


  

snip



 $mode = entrance;
 if ($mode == entrance) {

  

/snip
I suppose you added the first line ($mode = entrance; ) for testing
purposes during debugging, but in order for the script to work you
should now remove it, because now $mode will always have the value
entrance

good luck


René





  



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




RE: [PHP] Why won't this work?

2002-07-19 Thread joakim . andersson

 From: René Moonen [mailto:[EMAIL PROTECTED]]
 Sent: Friday, July 19, 2002 11:01 AM
  
 $result = mysql_query(SELECT COUNT(DISTINCT IP) AS ips FROM ma_counter);

You _might_ need to add GROUP BY ip (without quotes) to the end of that
query.

 Disclaimer: code not tested. You might want to check the MySQL manual 

Still not tested :-)

Regards
Joakim Andersson

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




Re: [PHP] Why won't this work?

2002-07-19 Thread René Moonen

Well if you *know* your query only returns one row or you are just 
interessed in the first row, just forget about the while construction

$result = mysql_query(SELECT id FROM ma_users WHERE user='$PHP_AUTH_USER');
$id=mysql_fetch_row($result)
print $id;

Good luck

René


John Wulff wrote:

Didn't work, but its a great place for me to start from.
As far as the difference between a looping query and a non looping query,
i understand the difference but not exactly how to go about writing a non
looping query.  This bit of code is looping, and i assume it dosen't need
to be, how do i fix this?
$result = mysql_query(SELECT id FROM ma_users where user='$PHP_AUTH_USER');
while(list($id) = mysql_fetch_row($result))
{
print($id);
}

  

hmm... seems a MySQL topic.
I suppose that your table is filled with correct data at some other
point. So what you need is a count query that returns
*one* result and not all records in that table. You do not want a
*while* loop in your PHP script, because that would show a list of
unique ips. So my gues would be:

$result = mysql_query(SELECT COUNT(DISTINCT IP) AS ips FROM
ma_counter); $ips = mysql_fetch_row($result);
pintf(Visitors = %d,$ips);

Disclaimer: code not tested. You might want to check the MySQL manual
for syntax details of the query.

Good luck

René


John Wulff wrote:



You're a savior, don't know how i missed that.  Thanks a bunch.  Now,
one more quick question if you don't mind.  I've got this query at the
bottom of my page for the purpose of a counter.  But naturally i don't
want a list of all the ips logged, i just want a count of how many
unique ips there are in the table.  How do i go about this??php
$result = mysql_query(SELECT distinct ip from ma_counter);
while(list($ip) = mysql_fetch_row($result))
{
print ($ip);
}
?




  

snip





   $mode = entrance;
   if ($mode == entrance) {



  

/snip
I suppose you added the first line ($mode = entrance; ) for testing
purposes during debugging, but in order for the script to work you
should now remove it, because now $mode will always have the value
entrance

good luck


René






  




  




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




Re: [PHP] Why won't this work?

2002-07-19 Thread René Moonen

Eh.. probably should be:

$result = mysql_query(SELECT id FROM ma_users WHERE 
user='$PHP_AUTH_USER');
$row=mysql_fetch_row($result)
print $row['id'];

René

René Moonen wrote:

 Well if you *know* your query only returns one row or you are just 
 interessed in the first row, just forget about the while construction

 $result = mysql_query(SELECT id FROM ma_users WHERE 
 user='$PHP_AUTH_USER');
 $id=mysql_fetch_row($result)
 print $id;

 Good luck

 René


 John Wulff wrote:

 Didn't work, but its a great place for me to start from.
 As far as the difference between a looping query and a non looping 
 query,
 i understand the difference but not exactly how to go about writing a 
 non
 looping query.  This bit of code is looping, and i assume it dosen't 
 need
 to be, how do i fix this?
 $result = mysql_query(SELECT id FROM ma_users where 
 user='$PHP_AUTH_USER');
 while(list($id) = mysql_fetch_row($result))
 {
 print($id);
 }

  

 hmm... seems a MySQL topic.
 I suppose that your table is filled with correct data at some other
 point. So what you need is a count query that returns
 *one* result and not all records in that table. You do not want a
 *while* loop in your PHP script, because that would show a list of
 unique ips. So my gues would be:

 $result = mysql_query(SELECT COUNT(DISTINCT IP) AS ips FROM
 ma_counter); $ips = mysql_fetch_row($result);
 pintf(Visitors = %d,$ips);

 Disclaimer: code not tested. You might want to check the MySQL manual
 for syntax details of the query.

 Good luck

 René


 John Wulff wrote:

   

 You're a savior, don't know how i missed that.  Thanks a bunch.  Now,
 one more quick question if you don't mind.  I've got this query at the
 bottom of my page for the purpose of a counter.  But naturally i don't
 want a list of all the ips logged, i just want a count of how many
 unique ips there are in the table.  How do i go about this??php
 $result = mysql_query(SELECT distinct ip from ma_counter);
 while(list($ip) = mysql_fetch_row($result))
 {
 print ($ip);
 }
 ?




 

 snip



   

 $mode = entrance;
 if ($mode == entrance) {



 

 /snip
 I suppose you added the first line ($mode = entrance; ) for testing
 purposes during debugging, but in order for the script to work you
 should now remove it, because now $mode will always have the value
 entrance

 good luck


 René


   



 




  







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