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
Re: [PHP] php and mysql date mapping question
Dave Goodchild wrote: > Hi all, I am in the process of creating a national events directory where > people can enter their events (car boot sales, evening classes etc) and > specify whether those events are one-ff events or repeating (daily, weekly > etc) affairs and people can search for those events by postcode, date > range, > category etc. > > I have a table containing all dates between Oct 1 2006 and 2030, including Dave, if you are starting a calendar/event DB with a table full of dates something is probably wrong. you only need to store dates for actual events (in theory). > leap years etc. I am pretty new to relational design so here's my question: > > I have an events table and a dates table. As an event can happen on many > dates and a date can hold many events, I created an intermediary table > called dates_events to express that many-to-many relationship. The data > entry works like a dream as does the search. > > However, the dates_events table is growing quite large (200,000 mapped > relationships for 300+ test events), but the logic I used seemed clear. > When > the system goes live, allowing for a sweeper script that removes outdated > mappings from all three tables, I estimate that this mapping table may grow > to 2-3 million records at least. asuming you tables are correctly indexes and the relations are correctly defined record count is not the limiting factor at all. it does sound like you have one table too many. a one to many relationship between an events table and a dates table should suffice. then again your denormalized design may allow for much faster data retrieval, in which case stick with it :-) only one way to find out though. > > Does this sound flawed, and will mysql handle this kind of data volume? yup :-) use InnoDB as the storage format and even the 4Gig limit is history. > Anyone have any experience building a similar system. I am happy to use > this > method for the initial test run but may re-engineer it before we go > national > if suggestions lead me that way. > > I am unable to release the URL as yet. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php and mysql date mapping question
Hi all, I am in the process of creating a national events directory where people can enter their events (car boot sales, evening classes etc) and specify whether those events are one-ff events or repeating (daily, weekly etc) affairs and people can search for those events by postcode, date range, category etc. I have a table containing all dates between Oct 1 2006 and 2030, including leap years etc. I am pretty new to relational design so here's my question: I have an events table and a dates table. As an event can happen on many dates and a date can hold many events, I created an intermediary table called dates_events to express that many-to-many relationship. The data entry works like a dream as does the search. However, the dates_events table is growing quite large (200,000 mapped relationships for 300+ test events), but the logic I used seemed clear. When the system goes live, allowing for a sweeper script that removes outdated mappings from all three tables, I estimate that this mapping table may grow to 2-3 million records at least. Does this sound flawed, and will mysql handle this kind of data volume? Anyone have any experience building a similar system. I am happy to use this method for the initial test run but may re-engineer it before we go national if suggestions lead me that way. I am unable to release the URL as yet. -- http://www.web-buddha.co.uk
Re: [PHP] PHP and mySQL dates
On Wed, September 13, 2006 5:56 am, Dave Goodchild wrote: > Hi all. I am building an online events registry and have mapped out > all the > dates between Oct 1 2006 and Dec 31 2030, stored in the database as > timestamps incremented by 86400 to give daily slots. I have output the > values using the php date function and all is well. Users can enter > either > one-off or regular events, and I am using a mapping table to tie > events to > dates as they comprise a many-to-many relationship. If I'm reading this correctly, you've created a table of every single date, just to provide a JOIN table of massive proportions? That's... Not Good (tm) almost for sure... > I am struggling with some date conversions, however. When a user > enters a > single event for example, the data is entered into the events table, > the > inserted id captured, and then the system will look for the relevant > record > in the dates table, and eventually enter the event id and date id into > the > mapping table for later joins during the search process. Now it sounds like you are inserting even MORE entries into another table to make an even more confusing JOIN... > To do this, I call: > > $date_string = > mktime(0,0,0,$_SESSION['month],$_SESSION['day'],$_SESSION['year']) > > to assemble a timestamp from the supplied user data, and now I need to > look > for the matching date in the dates table. My problem is in converting > between UNIX and mySQL timestamp values. My first attempt to match > used this > (query extract): > > "SELECT id FROM dates WHERE FROM_UNIXTIME($date_string) = date" "SELECT id FROM dates WHERE date = '$month/$day/$year'" has always worked for me... If date is a timestamp or datetime, you have to convert THAT to a date, so that the hours:minutes:seconds don't mess you up. You're making all of this way too hard ... :-) Re-think the concept of having a row for every possible day. Just make sure all your tests for date equality are using the same type of data -- DATE, not DATETIME, TIMESTAMP, etc. -- 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
Re: [PHP] PHP and mySQL dates
Good luck with that. > -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
RE: [PHP] PHP and mySQL dates
No problem, now I will go and make my girlfriend happy :) -Original Message- From: Dave Goodchild [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 13, 2006 6:27 PM To: Peter Lauri Cc: PHP General Subject: Re: [PHP] PHP and mySQL dates Thanks. I have been so up close and personal with this that I can't see the wood for the trees. Of course, so obvious. Thank you - you have made me very happy. > > -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL dates
Thanks. I have been so up close and personal with this that I can't see the wood for the trees. Of course, so obvious. Thank you - you have made me very happy. -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
RE: [PHP] PHP and mySQL dates
[snip] Hi all. I am building an online events registry and have mapped out all the dates between Oct 1 2006 and Dec 31 2030, stored in the database as timestamps incremented by 86400 to give daily slots. [/snip] I do not really understand the purpose of mapping all dates between Oct 1 2006 and Dec 31 2030 and store them into a database as a timestamp. First of all, a date is a date, not a timestamp. A timestamp is date and time together. Why don't you just save the events with the date as DATE format and then compare them with CURDATE() or similar. Or just with "$_SESSION[year]- "$_SESSION[month]- "$_SESSION[day]" Just some thoughts. /Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and mySQL dates
Hi all. I am building an online events registry and have mapped out all the dates between Oct 1 2006 and Dec 31 2030, stored in the database as timestamps incremented by 86400 to give daily slots. I have output the values using the php date function and all is well. Users can enter either one-off or regular events, and I am using a mapping table to tie events to dates as they comprise a many-to-many relationship. I am struggling with some date conversions, however. When a user enters a single event for example, the data is entered into the events table, the inserted id captured, and then the system will look for the relevant record in the dates table, and eventually enter the event id and date id into the mapping table for later joins during the search process. To do this, I call: $date_string = mktime(0,0,0,$_SESSION['month],$_SESSION['day'],$_SESSION['year']) to assemble a timestamp from the supplied user data, and now I need to look for the matching date in the dates table. My problem is in converting between UNIX and mySQL timestamp values. My first attempt to match used this (query extract): "SELECT id FROM dates WHERE FROM_UNIXTIME($date_string) = date" then "SELECT id FROM dates WHERE UNIX_TIMESTAMP(date) = $date_string" neither is working. Am I making some fundamental error here or missing something? Any help appreciated! -- http://www.web-buddha.co.uk http://www.projectkarma.co.uk
Re: [PHP] PHP and mySQL getting smashed...
On Wed, May 17, 2006 6:55 am, Russell Jones wrote: > I have a site that is getting 30K+ traffic daily and it is smashing > mySQL - > any ideas on what to do to make the mysql connections more efficient, > or > anything in general. No bandwidth issue here, just the server getting > killed. It depends on the application. For something with many reads and fewer writes like a forum or basic, if busy, e-commerce you'd consider setting up MySQL replication with one master for WRITE operations and multiple slaves for SELECT operations. For something with a high write/read ratio such as eBay, that would be a wildly-unsuitable solution. Your best bet is to ask the MySQL folks, honestly, since it's unlikely that anything in PHP is going to be "the answer" to this one. If you have RAM to spare, you could: Configure /etc/my.cnf to have N + X connections Use http://php.net/mysql_pconnect N would be the number of Apache Max children X would be a "few" spare connections so that, if, say, you NEED to use shell 'mysql' monitor to DO something, the fact that ALL N connections are taken by Apache, won't lock you out. There are significant RAM issues with pconnect, as well as some bugs in various versions of PHP/MySQL that make this answer a no-go. Tread carefully. But it's at least an on-topic answer, even if an incomplete and maybe downright bad answer. -- 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
Re: [PHP] PHP and mySQL getting smashed...
Jay Blanchard wrote: [snip] I have a site that is getting 30K+ traffic daily and it is smashing mySQL - any ideas on what to do to make the mysql connections more efficient, or anything in general. No bandwidth issue here, just the server getting killed. [/snip] Without seeing any code or table information my bet would be that none of your tables are indexed properly. and/or that the OP is using some killing JOINS in his queries - these often have a detremental effect regardless of indexes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL getting smashed...
On 17/05/06, Dave Goodchild <[EMAIL PROTECTED]> wrote: I have a site that is getting 30K+ traffic daily and it is smashing mySQL - > any ideas on what to do to make the mysql connections more efficient, or > anything in general. No bandwidth issue here, just the server getting > killed. > > ...I may be wrong but using persistent connections (mysql_pconnect) may help. Also, optimise your tables and use the explain command to see how efficient your queries are. And caching things that don't need to looked up form the database right now. Even the fastest server in the world would wilt under a slashdotting, if it had to do a dozen big queries for every page display. Meanwhile a Pentium3 with a decent network can serve hundreds of requests a second of a few static pages. Alister -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and mySQL getting smashed...
[snip] I have a site that is getting 30K+ traffic daily and it is smashing mySQL - any ideas on what to do to make the mysql connections more efficient, or anything in general. No bandwidth issue here, just the server getting killed. [/snip] Without seeing any code or table information my bet would be that none of your tables are indexed properly. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL getting smashed...
perhaps post some code so we can look at how you doing your queries... HTH Angelo Zanetti Z Logic www.zlogic.co.za [c] +27 72 441 3355 [t] +27 21 469 1052 [f] +27 86 681 5885 Dave Goodchild wrote: I have a site that is getting 30K+ traffic daily and it is smashing mySQL - any ideas on what to do to make the mysql connections more efficient, or anything in general. No bandwidth issue here, just the server getting killed. ...I may be wrong but using persistent connections (mysql_pconnect) may help. Also, optimise your tables and use the explain command to see how efficient your queries are. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL getting smashed...
I have a site that is getting 30K+ traffic daily and it is smashing mySQL - any ideas on what to do to make the mysql connections more efficient, or anything in general. No bandwidth issue here, just the server getting killed. ...I may be wrong but using persistent connections (mysql_pconnect) may help. Also, optimise your tables and use the explain command to see how efficient your queries are. -- http://www.web-buddha.co.uk dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css) look out for project karma, our new venture, coming soon!
[PHP] PHP and mySQL getting smashed...
I have a site that is getting 30K+ traffic daily and it is smashing mySQL - any ideas on what to do to make the mysql connections more efficient, or anything in general. No bandwidth issue here, just the server getting killed. Thanks
Re: [PHP] PHP and MySQL and resouce limits
On Wed, July 20, 2005 5:22 pm, John Hinton said: > I don't get it... I have been upping my memory limit for PHP. 32megs > now... and am making calls to a database on a different server. I see > the loads run up on the other server as it cruches the numbers.. and PHP > is in the process of creating a single little page with about 40 numbers > on it, from these returns. Now, I do know I'm crunching a LOT of data in > this instance, but it seems like MySQL is doing the work and that PHP > shouldn't be hitting 32 my 32meg wall. Running the same query on a > smaller dataset doesn't hit this limit, so I know it's not a function of > the PHP code itself. > > So, I must be missing something, why is PHP somehow tied to the work > MySQL is doing? As in memory usage seems that MySQL should be simply > sending PHP the returns on its commands... hm Print out the query you are sending off to MySQL. Inspect it carefully. Use the mysql monitor to run it. Can MySQL, without PHP in the picture, run that query in practical time/memory constraints? How many rows does it actually return? How much data in each row? Dollars to doughnuts sez your query isn't doing what you think it's doing, and it's returning *WAY* more rows than you think, and poor PHP is trying to process them all... -- 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
Re: [PHP] PHP and MySQL and resouce limits
John Hinton wrote: I don't get it... I have been upping my memory limit for PHP. 32megs now... and am making calls to a database on a different server. I see the loads run up on the other server as it cruches the numbers.. and PHP is in the process of creating a single little page with about 40 numbers on it, from these returns. Now, I do know I'm crunching a LOT of data in this instance, but it seems like MySQL is doing the work and that PHP shouldn't be hitting 32 my 32meg wall. Running the same query on a smaller dataset doesn't hit this limit, so I know it's not a function of the PHP code itself. So, I must be missing something, why is PHP somehow tied to the work MySQL is doing? As in memory usage seems that MySQL should be simply sending PHP the returns on its commands... hm Thanks, John Hinton Are you sure your query is correct? This happens to me sometimes if the query is rather crazy... Matt Darby -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL and resouce limits
I don't get it... I have been upping my memory limit for PHP. 32megs now... and am making calls to a database on a different server. I see the loads run up on the other server as it cruches the numbers.. and PHP is in the process of creating a single little page with about 40 numbers on it, from these returns. Now, I do know I'm crunching a LOT of data in this instance, but it seems like MySQL is doing the work and that PHP shouldn't be hitting 32 my 32meg wall. Running the same query on a smaller dataset doesn't hit this limit, so I know it's not a function of the PHP code itself. So, I must be missing something, why is PHP somehow tied to the work MySQL is doing? As in memory usage seems that MySQL should be simply sending PHP the returns on its commands... hm Thanks, John Hinton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL Installation on Apache for Windows
Does anyone know how to get PHP to detect MySQL after it has been installed and is running on an Apache 1.3.1 server for Windows? Any help would be greatly appreciated.
RE: [PHP] php and mysql help
[EMAIL PROTECTED] (Jay Blanchard) wrote in news:[EMAIL PROTECTED]: > Why are you sending this to me? You're at Stanford, you can probably > figure out the unsubscribe link and stuff > > -Original Message- > From: David A. Stevens [mailto:[EMAIL PROTECTED] > Sent: Friday, April 16, 2004 12:41 PM > To: Jay Blanchard > Subject: RE: [PHP] php and mysql help > > > Please remove my address from any future correspondence about PHP. > Jay, you are confusing persons at a university with persons who may have a Clue [TM] David (also recipient of this message) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php and mysql help
Why are you sending this to me? You're at Stanford, you can probably figure out the unsubscribe link and stuff -Original Message- From: David A. Stevens [mailto:[EMAIL PROTECTED] Sent: Friday, April 16, 2004 12:41 PM To: Jay Blanchard Subject: RE: [PHP] php and mysql help Please remove my address from any future correspondence about PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php and mysql help
[snip] Hello i need help with mysql_create_db i found the solution once but cant remember what it was if someone could tell me the proper way to create a database with php and mysql i would be greatly thankfull. Thank you. [/snip] http://www.php.net/mysql_create_db You're welcome. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php and mysql help
* Thus wrote webmaster ([EMAIL PROTECTED]): > Hello i need help with mysql_create_db i found the solution once but cant remember > what it was if someone could tell me the proper way to create a database with php > and mysql i would be greatly thankfull. You just need to issue a create database statement passed to mysql_query() mysql_create_db() is depricated and isn't available in php that is compiled with the mysql4 client libraries. Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php and mysql help
Hello i need help with mysql_create_db i found the solution once but cant remember what it was if someone could tell me the proper way to create a database with php and mysql i would be greatly thankfull. Thank you.
Re: [PHP] PHP and MySQL date
If you need to store both date and time, there are several ways to accomplish this. MySQL has built-in date/timestamp options, but those long strings would need to be converted for be human readable. The option I use most is telling PHP what format I want to use and entering it into the database as a variable character (VARCHAR) field. $Today = date((Y-m-d H:i),mktime()); Returns: 2003-12-15 18:20 See the PHP help file for mktime() and date() Jim www.websitemanagers.net - Original Message - From: "Cesar Aracena" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, December 15, 2003 5:23 PM Subject: [PHP] PHP and MySQL date | Hi all, | | I'm making a site and need some tables from wich I can extract date, time | and/or date/time later with PHP and I neved had very clear the way the | possible formats work with each other so my question is what is the best (or | recommended) method to store dates and/or times in a MySQL DB for PHP to | work later? | | Thanks in advanced, | ___ | Cesar L. Aracena | Commercial Manager / Developer | ICAAM Web Solutions | 2K GROUP | Neuquen, Argentina | Tel: +54.299.4774532 | Cel: +54.299.6356688 | E-mail: [EMAIL PROTECTED] | | -- | -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL date
Hi all, I'm making a site and need some tables from wich I can extract date, time and/or date/time later with PHP and I neved had very clear the way the possible formats work with each other so my question is what is the best (or recommended) method to store dates and/or times in a MySQL DB for PHP to work later? Thanks in advanced, ___ Cesar L. Aracena Commercial Manager / Developer ICAAM Web Solutions 2K GROUP Neuquen, Argentina Tel: +54.299.4774532 Cel: +54.299.6356688 E-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL problem, please help
[snip] A query in mysql become with STATE set to STATISTICS and all queries after this query are LOCKED.What is the decision please. [/snip] The decision is to ask for a better description if possible, along with some of the suspected code. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL problem, please help
hi folks, A query in mysql become with STATE set to STATISTICS and all queries after this query are LOCKED. What is the decision please. Best Regards Bogomil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MYSQL don't shake hands
From: "Frank Tudor" <[EMAIL PROTECTED]> > The problem I am having is that when I try to pass values to the > database the php fails. > > I think I have singled it down to the connection string but I am > not sure. [snip] > function db_connect() { >global $dbhost, $dbusername, $dbuserpassword, > $default_dbname; >global $MYSQL_ERRNO, $MYSQL_ERROR; > >$link_id = mysql_connect($dbhost, $dbusername, > $dbuserpassword); >if(!$link_id) { > $MYSQL_ERRNO = 0; > $MYSQL_ERROR = "Connection failed to the host $dbhost."; > return 0; >} >else if(empty($dbname) && !mysql_select_db($default_dbname)) > { > $MYSQL_ERRNO = mysql_errno(); > $MYSQL_ERROR = mysql_error(); > return 0; >} >else return $link_id; > } > > function sql_error() { >global $MYSQL_ERRNO, $MYSQL_ERROR; > >if(empty($MYSQL_ERROR)) { > $MYSQL_ERRNO = mysql_errno(); > $MYSQL_ERROR = mysql_error(); >} >return "$MYSQL_ERRNO: $MYSQL_ERROR"; > } > ?> > > My php sample code::: > > //db_connect.php > include "common_db.inc"; > error_reporting(0); Take this out or set it to E_ALL while debugging. > $link_id = db_connect(); > if(!$link_id) die(sql_error()); Use $link_id = db_connect() or die(sql_error()); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MYSQL don't shake hands
Guys, I have moved from a foxserv(apache, php, mysql, all in one install tool) windows test environment to a Linux apache php mysql setup specifically mandrake linux production server. The problem I am having is that when I try to pass values to the database the php fails. I think I have singled it down to the connection string but I am not sure. basically, I have tested the sample code in the book 'beginning php' by (wrox). I have made no changes. I think that the dbhost is the problem. when I look at the phpinfo page it shows me not localhost but a 'name.com' so I try $dbhost = 'name.com'; and then i also try $dbhost = 'localhost'; and neither seem to work. Can anyone tell me what I'm doing wrong? Here is my sample code: My db connect include file:: My php sample code::: "; ?> My error is a white screen and this is simple code out of the book. Could it be my dbhost is incorrect. I checked my services and Mysql is running. Apache running and parsing other php pages that don't do a db connect so I'm pretty sure it's the db connect stuff. Thanks, Frank __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MYSQL
Please help I am going quite mad. I am trying to install PHP-4. I purchased the PHP and MySQL web development book to this end. I am running under Win2000 and IIS. I downloaded from the PHP web site to get the latest versions. I first tried to do a manual installation but this appeared to fail so after trying many things as detailed in the book I gave up and after erasing all I had installed, used the installer program (advanced). This is giving me exactly the same results. Namely:- a script in the root directory (local Host) when viewed gives a copy of my script code and nothing else. I have checked the default DBase entry is correct (PHP/PHP.exe). The exec file Iuser_home and PHP4ts.dll has executable set. I have started and stopped ISS many times. The PHP.INI file is in the PHP directory. I have not modified it in any way (Yet). Here is the script for what it's worth. IS IT WORKING? and the result is IS IT WORKING? NO ERROR MESSAGES. I am using Internet explorer and incidentally all my ASP still work normally. I know I have missed something but any pointers as to what would be much appreciated. Thanks BOBG -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and Mysql Limit
On Wed, 2 Jul 2003, Jeff Harris wrote: > Then, once you've done it enough times, $start = $count = 178. > [code] > while ($start <= $count) { > // when $start = $count = 178, you won't retrive any data > [/code] The recordset would not alway contain an even number of records resulting in 10 records per page. It may contain something like 1027 records which should then produce 103 pages. 102 pages each with 10 records and one page of only 7 records. Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and Mysql Limit
Yes, the next page of results would start at #18. The page number only increments by 1. Ed On Wed, 2 Jul 2003, Chris Sherwood wrote: > It looks like your adding 10 to 8 thus getting 18... of course I maybe > looking at this wrong > > - Original Message - > From: <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, July 02, 2003 9:23 AM > Subject: [PHP] PHP and Mysql Limit > > > > > > I've created a script that reads a sorted mysql query and outputs specific > > results into text files defined by the start and limit of mysql. The > > database holds 178 records. I want to start my output on #9 with 10 > > records per page. Should leave me with 17 equal pages right? > > > > $count = 178 > > $start = 8; (Mysql starts at record 0) > > $per_page = 10; > > $page = 1; > > > > while ($start <= $count) { > > > > $fp = fopen("Page$page.txt", "w"); > > > > mysql_connect ($host, $user, $pass); > > > > mysql_select_db ($database); > > > > $result = mysql_query ("SELECT * FROM internal_listings, agents WHERE > > internal_listings.agent = agents.name AND category = 'Standard' ORDER by > > area,price LIMIT $start, $per_page"); > > > > if ($row = mysql_fetch_array($result)) { > > > > do { > > > > ##misc ouput to file $fp for 10 records in query > > > > } > > > > while($row = mysql_fetch_array($result)); > > > > } > > > > fclose($fp); > > > > mysql_close(); > > > > $start = $start + $per_page; > > > > $page++; > > > > } > > > > > > When I run the script outlined above I get 18 pages. Page number 18 is > > blank as it should be as there should be no more listings to output to a > > text file but why is there a page number 18 to begin with? It should end > > with page number 17. > > > > Thanks in advance for any insight, > > > > Ed > > > > > > > > -- > > 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and Mysql Limit
|- Original Message - |From: <[EMAIL PROTECTED]> |To: <[EMAIL PROTECTED]> |Sent: Wednesday, July 02, 2003 9:23 AM |Subject: [PHP] PHP and Mysql Limit | | |> |> I've created a script that reads a sorted mysql query and outputs specific |> results into text files defined by the start and limit of mysql. The |> database holds 178 records. I want to start my output on #9 with 10 |> records per page. Should leave me with 17 equal pages right? |> |> $count = 178 |> $start = 8; (Mysql starts at record 0) |> $per_page = 10; |> $page = 1; |> |> while ($start <= $count) { |> |> $fp = fopen("Page$page.txt", "w"); [snip] On Jul 2, 2003, "Chris Sherwood" claimed that: |It looks like your adding 10 to 8 thus getting 18... of course I maybe |looking at this wrong | Then, once you've done it enough times, $start = $count = 178. [code] while ($start <= $count) { // when $start = $count = 178, you won't retrive any data [/code] I would probably also move as much of the mysql_connect as possible to outside the loop. It only needs to be done once. -- Registered Linux user #304026. "lynx -source http://jharris.rallycentral.us/jharris.asc | gpg --import" Key fingerprint = 52FC 20BD 025A 8C13 5FC6 68C6 9CF9 46C2 B089 0FED -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and Mysql Limit
It looks like your adding 10 to 8 thus getting 18... of course I maybe looking at this wrong - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, July 02, 2003 9:23 AM Subject: [PHP] PHP and Mysql Limit > > I've created a script that reads a sorted mysql query and outputs specific > results into text files defined by the start and limit of mysql. The > database holds 178 records. I want to start my output on #9 with 10 > records per page. Should leave me with 17 equal pages right? > > $count = 178 > $start = 8; (Mysql starts at record 0) > $per_page = 10; > $page = 1; > > while ($start <= $count) { > > $fp = fopen("Page$page.txt", "w"); > > mysql_connect ($host, $user, $pass); > > mysql_select_db ($database); > > $result = mysql_query ("SELECT * FROM internal_listings, agents WHERE > internal_listings.agent = agents.name AND category = 'Standard' ORDER by > area,price LIMIT $start, $per_page"); > > if ($row = mysql_fetch_array($result)) { > > do { > > ##misc ouput to file $fp for 10 records in query > > } > > while($row = mysql_fetch_array($result)); > > } > > fclose($fp); > > mysql_close(); > > $start = $start + $per_page; > > $page++; > > } > > > When I run the script outlined above I get 18 pages. Page number 18 is > blank as it should be as there should be no more listings to output to a > text file but why is there a page number 18 to begin with? It should end > with page number 17. > > Thanks in advance for any insight, > > Ed > > > > -- > 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] PHP and Mysql Limit
I've created a script that reads a sorted mysql query and outputs specific results into text files defined by the start and limit of mysql. The database holds 178 records. I want to start my output on #9 with 10 records per page. Should leave me with 17 equal pages right? $count = 178 $start = 8; (Mysql starts at record 0) $per_page = 10; $page = 1; while ($start <= $count) { $fp = fopen("Page$page.txt", "w"); mysql_connect ($host, $user, $pass); mysql_select_db ($database); $result = mysql_query ("SELECT * FROM internal_listings, agents WHERE internal_listings.agent = agents.name AND category = 'Standard' ORDER by area,price LIMIT $start, $per_page"); if ($row = mysql_fetch_array($result)) { do { ##misc ouput to file $fp for 10 records in query } while($row = mysql_fetch_array($result)); } fclose($fp); mysql_close(); $start = $start + $per_page; $page++; } When I run the script outlined above I get 18 pages. Page number 18 is blank as it should be as there should be no more listings to output to a text file but why is there a page number 18 to begin with? It should end with page number 17. Thanks in advance for any insight, Ed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MYSQL record locking
> We have a multi-user database we use for telemarketing. It is used across > the internet. All the pages are PHP, I am trying to lock or keep other > users > from accessing the same record, so that they do not call the same lead. > For > example, the user selects a zip code to work from and then a lead pops up, > once the lead has popped up on the callers screen, I don t want that same > lead to pop up on anyone else's screen. So I am not sure if I need to lock > the row, or if there is a better way of doing it, since the web browser is > stateless. Please any help you can provide would be great, because I have > searched the net and haven t found much information. Thank you. Just add an extra column to keep track of whether the "lead" is being viewed or not. Set it to 1 when someone views it and then only select leads where the column is zero. You'll need a system to control setting it back to zero if need be or "timing" it out after so long... ---John W. Holmes... Amazon Wishlist: http://www.amazon.com/o/registry/3BEXC84AB3A5E PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MYSQL record locking
We have a multi-user database we use for telemarketing. It is used across the internet. All the pages are PHP, I am trying to lock or keep other users from accessing the same record, so that they do not call the same lead. For example, the user selects a zip code to work from and then a lead pops up, once the lead has popped up on the callers screen, I don t want that same lead to pop up on anyone else's screen. So I am not sure if I need to lock the row, or if there is a better way of doing it, since the web browser is stateless. Please any help you can provide would be great, because I have searched the net and haven t found much information. Thank you. -Jason -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php and mysql
I have a db with events in it. i would like to pull the events out via php, but i would like them to be ordered by month number (1-12). When I do this (Select blah blah From blah Order By Month_Start ASC) it orders the months by number, but it starts with october (month 10) I am pretty sure it is doing this because I have no events until april (month 4). So how can i get it to order the months by their numbers starting with january (1) and going to december (12) even if I do not have events until april (4)? _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL Full Text Search Problem
Since you are using fulltext search it is going to look for the exact spelling of what you pass in. If you wanted to get matches with Chris then you will want to modify your query by using LIKE. In version 4.0.1 of mysql you can do fulltext search in boolean mode. http://www.mysql.com/doc/en/Fulltext_Search.html (bottom of page). -- Ray On Thu, 2003-03-13 at 23:39, Charles Kline wrote: > Hi all, > > My first try at MySQL Full Text Search and it is not behaving ;) > > Here is what I have for my query string: > > $sql = "SELECT id, concat(fname, ' ', lname, ' ', degree1) as name". > " FROM tbl_personnel WHERE MATCH (fname,lname) AGAINST ('" . > $attributes['searchstring'] . "')"; > > > This works pretty good. The only problem is it only works if there is > an exact match for either the first name (fname) or last name. For > example. In tbl_personnel there are 5 people with the first name > Christine. > > If I pass Chris to this query in $attributes['searchstring'] I get 0 > results. If I pass Christine I get all 5. > > What do I need to modify to make this work? > > Thanks, > Charles > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL Full Text Search Problem
Hi all, My first try at MySQL Full Text Search and it is not behaving ;) Here is what I have for my query string: $sql = "SELECT id, concat(fname, ' ', lname, ' ', degree1) as name". " FROM tbl_personnel WHERE MATCH (fname,lname) AGAINST ('" . $attributes['searchstring'] . "')"; This works pretty good. The only problem is it only works if there is an exact match for either the first name (fname) or last name. For example. In tbl_personnel there are 5 people with the first name Christine. If I pass Chris to this query in $attributes['searchstring'] I get 0 results. If I pass Christine I get all 5. What do I need to modify to make this work? Thanks, Charles -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] php and mysql
I'm not sure what you mean by cut the records at 1/4, if you mean only bringing back 1/4 of the rows you could use the LIMIT clause in your sql statement and give it a number of rows you want brought back. To sort alphabetically just use the order by command in SQL So your query would look like this SELECT * from Table order by column_name Limit 100 This will bring back 100 rows that are order by the column you specify. Kelly -Original Message- From: Tyler Durdin [mailto:[EMAIL PROTECTED]] Sent: February 20, 2003 10:45 AM To: [EMAIL PROTECTED] Subject: [PHP] php and mysql When using a php script to pull recorda from a db how can I cut the records at 1/4 of the total and arrange them alaphabetically according to a certain field? Thanks in advance. _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus -- 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] php and mysql
On Thu, 20 Feb 2003 17:44:51 +, you wrote: >When using a php script to pull recorda from a db how can I cut the records >at 1/4 of the total and arrange them alaphabetically according to a certain >field? Thanks in advance. http://www.mysql.com/doc/en/SELECT.html LIMIT and ORDER BY. This is really a MySQL question, not PHP. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php and mysql
When using a php script to pull recorda from a db how can I cut the records at 1/4 of the total and arrange them alaphabetically according to a certain field? Thanks in advance. _ MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL bug
I cant give you a solution, and I''m running on Linux. But I have pages were I do 6-7 queries on one page always using the same connection. Never had a problem with that. Mike *** REPLY SEPARATOR *** >I'm using PHP and MySQL to make my programs. But I think I discovered a bug >in PHP or in MySQL (I don't know!). > >--- >I don't know why is this? Because I'm used to do more than a query per >connection and this never happened! >I'm using Win 2k, Apache 2.0.43, MySQL 3.23.49-nt and PHP 4.3. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL bug
Dear Sirs, I'm using PHP and MySQL to make my programs. But I think I discovered a bug in PHP or in MySQL (I don't know!). In one of my files I have the following: MYSQL_CONNECT("localhost", "**user**", "**pass**"); mysql_select_db("be"); $r=MYSQL_QUERY("SELECT n,u,m,h FROM d WHERE id='$id'"); /* Some code including "mysql_num_rows" and "mysql_fetch_array($r, MYSQL_NUM)" And the another query: */ MYSQL_QUERY("UPDATE d SET h='$h' WHERE id='$id'"); /* i don't know why but this doesn't work! But if I close the connection and open another te query is done:*/ MYSQL_CLOSE(); MYSQL_CONNECT("localhost", "**user**", "**pass**"); mysql_select_db("be"); MYSQL_QUERY("UPDATE d SET h='$h' WHERE id='$id'"); --- I don't know why is this? Because I'm used to do more than a query per connection and this never happened! I'm using Win 2k, Apache 2.0.43, MySQL 3.23.49-nt and PHP 4.3. I hope you solve this, Nuno Lopes -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL queries
Does it work if you put quotes around the array keys as follows... echo $line['idn']; echo $line['total']; echo $line['idp']; echo $line['position']; echo $line['points']; Rich -Original Message- From: Beauford.2002 [mailto:[EMAIL PROTECTED]] Sent: 18 December 2002 20:28 To: PHP General Subject: [PHP] PHP and MySQL queries Hi, I am having a real problem with variables in PHP and trying to query my MySQL database. I have a form that a user inputs information and then that info is used to query my database, but it's not working. I don't get any errorrs and it appears every thing worked, but nothing gets displayed (see code below). I know the info is getting passed from the form as it appears correct in the address bar of my browser. The query below also works if I use the command line in MySQL and hard code the information. Any help is appreciated. http://etc/etc?FromTrade=TRUE&name=1&from=2 $query = "select tmanager.idn, tmanager.total, troster.idp, user, position, points from troster join treference join tmanager where tmanager.idn=treference.idn and treference.idp=troster.idp and tmanager.name like '$name' and troster.player like '$from'"; $results = mysql_query($query) or die("Query failed"); while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) { echo $line[idn]; echo $line[total]; echo $line[idp]; echo $line[position]; echo $line[points]; This just displays an empty page. So it appears the query found nothing, but like I said, it works from the command line and there should be one entry (see below). So I have to assume it is a problem with the variables. +-++-++--++ | idn | total | idp | user | position | points | +-++-++--++ | 1 | 746.75 | 2 | Trevor | F| 45.00 | +-++-++--++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL queries
So print out $query before you execute it and see what you're actually sending to MySQL. You're apparently sending a valid query, but it's not matching any rows... ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ > -Original Message- > From: Beauford.2002 [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, December 18, 2002 11:28 PM > To: PHP General > Subject: [PHP] PHP and MySQL queries > > Hi, > > I am having a real problem with variables in PHP and trying to query my > MySQL database. I have a form that a user inputs information and then that > info is used to query my database, but it's not working. I don't get any > errorrs and it appears every thing worked, but nothing gets displayed (see > code below). I know the info is getting passed from the form as it appears > correct in the address bar of my browser. The query below also works if I > use the command line in MySQL and hard code the information. > > Any help is appreciated. > > http://etc/etc?FromTrade=TRUE&name=1&from=2 > > $query = "select tmanager.idn, tmanager.total, troster.idp, user, > position, > points from troster join treference > join tmanager where tmanager.idn=treference.idn and > treference.idp=troster.idp and tmanager.name like '$name' and > troster.player like '$from'"; > > $results = mysql_query($query) or die("Query failed"); > > while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) { > > echo $line[idn]; > echo $line[total]; > echo $line[idp]; > echo $line[position]; > echo $line[points]; > > This just displays an empty page. So it appears the query found nothing, > but > like I said, it works from the command line and there should be one entry > (see below). So I have to assume it is a problem with the variables. > > +-++-++--++ > | idn | total | idp | user | position | points | > +-++-++--++ > | 1 | 746.75 | 2 | Trevor | F| 45.00 | > +-++-++--++ > > > > > -- > 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] PHP and MySQL queries
Hi, I am having a real problem with variables in PHP and trying to query my MySQL database. I have a form that a user inputs information and then that info is used to query my database, but it's not working. I don't get any errorrs and it appears every thing worked, but nothing gets displayed (see code below). I know the info is getting passed from the form as it appears correct in the address bar of my browser. The query below also works if I use the command line in MySQL and hard code the information. Any help is appreciated. http://etc/etc?FromTrade=TRUE&name=1&from=2 $query = "select tmanager.idn, tmanager.total, troster.idp, user, position, points from troster join treference join tmanager where tmanager.idn=treference.idn and treference.idp=troster.idp and tmanager.name like '$name' and troster.player like '$from'"; $results = mysql_query($query) or die("Query failed"); while ($line = mysql_fetch_array($results, MYSQL_ASSOC)) { echo $line[idn]; echo $line[total]; echo $line[idp]; echo $line[position]; echo $line[points]; This just displays an empty page. So it appears the query found nothing, but like I said, it works from the command line and there should be one entry (see below). So I have to assume it is a problem with the variables. +-++-++--++ | idn | total | idp | user | position | points | +-++-++--++ | 1 | 746.75 | 2 | Trevor | F| 45.00 | +-++-++--++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
On Thursday 12 December 2002 09:22, BABA Yoshihiko wrote: > Jason Wong wrote: > > Not sure why you're escaping the single quote. It's unnecessary -- and I > > suspect you mis-escaped $select as well. Any you can use this format, > > which IMHO, is a lot easier on the eyes: > > > > $sql = "INSERT INTO `guest` > > SET `title` = '$title', > > `first_name` = '$first_name', > > ..., > > ..., > > `last_visit` = NOW()"; > > Can you use SET with INSERT INTO? Is it MySQL grammer? Yes. It's something that I miss when using PostgreSQL. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I didn't get sophisticated -- I just got tired. But maybe that's what sophisticated is -- being tired. -- Rita Gain */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
Jason Wong wrote: Not sure why you're escaping the single quote. It's unnecessary -- and I suspect you mis-escaped $select as well. Any you can use this format, which IMHO, is a lot easier on the eyes: $sql = "INSERT INTO `guest` SET `title` = '$title', `first_name` = '$first_name', ..., ..., `last_visit` = NOW()"; Can you use SET with INSERT INTO? Is it MySQL grammer? -- BABA Yoshihiko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
Thanks Jason...that werked fine for me.. --pS On Wednesday, December 11, 2002, at 03:50 PM, Jason Wong wrote: On Thursday 12 December 2002 04:30, Pushpinder Singh Garcha wrote: Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK gives error unable to execute query $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; Not sure why you're escaping the single quote. It's unnecessary -- and I suspect you mis-escaped $select as well. Any you can use this format, which IMHO, is a lot easier on the eyes: $sql = "INSERT INTO `guest` SET `title` = '$title', `first_name` = '$first_name', ..., ..., `last_visit` = NOW()"; -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I had a lease on an OEDIPUS COMPLEX back in '81 ... */ -- 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] PHP and MySQL
On Thursday 12 December 2002 04:30, Pushpinder Singh Garcha wrote: > Hello, > > I am using PHP to create forms and then am entering the user input into > a MySQL DB > In the first query I am trying to select the values that the user > entered on the form > > THIS DOES NOT WERK gives error unable to execute query >$sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, > `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, > `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) > VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', > \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, > NOW());"; Not sure why you're escaping the single quote. It's unnecessary -- and I suspect you mis-escaped $select as well. Any you can use this format, which IMHO, is a lot easier on the eyes: $sql = "INSERT INTO `guest` SET `title` = '$title', `first_name` = '$first_name', ..., ..., `last_visit` = NOW()"; -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I had a lease on an OEDIPUS COMPLEX back in '81 ... */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
Numerous syntax errors produce your invalid query... 1) If you use double quotes to enclose the string, "INSERT..., then you do not have to delimit your single quotes. 2) You accidently delimit a variable at VALUES ('\$select 3) The SQL command its self does not need to end with a semi-colon. Fixed string.. $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('$select', '$f_name', '$l_name', '$login', '$password', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW())"; -Kevin - Original Message - From: "Pushpinder Singh Garcha" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 1:30 PM Subject: [PHP] PHP and MySQL Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK gives error unable to execute query $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; WHEN I TRY TO HARD CODE THE VALUES INTO THE MYSQL QUERY, IT WERKS FINE // $sql = 'INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES (\'gh\', \'ghdfghhgj\', \'hgddj\', \'ggfgfg\', \'hfgdj\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());'; Can somebody please tell me where I am going wrong..?? Many thanks Pushpinder Singh Garcha _ Web Architect T. Falcon Napier and Associates, Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
My guess is you don't have register_globals on. Replace each variable with $_POST['field_name'] or $_GET['field_name'] depending on what your form's method is. You could also turn register_globals on but that is a security risk I've heard. - Original Message - From: "Pushpinder Singh Garcha" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 3:30 PM Subject: [PHP] PHP and MySQL Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK gives error unable to execute query $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; WHEN I TRY TO HARD CODE THE VALUES INTO THE MYSQL QUERY, IT WERKS FINE // $sql = 'INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES (\'gh\', \'ghdfghhgj\', \'hgddj\', \'ggfgfg\', \'hfgdj\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());'; Can somebody please tell me where I am going wrong..?? Many thanks Pushpinder Singh Garcha _ Web Architect T. Falcon Napier and Associates, Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL
Hello, I am using PHP to create forms and then am entering the user input into a MySQL DB In the first query I am trying to select the values that the user entered on the form THIS DOES NOT WERK gives error unable to execute query $sql = "INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES ('\$select\', \'$f_name\', \'$l_name\', \'$login\', \'$password\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());"; WHEN I TRY TO HARD CODE THE VALUES INTO THE MYSQL QUERY, IT WERKS FINE // $sql = 'INSERT INTO `guest` (`title`, `first_name`, `last_name`, `login`, `password`, `passport_number`, `e_mail`, `question`, `answer`, `industry`, `job_title`, `state`, `city`, `company`, `last_visit`) VALUES (\'gh\', \'ghdfghhgj\', \'hgddj\', \'ggfgfg\', \'hfgdj\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NOW());'; Can somebody please tell me where I am going wrong..?? Many thanks Pushpinder Singh Garcha _ Web Architect T. Falcon Napier and Associates, Inc.
RE: [PHP] PHP and MySQL sorting using COUNT
Actually, using your original query and referring to $row['count(*)'] would work too. However, when using calculated fields I always use a column alias as Rich recommends - it makes things a lot clearer. -steve At 1:54 PM + 11/13/02, "Rich Gray" <[EMAIL PROTECTED]> wrote: try '... ,count(*) as count ...' then you should be able to reference it as $row['count'] HTH Rich -Original Message- From: [EMAIL PROTECTED] [mailto:ed@;home.homes2see.com] Sent: 13 November 2002 13:44 To: [EMAIL PROTECTED] Subject: [PHP] PHP and MySQL sorting using COUNT I'm sorting records using COUNT with the following mysql command $result = mysql_query ("SELECT company_name, agent_name, count(*) FROM $cur_listings GROUP BY company_name, agent_name"); Running this in MySQL does exactly what I need it to do but how do I echo the COUNT portion of the array? I know the company_name would be $row['company_name'] and agent_name is $row['agent_name']; Thanks, Ed Curtis -- ++ | Steve Edberg [EMAIL PROTECTED] | | University of California, Davis (530)754-9127 | | Programming/Database/SysAdmin http://pgfsun.ucdavis.edu/ | ++ | SETI@Home: 1001 Work units on 23 oct 2002 | | 3.152 years CPU time, 3.142 years SETI user... and STILL no aliens... | ++ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL sorting using COUNT
Hello, <[EMAIL PROTECTED]> wrote: > > I'm sorting records using COUNT with the following mysql command > > $result = mysql_query ("SELECT company_name, agent_name, count(*) FROM > $cur_listings GROUP BY company_name, agent_name"); > > Running this in MySQL does exactly what I need it to do but how do I echo > the COUNT portion of the array? I know the company_name would be > $row['company_name'] and agent_name is $row['agent_name']; You can find something about "aliases" here: http://www.mysql.com/doc/en/SELECT.html - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL sorting using COUNT
I'm sorting records using COUNT with the following mysql command $result = mysql_query ("SELECT company_name, agent_name, count(*) FROM $cur_listings GROUP BY company_name, agent_name"); Running this in MySQL does exactly what I need it to do but how do I echo the COUNT portion of the array? I know the company_name would be $row['company_name'] and agent_name is $row['agent_name']; Thanks, Ed Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
On Saturday 03 August 2002 04:13, Erich Kolb wrote: > Is there any way to speed up MySQL queries? 1) Use a faster computer 2) Read the mysql manual 3) Ask on the mysql list 4) Ask google -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* I left my WALLET in the BATHROOM!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL
-Original Message- here any way to speed up MySQL queries? -- Sure, ask for only the data you need. or halt your query when you have what you need. HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL
Is there any way to speed up MySQL queries? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL
> You do realise, you have just pasted your database connection details to > the world?! I gonna have to write an article on how to communicate > securely over the internet. (not just with PHP, but with the data you > communicate in the messages as well!!) Well not quite, she did post her username password but it's not like we're aware of the server IP she's using. Not to mention most people are competent enough now a days to properly restrict their MySQL servers to talk only with specific hosts and IPs. I think she's safe from anyone trying to maliciously abuse her MySQL server due to her post =) Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and MySQL
Hi, [..] > $user = "OMMITTED"; > $pass = "OMMITTED"; > $db = "Book Store1"; > $local = "OMMITED"; > $link = mysql_connect( "$local", $user, $pass ); [..] You do realise, you have just pasted your database connection details to the world?! I gonna have to write an article on how to communicate securely over the internet. (not just with PHP, but with the data you communicate in the messages as well!!) -- Dan Hardiker [[EMAIL PROTECTED]] ADAM Software & Systems Engineer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL
I just wanted to thank everyone for helping me with the script for my school project. But, of course I must esp. thank JODY, (the man!!). Go ahead Jody, eat up the glory! :) Renee Here is part of the script in its final form if anyone is interested: "; }
Re: [PHP] PHP and MySQL
On Thu, 16 May 2002, City Colleges of Chicago - Mannheim wrote: > > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10 > This wasn't your question, but... $i"; ?> miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL
Missed a spot =) > if( $booktitle AND "quantity" ){ I'm not certain if this if statement is accurate. I've never used a statement like this but from the looks of it the AND "quantity" part would always be true (assuming it parses it). This could be adding to your problem as well. I think you were aiming for something like if ($booktitle AND $quantity) { or how I do it (although it looks a bit messier) if (($booktitle) && ($quantity)) { Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and MySQL
> mysql_select_db( $db, $link ) > > or die ( "Couldn't open the $db: ".mysql_error() ); > > > if ($submit){ > > if( $booktitle AND "quantity" ){ > > $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE > booktitle='$booktitle' AND quantity=quantity"; > > } Easy enough =) You're not running the mysql query =) You're never sending a command to MySQL to tell it to execute the $sql statement if( $booktitle AND "quantity" ){ $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE booktitle='$booktitle' AND quantity=quantity"; mysql_query($sql); } Should do the trick. Or even cleaner if( $booktitle AND "quantity" ){ mysql_query("UPDATE Book2 SET stock ='$stock-quantity' WHERE booktitle='$booktitle' AND quantity=quantity"); } Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and MySQL
My program is no longer giving a parse error, but my database is not being updated (as far as the stock numbers are concerned). Any ideas??? I made the changes below per a few people on the list: Quantity of books: 1 2 3 4 5 6 7 8 9 10 The book you are ordering: Additional Message: "; } ?> Renee
RE: [PHP] PHP and mySQL
Actually, "elseif" and "else if" are both valid. J Craig Vincent wrote: > > }else if(!$submit){ > > > Acthough you didn't show 75 lines of code my guess would be your problem > lies here. The else and the if shouldn't have a space between them. > > } elseif(!$submit){ > > See how that works for you =) > > Sincerely, > > Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and mySQL
> You are missing a " before $booktitle. > old:booktitle=$booktitle AND quantity=quantity"; > new:booktitle="$booktitle AND quantity=quantity"; So you're saying $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE booktitle="$booktitle AND quantity=quantity"; is the correct SQL statement? Me thinks you would be mistaken. That's another painful parsing error waiting to happen. You are partially right though, quotes were missing from the statement (although the missing quotes would have no effect on PHP running the code, just the MySQL server trying to execute the query). Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP and mySQL
}else if(!$submit){ Acthough you didn't show 75 lines of code my guess would be your problem lies here. The else and the if shouldn't have a space between them. } elseif(!$submit){ See how that works for you =) Also your SQL is faulty $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE booktitle=$booktitle AND quantity=quantity"; $booktitle I'm 99.9% certain is not an integer. Therefore you need single quotes around it. And the condition quantity=quantity is a tad redundant since quantity would always equal itself =) I suspect you meant quantity=$quantity (again if it's not an integer you need single quotesheck put single quotes around it anyways...it doesn't hurt) $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE booktitle='$booktitle' AND quantity='$quantity'"; Sincerely, Craig Vincent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL
You are missing a " before $booktitle. old:booktitle=$booktitle AND quantity=quantity"; new:booktitle="$booktitle AND quantity=quantity"; JJ Harrison [EMAIL PROTECTED] www.tececo.com - Original Message - From: "Jason Wong" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, May 14, 2002 8:51 PM Subject: Re: [PHP] PHP and mySQL > On Tuesday 14 May 2002 18:38, City Colleges of Chicago - Mannheim wrote: > > I am getting a parse error on line 75. I am trying to say: > > > > if there is a booktitle and a quantity chosen, then go to that booktitle > > and adjust the quantity in the database. > > if ($booktitle AND $quantity) { ... > > > > $user = "adminer"; > > $pass = "hoosiers"; > > $db = "Book Store1"; > > $local = "jolinux"; > > $link = mysql_connect( "$local", $user, $pass ); > > if (! $link ) > >die ( "Couldn't open the database" ); > > mysql_select_db( $db, $link ) > > or die ( "Couldn't open the $db: ".mysql_error() ); > > > > if ($submit){ > > if( $booktitle, "quantity" ){ > > $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE > > booktitle=$booktitle AND quantity=quantity"; > > } > > // $result = mysql_query($mysql); > > }else if(!$submit){ > > echo "Your order has not been placed."; > > } > > ?> > > > > > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > "All we are given is possibilities -- to make ourselves one thing or another." > -- Ortega y Gasset > */ > > > -- > 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] PHP and mySQL
On Tuesday 14 May 2002 18:38, City Colleges of Chicago - Mannheim wrote: > I am getting a parse error on line 75. I am trying to say: > > if there is a booktitle and a quantity chosen, then go to that booktitle > and adjust the quantity in the database. if ($booktitle AND $quantity) { ... > $user = "adminer"; > $pass = "hoosiers"; > $db = "Book Store1"; > $local = "jolinux"; > $link = mysql_connect( "$local", $user, $pass ); > if (! $link ) >die ( "Couldn't open the database" ); > mysql_select_db( $db, $link ) > or die ( "Couldn't open the $db: ".mysql_error() ); > > if ($submit){ > if( $booktitle, "quantity" ){ > $sql = "UPDATE Book2 SET stock ='$stock-quantity' WHERE > booktitle=$booktitle AND quantity=quantity"; > } > // $result = mysql_query($mysql); > }else if(!$submit){ > echo "Your order has not been placed."; > } > ?> > > -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* "All we are given is possibilities -- to make ourselves one thing or another." -- Ortega y Gasset */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP and mySQL
I am getting a parse error on line 75. I am trying to say: if there is a booktitle and a quantity chosen, then go to that booktitle and adjust the quantity in the database. Thanks! Renee "; } ?>
[PHP] PHP and mySQL
I am a student working on a practicum problem. I have a mySQL database that contains the books, their title, and how many are in stock. When a person orders one of the books, I want the stock to be adjusted by how many, quantity, that they chose when the submit button is clicked. The scripts are written in PHP. Here is part of my code: The book you are ordering: Additional Message: "; } ?>
Re: [PHP] PHP and mySQL...
On Fri, 5 Apr 2002, Anthony Ritter wrote: > Any idea what the cost is for the ISP to install mySQL on their end so that > I can utilize my database that I've set up on localhost? MySQL is free for that sort of usage, so it only costs their time. If they've done it before, it takes about 5 minutes from beginning the download to standing up and clapping yourself on the back for a job well done - in a unix environment, anyway. Not sure what's involved on the Windows side but I expect it's slightly more complicated. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL...
Cyberskydive wrote in message: > Since you didnt make it clear, do you even have MySql and php on your > server? Are you looking to just move your data or looking to get php & mysql > installed on the server as well? (SERVER = production site, not localhost) ... Yes. I have mySQL and PHP on my end - localhost - for development. I spoke with my ISP and they do not have mySQL installed on their end. They use MS SQL Server. Any idea what the cost is for the ISP to install mySQL on their end so that I can utilize my database that I've set up on localhost? Thank you. Tony Ritter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL...
Since you didnt make it clear, do you even have MySql and php on your server? Are you looking to just move your data or looking to get php & mysql installed on the server as well? (SERVER = production site, not localhost) if you just wanna move data, like everyone else said phpmyadmin rocks, but I do have a recommendation for ya before you jump to the ease of a GUI. Learn how to work in the command line, for the type of situation you are trying to resolve, after you learn that THEN work with a GUI like phpmyadmin. this will both give you a better understanding of mysql commands and also help you to fully appreciate the usefullness of phpmyadmin. -lol if you dont already have mysql php installed on your prodution site, see what it will cost you to have it installed etc, if anyhting, and if its already suppossed to be there, make sure they have set it up for your use, some times ISP's wont create you a database till you ask, or even have the latest version of php intalled for that matter. Even though it's suppossed to be included in your server "option". hope it helps. "Miguel Cruz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Thu, 4 Apr 2002, Anthony Ritter wrote: > > Sorry if my original question was confusing. > > > > This is what I would like to accomplish: > > > > I am currently developing a database on my website using mysql which is on > > my harddrive. > > I have installed Apache as well and I am using PHP. > > > > My database is functioning fine on localhost. > > > > I would like to find out the steps one takes in going from the process of > > having this reside on my harddrive - localhost - in development - to my > > ISP's server when it goes live. > > MySQL has a command-line tool called 'mysqldump' which will output a text > file containing all the table creates and inserts necessary to recreate > the database. > > As others have suggested, you can use phpmyadmin to import this file, or > you can just pipe it into the mysql command-line tool on the server once > you've created your database. Look inside the file created by mysqldump > and all will be much clearer. > > miguel > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP and mySQL...
On Thu, 4 Apr 2002, Anthony Ritter wrote: > Sorry if my original question was confusing. > > This is what I would like to accomplish: > > I am currently developing a database on my website using mysql which is on > my harddrive. > I have installed Apache as well and I am using PHP. > > My database is functioning fine on localhost. > > I would like to find out the steps one takes in going from the process of > having this reside on my harddrive - localhost - in development - to my > ISP's server when it goes live. MySQL has a command-line tool called 'mysqldump' which will output a text file containing all the table creates and inserts necessary to recreate the database. As others have suggested, you can use phpmyadmin to import this file, or you can just pipe it into the mysql command-line tool on the server once you've created your database. Look inside the file created by mysqldump and all will be much clearer. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php