Re: [PHP] why won't this work?
I did a View->Source on the generated code and got this for the Friday Feb 28 entry: Friday February 28th 8 AM to Noon John Look at the last ... 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 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! SIGN Up Name Time Friday, February 28, 8 a.m.-12 p.m. Friday, February 28, 12 p.m.-4 p.m. Friday, February 28, 4 p.m.-8 p.m. Saturday, March 1, 8 a.m.-12 p.m. Saturday, March 1, 12 p.m.-4 p.m. Saturday, March 1, 4 p.m.-8 p.m. Sunday, March 2, 8 a.m.-12 p.m. Sunday, March 2, 12 p.m.-4 p.m. Sunday, March 2, 4 p.m.-8 p.m. Friday February 28th 8 AM to Noon "; print $myrow["name"]; print ""; } ?> Friday February 28th 12 p.m to 4 p.m. "; print $myrow1["name"]; print ""; } ?> Friday February 28th 4 p.m. to 8 p.m. "; print $myrow2["name"]; print ""; } ?> Saturday March 1st 8 AM to Noon "; print $myrow3["name"]; print ""; } ?> Saturday March 1st 12 p.m to 4 p.m. "; print $myrow4["name"]; print ""; } ?> Saturday March 1st 4 p.m. to 8 p.m. "; print $myrow5["name"]; print ""; } ?> Sunday March 2nd 8 AM to Noon "; print $myrow6["name"]; print ""; } ?> Sunday March 2nd 12 p.m to 4 p.m. "; print $myrow7["name"]; print ""; } ?> Sunday March 2nd 4 p.m. to 8 p.m. "; print $myrow8["name"]; print ""; } ?> -- 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?
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?>>> $result = mysql_query("SELECT distinct ip from ma_counter"); while(list($ip) = mysql_fetch_row($result)) { print ("$ip"); } ?> > > > > > > >> $mode = "entrance"; >> if ($mode == "entrance") { >> >> >> >> > > > 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?
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?>>$result = mysql_query("SELECT distinct ip from ma_counter"); >>>while(list($ip) = mysql_fetch_row($result)) >>>{ >>>print ("$ip"); >>>} >>>?> >>> >>> >>> >>> >>> >>> > $mode = "entrance"; > if ($mode == "entrance") { > > > > > 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?
> 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?
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?$result = mysql_query("SELECT distinct ip from ma_counter"); >while(list($ip) = mysql_fetch_row($result)) >{ >print ("$ip"); >} >?> > > > > >> >> >> >> >>> $mode = "entrance"; >>> if ($mode == "entrance") { >>> >>> >>> >> >>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?
> $mode = "entrance"; > if ($mode == "entrance") { > 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?
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> JW>$mode = "entrance"; $mode is "entrance" > JW>if ($mode = "entrance") { looks if mode is > "entrance" which is > JW> include("inc/entrance.php");if was true so it > includes entrance > JW>} > JW>else 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: > > $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?
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?
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. > >$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?
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>$mode = "entrance"; $mode is "entrance" JW>if ($mode = "entrance") { looks if mode is "entrance" which is JW> include("inc/entrance.php");if was true so it includes entrance JW>} JW>else 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: 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