Re: [PHP] confusing problem or am just plain confused....
On Tue, Jun 10, 2003 at 03:27:10PM -0400, CPT John W. Holmes wrote: > > I dont know how exactly to explain this but will do my best, i have many > of > > the following lines in a page: > > > > > ="package" value="loco package"> > > Further to that... if you need to add more columns of information. Let's say: Text Name name="textname[id]" Checkbox name="checkbox[id]" Different checkbox name="otherchkbox[id]" If you set them all up to use arrays, you can process the form quite nicely like this: foreach ($_POST["textname"] as $id => $value) { // access other items with: $checkbox = $_POST["checkbox"][$id]; $other = $_POST["otherchkbox"][$id]; } I'm sure there are other ways of doing it, but that's the one I like. :) emma -- Emma Jane Hogbin [[ 416 417 2868 ][ www.xtrinsic.com ]] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confusing problem or am just plain confused....
> I dont know how exactly to explain this but will do my best, i have many of > the following lines in a page: > > ="package" value="loco package"> > each line of course has a differient id[] value and package value. > > Everything is working fine with the just id[] value but now i need to add > the package value too...but the problem is when i submit the form all the > hidden fields are getting submitted when i only need the hidden "package" > value of the ticked checkbox...is there any way to do that? or alter the > above so that each id[] can have 2 values? ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] confusing problem or am just plain confused....
Hi, I dont know how exactly to explain this but will do my best, i have many of the following lines in a page: each line of course has a differient id[] value and package value. Everything is working fine with the just id[] value but now i need to add the package value too...but the problem is when i submit the form all the hidden fields are getting submitted when i only need the hidden "package" value of the ticked checkbox...is there any way to do that? or alter the above so that each id[] can have 2 values? In the above example i am getting upto 5 id numbers after i get the numbers i am using it like so: if(isset($id[0])) {do things} to get a better idea of what i am talking about if the above is just too darn confusing check out http://bestwebhosters.com/search.template2.php note that most of the links are deadlinks as this is still in development. Any and all help appreciated. Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Confusing Problem
you'll need to make them global then... that's one thing that kept getting me when I started using php, global vars are only global if you tell them to be sorta like "local to the global scope" or something like that :) -Original Message- From: Tj Corley [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 10:09 AM To: DL Neil Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Confusing Problem they are in the same script outside the function. all the admin functions reside in a admin_func.php with the $db_host, etc, etc variables assigned before it. - Original Message - From: "DL Neil" <[EMAIL PROTECTED]> To: "Tj Corley" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, January 20, 2002 4:56 PM Subject: Re: [PHP] Confusing Problem > Tj, > > > > I am really baffled by this problem. I have tried so many things to get > > this working but to no avail. Here is the > > actual code: > > > > function verify_user($username, $password){ > > $conn = mysql_connect($db_host, $db_user, $db_pass) or > ... > > Anyways the problem is I cannot get it to even get to the database. It > > works when I try to connect in the actual code before I call this function. > ... > > But when I do it that way it won't let me run a query right. I am so > > baffled. Any input would be appreciated. Thanks. > > > Remember the idea of the "scope" of a variable? (if not, please RTFM) > Where do the values of $db_host, $db_user, etc come from? > They are not in the argument list for verify_user(). > > Regards, > =dn > > -- 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] Confusing Problem
Just as DL Neil implied, your variables are outside the scope of the function. set them global within your function. See: http://www.php.net/manual/en/language.variables.scope.php - Original Message - From: "Tj Corley" <[EMAIL PROTECTED]> To: "DL Neil" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, January 20, 2002 3:08 PM Subject: Re: [PHP] Confusing Problem > they are in the same script outside the function. > > all the admin functions reside in a admin_func.php > with the $db_host, etc, etc variables assigned before it. > > - Original Message - > From: "DL Neil" <[EMAIL PROTECTED]> > To: "Tj Corley" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Sunday, January 20, 2002 4:56 PM > Subject: Re: [PHP] Confusing Problem > > > > Tj, > > > > > > > I am really baffled by this problem. I have tried so many things to get > > > this working but to no avail. Here is the > > > actual code: > > > > > > function verify_user($username, $password){ > > > $conn = mysql_connect($db_host, $db_user, $db_pass) or > > ... > > > Anyways the problem is I cannot get it to even get to the database. It > > > works when I try to connect in the actual code before I call this > function. > > ... > > > But when I do it that way it won't let me run a query right. I am so > > > baffled. Any input would be appreciated. Thanks. > > > > > > Remember the idea of the "scope" of a variable? (if not, please RTFM) > > Where do the values of $db_host, $db_user, etc come from? > > They are not in the argument list for verify_user(). > > > > Regards, > > =dn > > > > > > > -- > 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] Confusing Problem
they are in the same script outside the function. all the admin functions reside in a admin_func.php with the $db_host, etc, etc variables assigned before it. - Original Message - From: "DL Neil" <[EMAIL PROTECTED]> To: "Tj Corley" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Sunday, January 20, 2002 4:56 PM Subject: Re: [PHP] Confusing Problem > Tj, > > > > I am really baffled by this problem. I have tried so many things to get > > this working but to no avail. Here is the > > actual code: > > > > function verify_user($username, $password){ > > $conn = mysql_connect($db_host, $db_user, $db_pass) or > ... > > Anyways the problem is I cannot get it to even get to the database. It > > works when I try to connect in the actual code before I call this function. > ... > > But when I do it that way it won't let me run a query right. I am so > > baffled. Any input would be appreciated. Thanks. > > > Remember the idea of the "scope" of a variable? (if not, please RTFM) > Where do the values of $db_host, $db_user, etc come from? > They are not in the argument list for verify_user(). > > Regards, > =dn > > -- 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] Confusing Problem
Tj, > I am really baffled by this problem. I have tried so many things to get > this working but to no avail. Here is the > actual code: > > function verify_user($username, $password){ > $conn = mysql_connect($db_host, $db_user, $db_pass) or ... > Anyways the problem is I cannot get it to even get to the database. It > works when I try to connect in the actual code before I call this function. ... > But when I do it that way it won't let me run a query right. I am so > baffled. Any input would be appreciated. Thanks. Remember the idea of the "scope" of a variable? (if not, please RTFM) Where do the values of $db_host, $db_user, etc come from? They are not in the argument list for verify_user(). Regards, =dn -- 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] Confusing Problem
I am really baffled by this problem. I have tried so many things to get this working but to no avail. Here is the actual code: function verify_user($username, $password){ $conn = mysql_connect($db_host, $db_user, $db_pass) or die("Error while connecting to Database System."); $select_db = mysql_select_db($db_name) or die("Error could not select the database"); $query = "SELECT FROM users WHERE username='$username'"; $result = mysql_query($query) or die("Unable to get query"); $rows = mysql_fetch_array($result); $password = md5($password); if($rows["password"] == $password){ print "You have been verified as $username."; print "Registering your session."; } else{ print "Error: Bad username or password."; print "Please go back"; } } Anyways the problem is I cannot get it to even get to the database. It works when I try to connect in the actual code before I call this function. Like for example in index.php $conn = mysql_connect($db_host, $db_user, $db_pass) or die("Error while connecting to Database System."); $select_db = mysql_select_db($db_name) or die("Error could not select the database"); verify_user($username, $pass); But when I do it that way it won't let me run a query right. I am so baffled. Any input would be appreciated. Thanks. - Tj Corley [EMAIL PROTECTED] The Planet -- 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] confusing problem w/sessions
On which platform do you run? set display_startup_errors = On so that you eventually will see any php initialization problem (like the folder where session data is stored being not accessible because of permission restrictions...I say that because I ran into this problem) to recap, code should be on first page: and on second page: should return: Value of a is: something -Message d'origine- De : Gabriele Biondo [mailto:[EMAIL PROTECTED]] Envoyé : lundi 20 août 2001 15:11 À : [EMAIL PROTECTED]; PHP Objet : Re: [PHP] confusing problem w/sessions > start your session before sending any html output to browser Okay. This solves the problem w/the warnings > check that register_globals is on It is actually on > if not use $HTTP_SESSION_VARS("a") instead to reference your session var > assign a value after having initialiazed your var not before Done. Nothing changes at all... my variables are saved (session_register("a") returns true) but from the second page, wich code is: $a"; ?> i do not see anything at all... more suggestions? thanks in advance Gabriele -- 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] confusing problem w/sessions
> start your session before sending any html output to browser Okay. This solves the problem w/the warnings > check that register_globals is on It is actually on > if not use $HTTP_SESSION_VARS("a") instead to reference your session var > assign a value after having initialiazed your var not before Done. Nothing changes at all... my variables are saved (session_register("a") returns true) but from the second page, wich code is: $a"; ?> i do not see anything at all... more suggestions? thanks in advance Gabriele -- 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] confusing problem w/sessions
start your session before sending any html output to browser check that register_globals is on if not use $HTTP_SESSION_VARS("a") instead to reference your session var assign a value after having initialiazed your var not before -- Original Message -- From: "Gabriele Biondo" <[EMAIL PROTECTED]> Date: Mon, 20 Aug 2001 14:34:35 +0200 >Dear sirs; >i have a simple snippet of code : >session_start(); >$a = 10; >session_register("a"); >?> > >i am trying to understand how do session work. > >Accessing at this document directly from the server (it is a SuSE 7.2 PE - >running PHP 4.0.4 >and apache 1.3.9) i find out the following problem: > >Warning: cannot send session cookie - headers already sent (output started >at ) > >and > >Warning: cannot send session cache limiter - headers already sent (output >started at ) > >The matter is that if i access this variables from another page, they seem >to be empty... > >How can i solve this little confusing problem? > >Thanks in advance > >Gabriele > > >-- >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]
[PHP] confusing problem w/sessions
Dear sirs; i have a simple snippet of code : i am trying to understand how do session work. Accessing at this document directly from the server (it is a SuSE 7.2 PE - running PHP 4.0.4 and apache 1.3.9) i find out the following problem: Warning: cannot send session cookie - headers already sent (output started at ) and Warning: cannot send session cache limiter - headers already sent (output started at ) The matter is that if i access this variables from another page, they seem to be empty... How can i solve this little confusing problem? Thanks in advance Gabriele -- 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]