Re: [PHP-DB] Problem with query
Im going to play devils advocate here and say, why is it the one who's helping that needs to be polite and respectful? Isn't it also the newbies responsibility to respect and be polite to those taking time out of their day to help them and not be so stubborn as to not take the advice given which has been the example given here by Ethan? Ethan has been given great advice and should be taking that advice and looking things up and learning, not asking Newbie confused, please explain?. It seems to me that the Help is being taken advantage of here and used as a crutch to get the work done that Ethan has taken upon himself even thought he knows he knows very little about programming in PHP. And that is PHP not PhD. But all that aside as you can see, the same people who Ethan has somewhat ignored their advice are still going against their better judgement to go out of their way to help.. again. Just how much help should be given before you realize the horse is just not drinking the water? I am all for Ethan getting help from the list and I don't want to chastise, but come on, someone with a PhD should know better and should know even better then most on how to listen and learn. Hence the PhD. You don't get one of those by doing what Ethan is doing. If he did that to his professors, he would have failed. Just saying. Best, Karl On Jun 25, 2013, at 1:32 AM, OJFR wrote: Yeah, Jim, please explain what u mean by Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. As long as I remember I could use associative arrays in that way (ex. $_SESSION['Cust_Num']). There's another way to do that using string indices? Why do you say it's wrong? It's obsolete? I would like to make a call to all the members of this mailing list: knowledge is a wonderful gift so, why we don't share it politely and efficiency. Jim, I will take you as an example. You start saying Against my better judgement, here I go again. If it's against your better judgment please don't go anywhere, your conscience is a good adviser. After that you talked a little about standards and some manual. If you are not happy to help people who make some mistakes regarding to programming standards, you should inform them where they can find the glorious manual and what is the correct syntax to do what people need to do. This is a better way to show to others what you know in a humble way but I suppose that wasn't what you were trying to do. I consider this list is to HELP others and share what we know. Never break the silence if it's not to make it better. Ethan, I will check your problem and I'll write you back as soon as I can 'cause right now I don't have anything installed in my computer. I'll try to do it tomorrow, ok? Be nice and stay well!!! Osain. -Mensaje original- De: Ethan Rosenberg, PhD [mailto:erosenb...@hygeiabiomedical.com] Enviado el: domingo, junio 23, 2013 4:38 PM Para: php-db@lists.php.net; Jim Giner Asunto: [PHP-DB] Re: Problem with query On 6/23/2013 2:31 PM, Ethan Rosenberg, PhD wrote: Dear List - There is an error in my query, and I cannot find it. This fails: $_SESSION['Cust_Num'] = $_REQUEST['cnum']; $_SESSION['CustNum'] = $_REQUEST['cnum']; echo sessionbr /; //this has the proper values print_r($_SESSION); $sql10 = select Balance, Payments, Charges, Date from Charges where Cust_Num = $_SESSION[Cust_Num] order by Date; echo $sql10; //echos the correct query $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL Against my better judgement, here I go again. Is this the actual code you executed, or is it once again a typeover? Your 1st error is in these two lines: $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL Yes your dump returns null. And always will. Any further errors might be related to your non-standard syntax for the session variable. Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. === Jim - Is this the actual code you executed, or is it once again a typeover? The actual code Any further errors might be related to your non-standard syntax for the session variable. Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. Newbie is confused. Please explain. TIA Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y
Re: [PHP-DB] Problem with query
On Sun, Jun 23, 2013 at 8:31 PM, Ethan Rosenberg, PhD erosenb...@hygeiabiomedical.com wrote: Dear List - There is an error in my query, and I cannot find it. This fails: $_SESSION['Cust_Num'] = $_REQUEST['cnum']; $_SESSION['CustNum'] = $_REQUEST['cnum']; echo sessionbr /; //this has the proper values print_r($_SESSION); $sql10 = select Balance, Payments, Charges, Date from Charges where Cust_Num = $_SESSION[Cust_Num] order by Date; echo $sql10; //echos the correct query $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL echo centerstrongCurrent Results/strong/center; echo center; echo table border='4' cellpadding='5' cellspacing='55' rules='all' frame='box'; echo tr class='heading'; echo thBalance/th; echo thPayments/th; echo thCharges/th; echo thDate/th; echo /tr; echo row1br /; $row10 is undefined here, so: $row10 = mysqli_fetch_row($result10); ? I would suggest using while (($row1 = mysqli_fetch_row($result1))!= 0 ) { ... } instead of do { ... } while (($row1 = mysqli_fetch_row($result1))!= 0 ); This avoids the need of the extra mysqli_fetch_row before the do-while loop. - Matijn
Re: [PHP-DB] Problem wkith Query
On 23 June 2013 21:37, Ethan Rosenberg, PhD erosenb...@hygeiabiomedical.com wrote: On 6/23/2013 2:31 PM, Ethan Rosenberg, PhD wrote: Dear List - There is an error in my query, and I cannot find it. This fails: $_SESSION['Cust_Num'] = $_REQUEST['cnum']; $_SESSION['CustNum'] = $_REQUEST['cnum']; echo sessionbr /; //this has the proper values print_r($_SESSION); $sql10 = select Balance, Payments, Charges, Date from Charges where Cust_Num = $_SESSION[Cust_Num] order by Date; echo $sql10; //echos the correct query $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL Against my better judgement, here I go again. Is this the actual code you executed, or is it once again a typeover? Your 1st error is in these two lines: $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL Yes your dump returns null. And always will. Any further errors might be related to your non-standard syntax for the session variable. Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. === Jim - Is this the actual code you executed, or is it once again a typeover? The actual code Any further errors might be related to your non-standard syntax for the session variable. Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. Newbie is confused. Please explain. Try ... $sql10 = select Balance, Payments, Charges, Date from Charges where Cust_Num = {$_SESSION['Cust_Num']} order by Date; -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY = Tried it. No luck Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem wkith Query
Turn on error reporting/logging/displaying and what errors are you getting? And as you said ... $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL is your actual code, maybe ... ?php $a = 'set variable a to this message'; var_dump($b); ? gives you a better clue? On 23 June 2013 23:06, Ethan Rosenberg, PhD erosenb...@hygeiabiomedical.com wrote: On 23 June 2013 21:37, Ethan Rosenberg, PhD erosenberg@hygeiabiomedical.* *com erosenb...@hygeiabiomedical.com wrote: On 6/23/2013 2:31 PM, Ethan Rosenberg, PhD wrote: Dear List - There is an error in my query, and I cannot find it. This fails: $_SESSION['Cust_Num'] = $_REQUEST['cnum']; $_SESSION['CustNum'] = $_REQUEST['cnum']; echo sessionbr /; //this has the proper values print_r($_SESSION); $sql10 = select Balance, Payments, Charges, Date from Charges where Cust_Num = $_SESSION[Cust_Num] order by Date; echo $sql10; //echos the correct query $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL Against my better judgement, here I go again. Is this the actual code you executed, or is it once again a typeover? Your 1st error is in these two lines: $result10 = mysqli_query($cxn, $sql10); var_dump($result1); // this returns NULL Yes your dump returns null. And always will. Any further errors might be related to your non-standard syntax for the session variable. Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. === Jim - Is this the actual code you executed, or is it once again a typeover? The actual code Any further errors might be related to your non-standard syntax for the session variable. Per the manual, associative arrays using string indices should always use ' ' around them. They work (as mentioned in the manual) but are wrong. Newbie is confused. Please explain. Try ... $sql10 = select Balance, Payments, Charges, Date from Charges where Cust_Num = {$_SESSION['Cust_Num']} order by Date; -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY = Tried it. No luck Ethan -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY
Re: [PHP-DB] Problem w/query - again
Dear Ethan It seems you are trying to build a query.But you are not getting field names. If you required field names then change the following line to foreach ( $allowed_fields AS $field = $_POST['field']) to foreach ( $allowed_fields AS $field) This would convert the variable field to value. In yoyr line the variable field is treated as array index regds amit The difference between fiction and reality? Fiction has to make sense. On Fri, Feb 10, 2012 at 9:40 AM, Ethan Rosenberg eth...@earthlink.netwrote: Dear list - This did not seem to post, so I am sending it again. If it did post, and I missed it, my apologies. Ethan Dear list - I have the following code: $query = select * from Intake3 where 1; $allowed_fields = array('Site', 'MedRec', 'Fname', 'Lname', 'Phone', 'Sex', 'Height'); foreach ( $allowed_fields AS $field = $_POST['field']) { if ( ! empty( $_POST['field'] ) ) { $query .= AND '$field' = '$_POST[$field]' ; echo $query; } } This is the value of $_POST: Array ( [Site] = AA [MedRec] = 1 [Fname] = [Lname] = [Phone] = [Height] = [welcome_already_seen] = already_seen ) I receive the following errors on run: Notice: Undefined offset: 0 in /var/www/srchrhsptl4.php on line 135 select * from Intake3 where 1 AND '0' = '' Notice: Undefined offset: 1 in /var/www/srchrhsptl4.php on line 135 select * from Intake3 where 1 AND '0' = '' AND '1' = '' Notice: Undefined offset: 2 in /var/www/srchrhsptl4.php on line 135 select * from Intake3 where 1 AND '0' = '' AND '1' = '' AND '2' = '' Advice and help please. Thanks. Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem w/query - again
At 12:13 AM 2/10/2012, Amit Tandon wrote: Dear Ethan It seems you are trying to build a query.But you are not getting field names. If you required field names then change the following line to foreach ( $allowed_fields AS $field = $_POST['field']) to foreach ( $allowed_fields AS $field) This would convert the variable field to value. In yoyr line the variable field is treated as array index regds amit The difference between fiction and reality? Fiction has to make sense. snip Advice and help please. Thanks. Ethan PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Amit - Thanks. Tried it. Still does not work. This is the query I get: select * from Intake3 where 1 Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem w/query - again
Dear Ethan The line you are getting is because the $_POST[fieldname] is blank. So for the following line if ( ! empty( $_POST['field'] ) ) change it to if ( ! empty( $_POST[$field] ) ) Your line : Program is searxchinbg for variable name field New line : The Program is seacging for varable stored in $field. Rember to use double quotes And to verify the value echo $_POST[$field] before your if line i.e. if ( ! empty( $_POST[$field] ) ) regds amit The difference between fiction and reality? Fiction has to make sense. On Fri, Feb 10, 2012 at 11:04 AM, Ethan Rosenberg eth...@earthlink.netwrote: At 12:13 AM 2/10/2012, Amit Tandon wrote: Dear Ethan It seems you are trying to build a query.But you are not getting field names. If you required field names then change the following line to foreach ( $allowed_fields AS $field = $_POST['field']) to foreach ( $allowed_fields AS $field) This would convert the variable field to value. In yoyr line the variable field is treated as array index regds amit The difference between fiction and reality? Fiction has to make sense. snip Advice and help please. Thanks. Ethan PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Amit - Thanks. Tried it. Still does not work. This is the query I get: select * from Intake3 where 1 Ethan
Re: [PHP-DB] Problem w/query - again
At 12:48 AM 2/10/2012, Amit Tandon wrote: Dear Ethan The line you are getting is because the $_POST[fieldname] is blank. So for the following line  if ( ! empty( $_POST['field'] ) ) change it to  if ( ! empty( $_POST[$field] ) ) Your line : Program is searxchinbg for variable name field New line : The Program is seacging for varable stored in $field. Rember to use double quotes And to verify the value echo $_POST[$field] before your if line i.e.  if ( ! empty( $_POST[$field] ) )    regds amit The difference between fiction and reality? Fiction has to make sense. On Fri, Feb 10, 2012 at 11:04 AM, Ethan Rosenberg mailto:eth...@earthlink.neteth...@earthlink.net wrote: At 12:13 AM 2/10/2012, Amit Tandon wrote: Dear Ethan It seems you are trying to build a query.But you are not getting field names. If you required field names then change the following line to foreach ( $allowed_fields AS $field = $_POST['field']) to foreach ( $allowed_fields AS $field) This would convert the variable field to value. In yoyr line the variable field is treated as array index regds amit The difference between fiction and reality? Fiction has to make sense. snip Advice and help please. Thanks. Ethan PHP Database Mailing List (http://www.php.net/http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phphttp://www.php.net/unsub.php Amit - Thanks. Tried your edit. Still does not work. Ethan Amit - Thanks. Tried it.  Still does not work. This is the query I get: select * from Intake3 where  1 Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem w/query - again - CORRECTION
At 12:48 AM 2/10/2012, Amit Tandon wrote: Dear Ethan The line you are getting is because the $_POST[fieldname] is blank. So for the following line  if ( ! empty( $_POST['field'] ) ) change it to  if ( ! empty( $_POST[$field] ) ) Your line : Program is searxchinbg for variable name field New line : The Program is seacging for varable stored in $field. Rember to use double quotes And to verify the value echo $_POST[$field] before your if line i.e.  if ( ! empty( $_POST[$field] ) )    regds amit The difference between fiction and reality? Fiction has to make sense. On Fri, Feb 10, 2012 at 11:04 AM, Ethan Rosenberg mailto:eth...@earthlink.neteth...@earthlink.net wrote: At 12:13 AM 2/10/2012, Amit Tandon wrote: Dear Ethan It seems you are trying to build a query.But you are not getting field names. If you required field names then change the following line to foreach ( $allowed_fields AS $field = $_POST['field']) to foreach ( $allowed_fields AS $field) This would convert the variable field to value. In yoyr line the variable field is treated as array index regds amit The difference between fiction and reality? Fiction has to make sense. snip Advice and help please. Thanks. Ethan PHP Database Mailing List (http://www.php.net/http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phphttp://www.php.net/unsub.php Amit - Thanks. Tried your edit. Still does not work. Ethan Amit - Thanks. Tried it.  Still does not work. This is the query I get: select * from Intake3 where  1 Ethan - Amit - SORRY. Works Perfectly I had commented out my output routine!! Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Problem with query!
Hello! I have a problem with a mysql query! after the query the result variable is "resource id 2" what is wrong! Nothing. Read the manual, even the mysq_fetch_array($result) function. Mage -- PHP Database 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]