[PHP] Building Dynamic Value list using ohp
Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
Thanks Gottfried, but that doesn't change the response I get. Any more suggestions. George P in Edinburgh PS I am hoping to come over to Frankfurt for the conference in November (boss might pay) - Original Message - From: [EMAIL PROTECTED] To: George Pitcher [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:46 PM Subject: Re: [PHP] Building Dynamic Value list using ohp hi! try: $query = select HEI from heronuser; // line 22 greetinx! gottfried Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
A couple of things about the code... 1) - mysql_connect ('localhost', 'root', 'monty'); should be $mysql_link = mysql_connect ('localhost', 'root', 'monty'); 2) - You only pass you can read more about it all and copy and adapt the code snippter from http://www.php.net/manual/en/ref.mysql.php - Original Message - From: George Pitcher [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:54 PM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks Gottfried, but that doesn't change the response I get. Any more suggestions. George P in Edinburgh PS I am hoping to come over to Frankfurt for the conference in November (boss might pay) - Original Message - From: [EMAIL PROTECTED] To: George Pitcher [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:46 PM Subject: Re: [PHP] Building Dynamic Value list using ohp hi! try: $query = select HEI from heronuser; // line 22 greetinx! gottfried Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] ** This e-mail (and any attachment) is intended only for the attention of the addressee(s). Its unauthorised use, disclosure, storage or copying is not permitted. If you are not the intended recipient, please destroy all copies and inform the sender by return e-mail. This e-mail (whether you are the sender or the recipient) may be monitored, recorded and retained by Business Information Publications Limited (BiP). E-mail monitoring/ blocking software may be used, and e-mail content may be read at any time.You have a responsibility to ensure laws are not broken when composing or forwarding e-mails and their contents. ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
oops...I was going to add... 2) - $result = mysql_query($query, $mysql_link); doesn't require the $mysql_link argument, try $result = mysql_query($query); Another general comment is that you have copied a bit of your code that seems to include the root password to mysql. Not a good idea - you should check and edit your code if necessary before posting. Hope this helps - good luck Derek - Original Message - From: George Pitcher [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:54 PM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks Gottfried, but that doesn't change the response I get. Any more suggestions. George P in Edinburgh PS I am hoping to come over to Frankfurt for the conference in November (boss might pay) - Original Message - From: [EMAIL PROTECTED] To: George Pitcher [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:46 PM Subject: Re: [PHP] Building Dynamic Value list using ohp hi! try: $query = select HEI from heronuser; // line 22 greetinx! gottfried Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] ** This e-mail (and any attachment) is intended only for the attention of the addressee(s). Its unauthorised use, disclosure, storage or copying is not permitted. If you are not the intended recipient, please destroy all copies and inform the sender by return e-mail. This e-mail (whether you are the sender or the recipient) may be monitored, recorded and retained by Business Information Publications Limited (BiP). E-mail monitoring/ blocking software may be used, and e-mail content may be read at any time.You have a responsibility to ensure laws are not broken when composing or forwarding e-mails and their contents. ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Building Dynamic Value list using ohp
1. this: print(option value=\$row[0]\$row[0]/option); should be this: print(option value=\{$row[0]}\{$row[0]}/option); or like this: echo 'option value='.$row[0].''.$row[0].'/option'); The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. 2. this: mysql_connect ('localhost', 'root', 'monty'); better be this: mysql_connect ('localhost', '', ''); // for security reasons obviously, you don't wanna give the password our to the group, even so it is your local server (you might not be original with the password on production machines, no?) Hope it helps, Maxim Maletsky PHPBeginner.com -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: mercoledì 26 settembre 2001 15.31 To: [EMAIL PROTECTED] Subject: [PHP] Building Dynamic Value list using ohp Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
Thanks for everyone's help but this is still failing to work. Revised code is: ?php $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); // I've also tried with ($query, $link) if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\{$row[0]}\{$row[0]}/option); } } mysql_close($link); ? Any more suggestions (please)? George - Original Message - From: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 3:17 PM Subject: RE: [PHP] Building Dynamic Value list using ohp 1. this: print(option value=\$row[0]\$row[0]/option); should be this: print(option value=\{$row[0]}\{$row[0]}/option); or like this: echo 'option value='.$row[0].''.$row[0].'/option'); The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. 2. this: mysql_connect ('localhost', 'root', 'monty'); better be this: mysql_connect ('localhost', '', ''); // for security reasons obviously, you don't wanna give the password our to the group, even so it is your local server (you might not be original with the password on production machines, no?) Hope it helps, Maxim Maletsky PHPBeginner.com -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: mercoledì 26 settembre 2001 15.31 To: [EMAIL PROTECTED] Subject: [PHP] Building Dynamic Value list using ohp Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
Also look for missing semicolons and unclosed braces in the lines above 22. -Steve On Wednesday, September 26, 2001, at 09:19 AM, Derek Mailer wrote: oops...I was going to add... 2) - $result = mysql_query($query, $mysql_link); doesn't require the $mysql_link argument, try $result = mysql_query($query); Another general comment is that you have copied a bit of your code that seems to include the root password to mysql. Not a good idea - you should check and edit your code if necessary before posting. Hope this helps - good luck Derek - Original Message - From: George Pitcher [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:54 PM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks Gottfried, but that doesn't change the response I get. Any more suggestions. George P in Edinburgh PS I am hoping to come over to Frankfurt for the conference in November (boss might pay) - Original Message - From: [EMAIL PROTECTED] To: George Pitcher [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 2:46 PM Subject: Re: [PHP] Building Dynamic Value list using ohp hi! try: $query = select HEI from heronuser; // line 22 greetinx! gottfried Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: php-list- [EMAIL PROTECTED] * * This e-mail (and any attachment) is intended only for the attention of the addressee(s). Its unauthorised use, disclosure, storage or copying is not permitted. If you are not the intended recipient, please destroy all copies and inform the sender by return e-mail. This e-mail (whether you are the sender or the recipient) may be monitored, recorded and retained by Business Information Publications Limited (BiP). E-mail monitoring/ blocking software may be used, and e-mail content may be read at any time.You have a responsibility to ensure laws are not broken when composing or forwarding e-mails and their contents. * * -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
- Original Message - From: George Pitcher [EMAIL PROTECTED] To: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 9:42 AM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks for everyone's help but this is still failing to work. Revised code is: ?php $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); // I've also tried with ($query, $link) if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\{$row[0]}\{$row[0]}/option); } } mysql_close($link); ? Any more suggestions (please)? George I don't see anything glaringly wrong with your code. I would change this: $result = mysql_query ($query) into: if( !($result = mysql_query ($query)) ) echo Error: . mysql_error() . BR; as I find that most of my errors in something this simple are in something fairly simple with the query itself (misspelled table or something). also make sure that if you copy your query and paste it directly into MySQL that it works. Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
what's the error you're getting now? if you aren't getting any error, but it just isn't working try something like...(note that I haven't tested this code). $drop_down_list = select name=\select\; $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); $num = mysql_num_rows($result); for ($i = 0; $i $num; $i++) { $HEI = mysql_result($result, $i, HEI); $drop_down_list .= option value=\$HEI\$HEI/option; } mysql_close($link); $drop_down_list .= /select; echo $drop_down_list; Cheers the noo, Derek - Original Message - From: George Pitcher [EMAIL PROTECTED] To: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 3:42 PM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks for everyone's help but this is still failing to work. Revised code is: ?php $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); // I've also tried with ($query, $link) if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\{$row[0]}\{$row[0]}/option); } } mysql_close($link); ? Any more suggestions (please)? George - Original Message - From: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 3:17 PM Subject: RE: [PHP] Building Dynamic Value list using ohp 1. this: print(option value=\$row[0]\$row[0]/option); should be this: print(option value=\{$row[0]}\{$row[0]}/option); or like this: echo 'option value='.$row[0].''.$row[0].'/option'); The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. 2. this: mysql_connect ('localhost', 'root', 'monty'); better be this: mysql_connect ('localhost', '', ''); // for security reasons obviously, you don't wanna give the password our to the group, even so it is your local server (you might not be original with the password on production machines, no?) Hope it helps, Maxim Maletsky PHPBeginner.com -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: mercoledì 26 settembre 2001 15.31 To: [EMAIL PROTECTED] Subject: [PHP] Building Dynamic Value list using ohp Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] ** This e-mail (and any attachment) is intended only for the attention of the addressee(s). Its unauthorised use, disclosure, storage or copying is not permitted. If you are not the intended recipient, please destroy all copies and inform the sender by return e-mail. This e-mail (whether you are the sender or the recipient) may be monitored, recorded and retained by Business Information Publications Limited (BiP). E-mail monitoring/ blocking software may be used, and e-mail content may be read at any time.You have a responsibility to ensure
Re: [PHP] Building Dynamic Value list using ohp
Sheridan, I added the error stuff (adding an else bit) but when I went to my browser, I got the same resulting error I've always had. I have tried pasting the select statement striaght into MySQL_Front and I get my nice neat list. So it doen't look like a SQL problem. Head banging off wall right now. George - Original Message - From: Sheridan Saint-Michel [EMAIL PROTECTED] To: George Pitcher [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 4:00 PM Subject: Re: [PHP] Building Dynamic Value list using ohp - Original Message - From: George Pitcher [EMAIL PROTECTED] To: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 9:42 AM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks for everyone's help but this is still failing to work. Revised code is: ?php $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); // I've also tried with ($query, $link) if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\{$row[0]}\{$row[0]}/option); } } mysql_close($link); ? Any more suggestions (please)? George I don't see anything glaringly wrong with your code. I would change this: $result = mysql_query ($query) into: if( !($result = mysql_query ($query)) ) echo Error: . mysql_error() . BR; as I find that most of my errors in something this simple are in something fairly simple with the query itself (misspelled table or something). also make sure that if you copy your query and paste it directly into MySQL that it works. Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Building Dynamic Value list using ohp
What error do you see, George? Maxim Maletsky www.PHPBeginner.com -Original Message- From: Sheridan Saint-Michel [mailto:[EMAIL PROTECTED]] Sent: mercoledì 26 settembre 2001 17.01 To: George Pitcher; [EMAIL PROTECTED] Subject: Re: [PHP] Building Dynamic Value list using ohp - Original Message - From: George Pitcher [EMAIL PROTECTED] To: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 9:42 AM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks for everyone's help but this is still failing to work. Revised code is: ?php $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); // I've also tried with ($query, $link) if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\{$row[0]}\{$row[0]}/option); } } mysql_close($link); ? Any more suggestions (please)? George I don't see anything glaringly wrong with your code. I would change this: $result = mysql_query ($query) into: if( !($result = mysql_query ($query)) ) echo Error: . mysql_error() . BR; as I find that most of my errors in something this simple are in something fairly simple with the query itself (misspelled table or something). also make sure that if you copy your query and paste it directly into MySQL that it works. Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Building Dynamic Value list using ohp
If you see no errors this might mean you have no records :-) Maxim Maletsky www.PHPBeginner.com -Original Message- From: Derek Mailer [mailto:[EMAIL PROTECTED]] Sent: mercoledì 26 settembre 2001 17.14 To: George Pitcher Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Building Dynamic Value list using ohp what's the error you're getting now? if you aren't getting any error, but it just isn't working try something like...(note that I haven't tested this code). $drop_down_list = select name=\select\; $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); $num = mysql_num_rows($result); for ($i = 0; $i $num; $i++) { $HEI = mysql_result($result, $i, HEI); $drop_down_list .= option value=\$HEI\$HEI/option; } mysql_close($link); $drop_down_list .= /select; echo $drop_down_list; Cheers the noo, Derek - Original Message - From: George Pitcher [EMAIL PROTECTED] To: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 3:42 PM Subject: Re: [PHP] Building Dynamic Value list using ohp Thanks for everyone's help but this is still failing to work. Revised code is: ?php $link = mysql_connect ('localhost', '', '') or die (Could not select db); mysql_select_db ('Heronsql') or die (Could not connect); $query=select distinct HEI from heronuser; $result = mysql_query ($query); // I've also tried with ($query, $link) if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\{$row[0]}\{$row[0]}/option); } } mysql_close($link); ? Any more suggestions (please)? George - Original Message - From: Maxim Maletsky (PHPBeginner.com) [EMAIL PROTECTED] To: 'George Pitcher' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, September 26, 2001 3:17 PM Subject: RE: [PHP] Building Dynamic Value list using ohp 1. this: print(option value=\$row[0]\$row[0]/option); should be this: print(option value=\{$row[0]}\{$row[0]}/option); or like this: echo 'option value='.$row[0].''.$row[0].'/option'); The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. 2. this: mysql_connect ('localhost', 'root', 'monty'); better be this: mysql_connect ('localhost', '', ''); // for security reasons obviously, you don't wanna give the password our to the group, even so it is your local server (you might not be original with the password on production machines, no?) Hope it helps, Maxim Maletsky PHPBeginner.com -Original Message- From: George Pitcher [mailto:[EMAIL PROTECTED]] Sent: mercoledì 26 settembre 2001 15.31 To: [EMAIL PROTECTED] Subject: [PHP] Building Dynamic Value list using ohp Hi all, I'm having a problem with dynamically building a value list. My code: ?php mysql_connect ('localhost', 'root', 'monty'); mysql_select_db ('Heronsql'); $query = (select HEI from heronuser); // LINE 22 on original script $result = mysql_query($query, $mysql_link); if(mysql_num_rows($result)) { // show all HEIs as options in select form while($row = mysql_fetch_row($result)) { print(option value=\$row[0]\$row[0]/option); } } ? But this generates: Parse error: parse error in c:\program files\apache group\apache\htdocs\bizflyers\login.php on line 22 Any suggestions? Regards George _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] _ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] ** This e-mail (and any attachment) is intended only for the attention of the addressee(s). Its unauthorised use, disclosure, storage or copying is not permitted. If you are not the intended recipient, please destroy all copies
RE: [PHP] Building Dynamic Value list using ohp
The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. Just a quick note, this is partially true. The following works : error_reporting(E_ALL); $arr = array ('a' = 'apple','b' = 'banana'); print I'd like an $arr[a] today, and a {$arr['b']} too; I used to assume foo $arr[a] would give a Warning but it doesn't as the constant 'a' isn't looked for in the string, but : print $arr[a]; // apple and a Warning // Warning: Use of undefined constant a - assumed 'a' define('a','b'); // define a as a constant with value of b print $arr[a]; // banana and no Warning print $arr['a']; // apple and no Warning (quotes are good) Numerical arrays work fine in a string, such as foo $array[0]. Maxim is referring to foo $arr['a'] creating a parse error, one that looks like : Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /www/htdocs/test.php on line 4 As it does. The Warnings shown above refer to the E_NOTICE level. Have fun and yes, this is a digression and off-topic :) Regards, Philip Olson 1. this: print(option value=\$row[0]\$row[0]/option); should be this: print(option value=\{$row[0]}\{$row[0]}/option); or like this: echo 'option value='.$row[0].''.$row[0].'/option'); The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Building Dynamic Value list using ohp
On another side-note, I haven't had trouble with echo foo $arr[$a] which is very handy in loops (especially for, while, and foreach) Also, nice to have you back, Maxim On Wednesday 26 September 2001 09:28 am, you wrote: The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. Just a quick note, this is partially true. The following works : error_reporting(E_ALL); $arr = array ('a' = 'apple','b' = 'banana'); print I'd like an $arr[a] today, and a {$arr['b']} too; I used to assume foo $arr[a] would give a Warning but it doesn't as the constant 'a' isn't looked for in the string, but : print $arr[a]; // apple and a Warning // Warning: Use of undefined constant a - assumed 'a' define('a','b'); // define a as a constant with value of b print $arr[a]; // banana and no Warning print $arr['a']; // apple and no Warning (quotes are good) Numerical arrays work fine in a string, such as foo $array[0]. Maxim is referring to foo $arr['a'] creating a parse error, one that looks like : Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /www/htdocs/test.php on line 4 As it does. The Warnings shown above refer to the E_NOTICE level. Have fun and yes, this is a digression and off-topic :) Regards, Philip Olson 1. this: print(option value=\$row[0]\$row[0]/option); should be this: print(option value=\{$row[0]}\{$row[0]}/option); or like this: echo 'option value='.$row[0].''.$row[0].'/option'); The reason for it is that within double quote you can parse for 'simple' variables only (es: $var, not $var[]). Otherwise it gives you a parse error. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]