Re: [PHP] PHP and MySQL SELECT COUNT (*)
Dan Joseph schreef: On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: ... $i[servername] Try: $i['servername'] notice the ' and ' around the name. I've heard you can do w/o those, but I've had issues in the past where it didn't work. ITs also good practice to use 'em. yes, not quoting the array key will generate an E_NOTICE, php first looks for a constant named **servername** doesn't find it and falls back to using the literal as a string value, namely 'servername' developed with error_reporting set to E_ALL and such things are explained to you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
That was it!!! Thank you all so much for your help!!! =D ""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Wed, Sep 17, 2008 at 4:30 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: If by key you mean the column in the database, it's called: servername "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] What is the key for the server name? That's what you need when you output it. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: var_dump($i); looks messy, but I can see the server names in there and they are the correct names. "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: Still no luck displaying the stupid servername. Any other things I can try? "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: echo $query; yields SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Thanks, I know your problem, sorry for not seeing this sooner. mysql_fetch_row returns the numerical array types. $array[0]... You want to use mysql_fetch_array(). Change to that, and you should be seeing the servername's. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
I meant key in the array that was returned by MySQL. I answered you in my other post. The array was numerically index based instead of column based. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > If by key you mean the column in the database, it's called: servername > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> What is the key for the server name? That's what you need when you >> output it. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >>> var_dump($i); looks messy, but I can see the server names in there and >>> they are the correct names. >>> >>> >>> "Micah Gersten" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > Still no luck displaying the stupid servername. Any other things I > can > try? > > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> You'll want to change your Order By statement to 'ORDER BY >> CountSteps >> DESC'. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >>> echo $query; >>> >>> yields >>> >>> SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE >>> steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND >>> timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) >>> DESC >>> LIMIT 10 >>> > > >>> >>> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
On Wed, Sep 17, 2008 at 4:30 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: > If by key you mean the column in the database, it's called: servername > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > What is the key for the server name? That's what you need when you >> output it. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >> >>> var_dump($i); looks messy, but I can see the server names in there and >>> they are the correct names. >>> >>> >>> "Micah Gersten" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] >>> Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > Still no luck displaying the stupid servername. Any other things I can > try? > > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> You'll want to change your Order By statement to 'ORDER BY CountSteps >> DESC'. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >> >>> echo $query; >>> >>> yields >>> >>> SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE >>> steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND >>> timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC >>> LIMIT 10 >>> >>> > > >>> >>> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Thanks, I know your problem, sorry for not seeing this sooner. mysql_fetch_row returns the numerical array types. $array[0]... You want to use mysql_fetch_array(). Change to that, and you should be seeing the servername's. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life."
Re: [PHP] PHP and MySQL SELECT COUNT (*)
That's your problem, you need to use mysql_fetch_assoc instead of mysql_fetch_row. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > var_dump looks like this: > > array(2) { [0]=> string(9) "wehost006" [1]=> string(2) "72" } array(2) > { [0]=> string(8) "H7848-49" [1]=> string(2) "71" } array(2) { [0]=> > string(7) "H7853-2" [1]=> string(2) "70" } array(2) { [0]=> string(7) > "H7842-2" [1]=> string(2) "64" } array(2) { [0]=> string(9) > "WEHOST005" [1]=> string(2) "64" } array(2) { [0]=> string(7) > "h7835-2" [1]=> string(2) "57" } array(2) { [0]=> string(9) > "wehost007" [1]=> string(2) "56" } array(2) { [0]=> string(7) > "H7814-1" [1]=> string(2) "55" } array(2) { [0]=> string(5) "H0542" > [1]=> string(2) "54" } array(2) { [0]=> string(8) "H7811-12" [1]=> > string(2) "54" } > > > ""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Wed, Sep 17, 2008 at 4:21 PM, Vinny Gullotta >> <[EMAIL PROTECTED]>wrote: >> >>> var_dump($i); looks messy, but I can see the server names in there >>> and they >>> are the correct names. >>> >>> >>> "Micah Gersten" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] >>> >>> Do var_dump($i) in the loop to see if you're getting the data you >>> want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > Still no luck displaying the stupid servername. Any other things I > can > try? > > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> You'll want to change your Order By statement to 'ORDER BY >> CountSteps >> DESC'. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >> >>> echo $query; >>> >>> yields >>> >>> SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE >>> steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND >>> timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) >>> DESC >>> LIMIT 10 >>> >>> > > >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> Can you show us one of the var_dumps? >> >> -- >> -Dan Joseph >> >> www.canishosting.com - Plans start @ $1.99/month. >> >> "Build a man a fire, and he will be warm for the rest of the day. >> Light a man on fire, and will be warm for the rest of his life." >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
If by key you mean the column in the database, it's called: servername "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] What is the key for the server name? That's what you need when you output it. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: var_dump($i); looks messy, but I can see the server names in there and they are the correct names. "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: Still no luck displaying the stupid servername. Any other things I can try? "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: echo $query; yields SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
var_dump looks like this: array(2) { [0]=> string(9) "wehost006" [1]=> string(2) "72" } array(2) { [0]=> string(8) "H7848-49" [1]=> string(2) "71" } array(2) { [0]=> string(7) "H7853-2" [1]=> string(2) "70" } array(2) { [0]=> string(7) "H7842-2" [1]=> string(2) "64" } array(2) { [0]=> string(9) "WEHOST005" [1]=> string(2) "64" } array(2) { [0]=> string(7) "h7835-2" [1]=> string(2) "57" } array(2) { [0]=> string(9) "wehost007" [1]=> string(2) "56" } array(2) { [0]=> string(7) "H7814-1" [1]=> string(2) "55" } array(2) { [0]=> string(5) "H0542" [1]=> string(2) "54" } array(2) { [0]=> string(8) "H7811-12" [1]=> string(2) "54" } ""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Wed, Sep 17, 2008 at 4:21 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: var_dump($i); looks messy, but I can see the server names in there and they are the correct names. "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: Still no luck displaying the stupid servername. Any other things I can try? "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: echo $query; yields SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Can you show us one of the var_dumps? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
On Wed, Sep 17, 2008 at 4:21 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: > var_dump($i); looks messy, but I can see the server names in there and they > are the correct names. > > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Do var_dump($i) in the loop to see if you're getting the data you want. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >> >>> Still no luck displaying the stupid servername. Any other things I can >>> try? >>> >>> >>> "Micah Gersten" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] >>> You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > echo $query; > > yields > > SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE > steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND > timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC > LIMIT 10 > > >>> >>> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Can you show us one of the var_dumps? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life."
Re: [PHP] PHP and MySQL SELECT COUNT (*)
What is the key for the server name? That's what you need when you output it. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > var_dump($i); looks messy, but I can see the server names in there and > they are the correct names. > > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Do var_dump($i) in the loop to see if you're getting the data you want. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >>> Still no luck displaying the stupid servername. Any other things I can >>> try? >>> >>> >>> "Micah Gersten" <[EMAIL PROTECTED]> wrote in message >>> news:[EMAIL PROTECTED] You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > echo $query; > > yields > > SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE > steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND > timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC > LIMIT 10 > >>> >>> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
var_dump($i); looks messy, but I can see the server names in there and they are the correct names. "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: Still no luck displaying the stupid servername. Any other things I can try? "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: echo $query; yields SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: What I want to do is find the top 10 servers where the column steps = iisreset. The following code works great except that the page is not displaying the servername in the 'Server Name' column of my results (nothing appears, the column is just blank). servername and steps are the important columns in the database table. $_POST[time1] and $_POST[time2] come from a form submitted. When I copy and paste the entire select statement into the SQL tab in phpmyadmin (and replace the time variables with actual times corresponding to the timestamp column), it displays the correct results including servername. Everything works in the php page's results except for the servername. I feel like it's right in front of my face and that's why I can't see it lol. Any help would be greatly appreciated. Thanks in advance =) My code... $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps LIKE 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= '$_POST[time1]' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; $result = mysql_query($query) or die(mysql_error()); # display column titles echo ""; echo "Count"; echo "Server Name"; echo ""; #display results while($i = mysql_fetch_row($result)) { echo "", $i[COUNT('steps')], ""; echo "", $i[servername] ,""; } echo ""; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $i[servername] Try: $i['servername'] notice the ' and ' around the name. I've heard you can do w/o those, but I've had issues in the past where it didn't work. ITs also good practice to use 'em. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life." yeah, I've tried that combination before, but just for grins I tried it again, and same result. It displays the counts but not the servernames. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
Do var_dump($i) in the loop to see if you're getting the data you want. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > Still no luck displaying the stupid servername. Any other things I can > try? > > > "Micah Gersten" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> You'll want to change your Order By statement to 'ORDER BY CountSteps >> DESC'. >> >> Thank you, >> Micah Gersten >> onShore Networks >> Internal Developer >> http://www.onshore.com >> >> >> >> Vinny Gullotta wrote: >>> echo $query; >>> >>> yields >>> >>> SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE >>> steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND >>> timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC >>> LIMIT 10 >>> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: > What I want to do is find the top 10 servers where the column steps = > iisreset. The following code works great except that the page is not > displaying the servername in the 'Server Name' column of my results (nothing > appears, the column is just blank). > > servername and steps are the important columns in the database table. > $_POST[time1] and $_POST[time2] come from a form submitted. > > When I copy and paste the entire select statement into the SQL tab in > phpmyadmin (and replace the time variables with actual times corresponding > to the timestamp column), it displays the correct results including > servername. Everything works in the php page's results except for the > servername. I feel like it's right in front of my face and that's why I > can't see it lol. Any help would be greatly appreciated. Thanks in advance > =) > > My code... > > $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps LIKE > 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= '$_POST[time1]' > GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; > $result = mysql_query($query) or die(mysql_error()); > > # display column titles > echo ""; > echo "Count"; > echo "Server > Name"; > echo ""; > > #display results > while($i = mysql_fetch_row($result)) > { > echo "", $i[COUNT('steps')], > ""; > echo "", $i[servername] ,""; > } > echo ""; > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > $i[servername] Try: $i['servername'] notice the ' and ' around the name. I've heard you can do w/o those, but I've had issues in the past where it didn't work. ITs also good practice to use 'em. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life."
Re: [PHP] PHP and MySQL SELECT COUNT (*)
Still no luck displaying the stupid servername. Any other things I can try? "Micah Gersten" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: echo $query; yields SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
You'll want to change your Order By statement to 'ORDER BY CountSteps DESC'. Thank you, Micah Gersten onShore Networks Internal Developer http://www.onshore.com Vinny Gullotta wrote: > echo $query; > > yields > > SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE > steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND > timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC > LIMIT 10 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Wed, Sep 17, 2008 at 2:30 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: ""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED] >wrote: What I want to do is find the top 10 servers where the column steps = iisreset. The following code works great except that the page is not displaying the servername in the 'Server Name' column of my results (nothing appears, the column is just blank). servername and steps are the important columns in the database table. $_POST[time1] and $_POST[time2] come from a form submitted. When I copy and paste the entire select statement into the SQL tab in phpmyadmin (and replace the time variables with actual times corresponding to the timestamp column), it displays the correct results including servername. Everything works in the php page's results except for the servername. I feel like it's right in front of my face and that's why I can't see it lol. Any help would be greatly appreciated. Thanks in advance =) My code... $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps LIKE 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= '$_POST[time1]' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; $result = mysql_query($query) or die(mysql_error()); # display column titles echo ""; echo "class='tableHeader'>Count"; echo "Server Name"; echo ""; #display results while($i = mysql_fetch_row($result)) { echo "", $i[COUNT('steps')], ""; echo "", $i[servername] ,""; } echo ""; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Change that "COUNT(steps)" to "COUNT(steps) AS CountSteps", that might be the issue. Then you're using $i['CountSteps']. That seems a bit more normal looking to me atleast. Also, try echoing out your query on the screen to see that its formating properly in the PHP code. You may have something wrong in there, although I don't see any off hand. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life." Adding as CountSteps $i['CountSteps'] still leaves the column blank. echo $result; gives me an output of: Resource id #3 and echo $query; just gives me an error. One thing I don't understand is why echo $result; gives me Resource id #3 as an output. What does that mean? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php That's basically your result set ID number inside PHP. as for $query, what error are you getting? Does this $query echo out: $query = "SELECT servername, COUNT(steps) AS CountSteps FROM monitoring WHERE steps LIKE 'iisreset' AND timestamp <= '" . $_POST['time2'] . "' AND timestamp >= '" . $_POST['time1'] . "' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life." It's actually not an error, it's the select statement that is echo'd echo $query; yields SELECT servername, COUNT(steps) as CountSteps FROM monitoring WHERE steps = 'IISRESET' AND timestamp <= '2008-09-17 11:40:34' AND timestamp >= '2008-08-17' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
On Wed, Sep 17, 2008 at 2:30 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: > ""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED] >> >wrote: >> >> What I want to do is find the top 10 servers where the column steps = >>> iisreset. The following code works great except that the page is not >>> displaying the servername in the 'Server Name' column of my results >>> (nothing >>> appears, the column is just blank). >>> >>> servername and steps are the important columns in the database table. >>> $_POST[time1] and $_POST[time2] come from a form submitted. >>> >>> When I copy and paste the entire select statement into the SQL tab in >>> phpmyadmin (and replace the time variables with actual times >>> corresponding >>> to the timestamp column), it displays the correct results including >>> servername. Everything works in the php page's results except for the >>> servername. I feel like it's right in front of my face and that's why I >>> can't see it lol. Any help would be greatly appreciated. Thanks in >>> advance >>> =) >>> >>> My code... >>> >>> $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps >>> LIKE >>> 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= >>> '$_POST[time1]' >>> GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; >>> $result = mysql_query($query) or die(mysql_error()); >>> >>> # display column titles >>> echo ""; >>> echo "Count"; >>> echo "Server >>> Name"; >>> echo ""; >>> >>> #display results >>> while($i = mysql_fetch_row($result)) >>> { >>> echo "", $i[COUNT('steps')], >>> ""; >>> echo "", $i[servername] >>> ,""; >>> } >>> echo ""; >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >>> Change that "COUNT(steps)" to "COUNT(steps) AS CountSteps", that might >> be >> the issue. Then you're using $i['CountSteps']. That seems a bit more >> normal looking to me atleast. >> >> Also, try echoing out your query on the screen to see that its formating >> properly in the PHP code. You may have something wrong in there, although >> I >> don't see any off hand. >> >> -- >> -Dan Joseph >> >> www.canishosting.com - Plans start @ $1.99/month. >> >> "Build a man a fire, and he will be warm for the rest of the day. >> Light a man on fire, and will be warm for the rest of his life." >> >> > > Adding as CountSteps $i['CountSteps'] still leaves the column blank. > > echo $result; gives me an output of: > Resource id #3 > > and > > echo $query; > > just gives me an error. > > One thing I don't understand is why echo $result; gives me Resource id #3 > as an output. What does that mean? > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > That's basically your result set ID number inside PHP. as for $query, what error are you getting? Does this $query echo out: $query = "SELECT servername, COUNT(steps) AS CountSteps FROM monitoring WHERE steps LIKE 'iisreset' AND timestamp <= '" . $_POST['time2'] . "' AND timestamp >= '" . $_POST['time1'] . "' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life."
Re: [PHP] PHP and MySQL SELECT COUNT (*)
""Dan Joseph"" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: What I want to do is find the top 10 servers where the column steps = iisreset. The following code works great except that the page is not displaying the servername in the 'Server Name' column of my results (nothing appears, the column is just blank). servername and steps are the important columns in the database table. $_POST[time1] and $_POST[time2] come from a form submitted. When I copy and paste the entire select statement into the SQL tab in phpmyadmin (and replace the time variables with actual times corresponding to the timestamp column), it displays the correct results including servername. Everything works in the php page's results except for the servername. I feel like it's right in front of my face and that's why I can't see it lol. Any help would be greatly appreciated. Thanks in advance =) My code... $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps LIKE 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= '$_POST[time1]' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; $result = mysql_query($query) or die(mysql_error()); # display column titles echo ""; echo "Count"; echo "Server Name"; echo ""; #display results while($i = mysql_fetch_row($result)) { echo "", $i[COUNT('steps')], ""; echo "", $i[servername] ,""; } echo ""; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Change that "COUNT(steps)" to "COUNT(steps) AS CountSteps", that might be the issue. Then you're using $i['CountSteps']. That seems a bit more normal looking to me atleast. Also, try echoing out your query on the screen to see that its formating properly in the PHP code. You may have something wrong in there, although I don't see any off hand. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life." Adding as CountSteps $i['CountSteps'] still leaves the column blank. echo $result; gives me an output of: Resource id #3 and echo $query; just gives me an error. One thing I don't understand is why echo $result; gives me Resource id #3 as an output. What does that mean? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL SELECT COUNT (*)
On Wed, Sep 17, 2008 at 2:17 PM, Vinny Gullotta <[EMAIL PROTECTED]>wrote: > What I want to do is find the top 10 servers where the column steps = > iisreset. The following code works great except that the page is not > displaying the servername in the 'Server Name' column of my results (nothing > appears, the column is just blank). > > servername and steps are the important columns in the database table. > $_POST[time1] and $_POST[time2] come from a form submitted. > > When I copy and paste the entire select statement into the SQL tab in > phpmyadmin (and replace the time variables with actual times corresponding > to the timestamp column), it displays the correct results including > servername. Everything works in the php page's results except for the > servername. I feel like it's right in front of my face and that's why I > can't see it lol. Any help would be greatly appreciated. Thanks in advance > =) > > My code... > > $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps LIKE > 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= '$_POST[time1]' > GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; > $result = mysql_query($query) or die(mysql_error()); > > # display column titles > echo ""; > echo "Count"; > echo "Server > Name"; > echo ""; > > #display results > while($i = mysql_fetch_row($result)) > { > echo "", $i[COUNT('steps')], > ""; > echo "", $i[servername] ,""; > } > echo ""; > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > Change that "COUNT(steps)" to "COUNT(steps) AS CountSteps", that might be the issue. Then you're using $i['CountSteps']. That seems a bit more normal looking to me atleast. Also, try echoing out your query on the screen to see that its formating properly in the PHP code. You may have something wrong in there, although I don't see any off hand. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life."
[PHP] PHP and MySQL SELECT COUNT (*)
What I want to do is find the top 10 servers where the column steps = iisreset. The following code works great except that the page is not displaying the servername in the 'Server Name' column of my results (nothing appears, the column is just blank). servername and steps are the important columns in the database table. $_POST[time1] and $_POST[time2] come from a form submitted. When I copy and paste the entire select statement into the SQL tab in phpmyadmin (and replace the time variables with actual times corresponding to the timestamp column), it displays the correct results including servername. Everything works in the php page's results except for the servername. I feel like it's right in front of my face and that's why I can't see it lol. Any help would be greatly appreciated. Thanks in advance =) My code... $query = "SELECT servername, COUNT(steps) FROM monitoring WHERE steps LIKE 'iisreset' AND timestamp <= '$_POST[time2]' AND timestamp >= '$_POST[time1]' GROUP BY servername ORDER BY COUNT(*) DESC LIMIT 10"; $result = mysql_query($query) or die(mysql_error()); # display column titles echo ""; echo "Count"; echo "Server Name"; echo ""; #display results while($i = mysql_fetch_row($result)) { echo "", $i[COUNT('steps')], ""; echo "", $i[servername] ,""; } echo ""; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php