Re: [PHP] PHP & Database Problems -- Code Snippets
On Thu, May 3, 2012 at 4:20 PM, Ethan Rosenberg wrote: > At 06:47 PM 5/2/2012, Matijn Woudt wrote: >> >> On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg >> wrote: > Dear list - > > Sorry for the attachment.  Here are code snippets >> --- Ethan, I don't want to sound rude, but it appears to me you don't have >> any understanding of what you're doing. It might help if you understand what >> the code is doing... Let me explain. > > GET THE DATA FROM INTAKE3: > >   >> function handle_data() >   { >    global $cxn; >    $query = >> "select * from Intake3 where  1"; > > > >    >> if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) $_Request does not >> exists, you're looking for $_REQUEST. And why are you mixing $_REQUEST and >> $_POST here? >    { >       if ($_REQUEST['Sex'] === "0") > >>       { >        $sex = 'Male'; >       >> } >       else >       { >        $sex = >> 'Female'; >       } >    } > >   } What is the point of >> the handle_data function above? It doesn't do anything. >   >> $allowed_fields = array >    (  'Site' =>$_POST['Site'], 'MedRec' => >> $_POST['MedRec'], 'Fname' => > $_POST['Fname'], 'Lname' => $_POST['Lname'] , >> >       'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex']  , >> 'Height' > => $_POST['Height']  ); > >   if(empty($allowed_fields)) >  >>  { >      echo "ouch"; >   } > >   $query = "select * from >> Intake3  where  1 "; > >   foreach ( $allowed_fields as $key => $val ) >> >   { >    if ( (($val != '')) ) > >   { >    $query .= " >> AND ($key  = '$val') "; >   } >    $result1 = mysqli_query($cxn, >> $query); >   } First, this will allow SQL injections, because you insert >> the values directly from the browser. Second, you should move the last line >> ($result1=...), outside of the foreach loop, now you're executing the query >> multiple times. Third, you should check if $result1 === FALSE, in case the >> query fails > >   $num = mysqli_num_rows($result1); >   if(($num = >> mysqli_num_rows($result1)) == 0) Doing the same thing twice? >   { > ?> > >>   No >> Records > Retrieved #1 >   exit(); >  >>  } > > DISPLAY THE INPUT3 DATA: > THIS SEEMS TO BE THE ROUTINE THAT >> IS FAILING <<< > >   Search Results > >  >>  > >  frame="box"> >   >   Site >   >> Medical Record >   First Name >   Last Name >> >   Phone >   Height >   Sex >   >> History >   > > >    while ($row1 = >> mysqli_fetch_array($result1, MYSQLI_BOTH)) >    { >       >> print_r($_POST); Doesn't really make sense to print $_POST here.. >    >>     global $MDRcheck; >        $n1++; >      >>   echo "n1 ";echo $n1; >       { >      >>   if (($n1 > 2) && ($MDRcheck == $row1[1])) >        { > >>           echo ">2==  "; >           >> echo $MDRcheck; >           echo " $row1[0] \n"; >> >           echo " $row1[1] \n"; >      >>      echo " $row1[2] \n"; >           >> echo " $row1[3] \n"; >           echo " >> $row1[4] \n"; >           echo " $row1[5] >> \n"; >           echo " $row1[6] \n"; >  >>          echo " $row1[7] \n"; >       >>     echo "\n"; >        } >        >> elseif (($n1 > 2) && ($MDRcheck != $row1[1])) >        { >  >>          echo ">2!=  "; > >           >> echo $MDRcheck; > > >           continue; continue >> doesn't do anything here. >        } >        >> elseif ($n1 == 2) >        { > >           >> define( "MDR" ,  $row1[1]); >           echo "row1 >> ";echo $row1[1]; >           echo "\n"; > >   >>         $_GLOBALS['mdr']= $row1[1]; >         >>   $_POST['MedRec'] = $row1[1]; You're not supposed to set variables in >> $_POST... >           $MDRold = $_GLOBALS['mdr']; It >> appears you want the old value of mdr, if so, then you should do this before >> you set it again 2 lines above.. >           echo " >> $row1[0] \n"; >           echo " $row1[1] >> \n"; >           echo " $row1[2] \n"; >  >>          echo " $row1[3] \n"; >       >>     echo " $row1[4] \n"; >           >> echo " $row1[5] \n"; >           echo " >> $row1[6] \n"; >           echo " $row1[7] >> \n"; >           echo
Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
Am 04.05.2012 16:09, schrieb Ethan Rosenberg: function handle_data() { global $cxn; What does this function? It neither takes any parameters nor returns any value. And it does not write back anything to its global $cxn. So it is quite useless and can be deleted. $query = "select * from Intake3 where 1"; if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) there is no variable $_Request, it is $_REQUEST. Why do you test on $_REQUEST and compare it with trimmed $_POST? { if ($_REQUEST['Sex'] === "0") { $sex = 'Male'; } else { $sex = 'Female'; } Why do you set a variable that is never used? $allowed_fields = array ( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => $_POST['Fname'], 'Lname' => $_POST['Lname'] , 'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' => $_POST['Height'] ); if(empty($allowed_fields)) { echo "ouch"; } $query = "select * from Intake3 where 1 "; foreach ( $allowed_fields as $key => $val ) { if ( (($val != '')) ) { $query .= " AND ($key = '$val') "; Why the hell do you put unverified data into an sql query? DISPLAY THE INPUT3 DATA: >>> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< What fails? I do not have access to your database, so I can not run your code to see what fails. n1 ";echo $n1; { if (($n1 > 2) && ($MDRcheck == $row1[1])) What is $MDRcheck and what does this comparision mean? SELECT AND DISPLAY DATA FROM VISIT3 DATABASE Quotes around mdr missing $result2 = mysqli_query($cxn, $query2); $num = mysqli_num_rows($result2); global $finished; $finished = 0; while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH)) { global $finished; No need to global that twice. And why ndo you use global and $_GLOBALS? STick to one or better skip it anyways. Globals are not to be used! switch ( @$_POST[next_step] ) Remove all @ from your code or you won't see any errors on this. Do proper checking and do NOT suppress errors or warnings. echo ""; echo ""; echo ""; echo "Medical Record: "; Quotes. $Weight = $_POST['Weight']; $Notes = $_POST['Notes']; $sql2 = "INSERT INTO Visit3(Indx, Site, MedRec, Notes, Weight, BMI, Date) VALUES(null, '$Site', '$MDRold', '$Notes', Do NOT NEVER put data that is user input unchecked into a query. ?> ?> Double closing tag? echo " $_GLOBALS[mdr] \n"; Quotes. $flag = 1; What's this? You really really should seperate your code from HTML. Please truncate your apache and php error log. Add error_reporting(E_ALL); ini_set('display_errors', 'On'); at the top of every php file right after Remove all @ from your lines and execute your script another time and see what errors are appear into your browser and your logfiles. Post them and the codelines for these errors on the list. -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.biz smime.p7s Description: S/MIME Kryptografische Unterschrift
[PHP] RE: [PHP-DB] [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
Ethan, You have been given advise and break down on your code. Have you taken the advise given? Which part of the code isn't working? Not which chunk, but break it down and show which part BR, Gav -Original Message- From: Ethan Rosenberg [mailto:eth...@earthlink.net] Sent: 04 May 2012 15:10 To: php-db-lists.php.net; php-general@lists.php.net Subject: [PHP-DB] [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas? I am sending this again to see if more ideas for solution of this problem are available. Ethan === Dear list - Sorry for the attachment. Here are code snippets --- GET THE DATA FROM INTAKE3: function handle_data() { global $cxn; $query = "select * from Intake3 where 1"; if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) { if ($_REQUEST['Sex'] === "0") { $sex = 'Male'; } else { $sex = 'Female'; } } } $allowed_fields = array ( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => $_POST['Fname'], 'Lname' => $_POST['Lname'] , 'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' => $_POST['Height'] ); if(empty($allowed_fields)) { echo "ouch"; } $query = "select * from Intake3 where 1 "; foreach ( $allowed_fields as $key => $val ) { if ( (($val != '')) ) { $query .= " AND ($key = '$val') "; } $result1 = mysqli_query($cxn, $query); } $num = mysqli_num_rows($result1); if(($num = mysqli_num_rows($result1)) == 0) { ?> No Records Retrieved #1 >> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< Search Results Site Medical Record First Name Last Name Phone Height Sex History n1 ";echo $n1; { if (($n1 > 2) && ($MDRcheck == $row1[1])) { echo ">2== "; echo $MDRcheck; echo " $row1[0] \n"; echo " $row1[1] \n"; echo " $row1[2] \n"; echo " $row1[3] \n"; echo " $row1[4] \n"; echo " $row1[5] \n"; echo " $row1[6] \n"; echo " $row1[7] \n"; echo "\n"; } elseif (($n1 > 2) && ($MDRcheck != $row1[1])) { echo ">2!= "; echo $MDRcheck; continue; } elseif ($n1 == 2) { define( "MDR" , $row1[1]); echo "row1 ";echo $row1[1]; echo "\n"; $_GLOBALS['mdr']= $row1[1]; $_POST['MedRec'] = $row1[1]; $MDRold = $_GLOBALS['mdr']; echo " $row1[0] \n"; echo " $row1[1] \n"; echo " $row1[2] \n"; echo " $row1[3] \n"; echo " $row1[4] \n"; echo " $row1[5] \n"; echo " $row1[6] \n"; echo " $row1[7] \n"; echo "\n"; } } } ?> SELECT AND DISPLAY DATA FROM VISIT3 DATABASE \n"; echo " $row2[0] \n"; echo " $row2[1] \n"; echo " $row2[2] \n"; echo " $row2[3] \n"; echo " $row2[4] \n"; echo " $row2[5] \n"; echo " $row2[6] \n"; echo "\n"; } echo ""; ENTER MORE DATA: function More_Data() { $decision = 5; ?> Do you Wish to Enter More Data? Yes No >>>>end function More_Data switch ( @$_POST[next_step] ) { case "step10": { if (!isset($_POST['decision'])) { $_POST['decision'] = 5; } if ($_POST['decision'] == 0) { exit(); }
Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
Ethan, before you get frustrated or feel abandoned, let me *sincerely* try to help: Here is honestly what I am utterly convinced you need to do to get any where in the medium/long run: Break everything down into very small steps. Making web apps is just building a whole lot of layers/collections of very small simple things. Nothing is out of your grasp.. it only appears mysterious or complicated because you are not familiar with the terms/code structures and have not spent enough time with the little things to recognize them like english speakers do when reading written english. So what you do to get out of the woods (and it works every time), regardless of the problem, is just focus on one small thing at a time. START OVER. Throw out all the code, especially everything you borrowed from other sources. Write everything yourself, from scratch. Just print "hello" to a web page. Then add in the ability to do ONE more thing that you need... like reading from a db, or writing to a db... and then processing/manipulating things, as you need. Test everything every time you add even ONE little feature. Then as soon as something breaks, you know instantly where the issue lays.. and focus on solving why that one little thing is broken. If re-reading the docs about whatever code structures you used at that point (of your newly-added broken feature) does not clear it up for you, then post just that ONE little issue to this list.. asking why that one thing is behaving that way. Like this (using this tedious but effective method) , you will get your code into shape so it works, you will not alienate yourself from the help you need (by posting volumes of broken code with no evidence that you are actually trying to learn), and best of all - you will, step by step, come to master all this stuff! Everyone loves to help answer/clear up one little thing, but no one has time to digest a whole broken page/app and tell you where all the issues are. Even if they did have the time and inclination, they would lose it after the very first time they saw you take what they gave you and come back 3 weeks later with evidence that you never learned anything from the last episode. Believe me you will always have people climbing over each other to help you, if you can just break down your problems into such small portions that you will be able to realize you have the smarts to answer them yourself. ;-) There is a very lively, effective and popular coders community (and Q/A tool set) here: http://stackoverflow.com/ ..where you get almost instant help to any coding question.. because there are so many people who really care to give quality help, because they get recognized for their contributions. But if you try to use the tools at stackoverflow.com then you will find there, in that very professional atmosphere, that (to get anywhere) you HAVE to ask questions that are distilled down to something very specific and answerable in a specific/factual kind of way, as opposed to question that bring up more fuzzy-boundaried topics, like questions of preference or style, or questions that show an utter lack of homework/effort on the part of the asker which require more than a couple specific facts to answer. You can train here or on stackoverflow.com, but anywhere you go, you will find the same situation, that you have to use baby steps (as necessary) - for your own learning, and to get any decent help. -Govinda -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
Nor will posting to multiple lists.(Sorry to the rest of you - didn't realize it until now.) ""Jim Giner"" wrote in message news:c6.f8.38082.efae3...@pb1.pair.com... >I don't think posting the same voluminous code is going to generate any >better responses. > > The suggestion to start over and make your insert/retrieve queries fool > proof before starting to write some logic into your code was a very good > one. Why don't you work on that so that any requests for help can focus > on just that instead of the 100+ lines of code you are posting? Reading > some documentation on sql and some html/php relationships would be VERY > beneficial to your long-term success as a programmer as well. > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
I don't think posting the same voluminous code is going to generate any better responses. The suggestion to start over and make your insert/retrieve queries fool proof before starting to write some logic into your code was a very good one. Why don't you work on that so that any requests for help can focus on just that instead of the 100+ lines of code you are posting? Reading some documentation on sql and some html/php relationships would be VERY beneficial to your long-term success as a programmer as well. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP & Database Problems -- Code Snippets - Any more Ideas?
I am sending this again to see if more ideas for solution of this problem are available. Ethan === Dear list - Sorry for the attachment. Here are code snippets --- GET THE DATA FROM INTAKE3: function handle_data() { global $cxn; $query = "select * from Intake3 where 1"; if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) { if ($_REQUEST['Sex'] === "0") { $sex = 'Male'; } else { $sex = 'Female'; } } } $allowed_fields = array ( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => $_POST['Fname'], 'Lname' => $_POST['Lname'] , 'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' => $_POST['Height'] ); if(empty($allowed_fields)) { echo "ouch"; } $query = "select * from Intake3 where 1 "; foreach ( $allowed_fields as $key => $val ) { if ( (($val != '')) ) { $query .= " AND ($key = '$val') "; } $result1 = mysqli_query($cxn, $query); } $num = mysqli_num_rows($result1); if(($num = mysqli_num_rows($result1)) == 0) { ?> No Records Retrieved #1 >> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< Search Results cellspacing="55" rules="all" frame="box"> Site Medical Record First Name Last Name Phone Height Sex History n1 ";echo $n1; { if (($n1 > 2) && ($MDRcheck == $row1[1])) { echo ">2== "; echo $MDRcheck; echo " $row1[0] \n"; echo " $row1[1] \n"; echo " $row1[2] \n"; echo " $row1[3] \n"; echo " $row1[4] \n"; echo " $row1[5] \n"; echo " $row1[6] \n"; echo " $row1[7] \n"; echo "\n"; } elseif (($n1 > 2) && ($MDRcheck != $row1[1])) { echo ">2!= "; echo $MDRcheck; continue; } elseif ($n1 == 2) { define( "MDR" , $row1[1]); echo "row1 ";echo $row1[1]; echo "\n"; $_GLOBALS['mdr']= $row1[1]; $_POST['MedRec'] = $row1[1]; $MDRold = $_GLOBALS['mdr']; echo " $row1[0] \n"; echo " $row1[1] \n"; echo " $row1[2] \n"; echo " $row1[3] \n"; echo " $row1[4] \n"; echo " $row1[5] \n"; echo " $row1[6] \n"; echo " $row1[7] \n"; echo "\n"; } } } ?> SELECT AND DISPLAY DATA FROM VISIT3 DATABASE $query2 = "select * from Visit3 where 1 AND (Site = 'AA') AND (MedRec = $_GLOBALS[mdr])"; $result2 = mysqli_query($cxn, $query2); $num = mysqli_num_rows($result2); global $finished; $finished = 0; while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH)) { global $finished; echo "\n"; echo " $row2[0] \n"; echo " $row2[1] \n"; echo " $row2[2] \n"; echo " $row2[3] \n"; echo " $row2[4] \n"; echo " $row2[5] \n"; echo " $row2[6] \n"; echo "\n"; } echo ""; ENTER MORE DATA: function More_Data() { $decision = 5; ?> Do you Wish to Enter More Data? Yes No end function More_Data switch ( @$_POST[next_step] ) { case "step10": { if (!isset($_POST['decision'])) { $_POST['decision'] = 5; } if ($_POST['decision'] == 0) { exit(); } if ($_POST['decision'] == 1) { ; echo ""; echo "value=\"step4\" />"; echo ""; echo "Medical Record: name=\"MedRec\" value=\" $_GLOBALS[mdr]\" />"; echo " Weight: name=\"Weight\" /> "; echo "Notes: "; echo "rows=\"10\" wrap=\"hard\" name=\"Notes\" > "; echo ""; echo " "; echo ""; echo ""; } } /* End Step10 */ case "step4": { if (!isset($_POST['datain'])) { $_POST['datain'] = 5; } if( $_POST['datain'] == "already") { date_default_timezone_set('America/New_York'); $Date = date('Ymd'); $Date2 = date('d M Y'); $sql1 = "select MedRec, Height from Intake3 where (MedRec = $MDRold)"; $result4 = mysqli_query($cxn, $sql1); $row4 = m
Re: [PHP] PHP & Database Problems -- Code Snippets
At 06:47 PM 5/2/2012, Matijn Woudt wrote: On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg wrote: > Dear list - > > Sorry for the attachment.  Here are code snippets --- Ethan, I don't want to sound rude, but it appears to me you don't have any understanding of what you're doing. It might help if you understand what the code is doing... Let me explain. > > GET THE DATA FROM INTAKE3: > >   function handle_data() >   { >    global $cxn; >    $query = "select * from Intake3 where  1"; > > > >    if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) $_Request does not exists, you're looking for $_REQUEST. And why are you mixing $_REQUEST and $_POST here? >    { >       if ($_REQUEST['Sex'] === "0") >       { >        $sex = 'Male'; >       } >       else >       { >        $sex = 'Female'; >       } >    } > >   } What is the point of the handle_data function above? It doesn't do anything. >   $allowed_fields = array >    (  'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => > $_POST['Fname'], 'Lname' => $_POST['Lname'] , >       'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex']  , 'Height' > => $_POST['Height']  ); > >   if(empty($allowed_fields)) >   { >      echo "ouch"; >   } > >   $query = "select * from Intake3  where  1 "; > >   foreach ( $allowed_fields as $key => $val ) >   { >    if ( (($val != '')) ) > >   { >    $query .= " AND ($key  = '$val') "; >   } >    $result1 = mysqli_query($cxn, $query); >   } First, this will allow SQL injections, because you insert the values directly from the browser. Second, you should move the last line ($result1=...), outside of the foreach loop, now you're executing the query multiple times. Third, you should check if $result1 === FALSE, in case the query fails > >   $num = mysqli_num_rows($result1); >   if(($num = mysqli_num_rows($result1)) == 0) Doing the same thing twice? >   { > ?> >   />No Records > Retrieved #1 >   exit(); >   } > > DISPLAY THE INPUT3 DATA: > THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< > >   Search Results > >   cellspacing="55"  rules="all" >  frame="box"> >   >   Site >   Medical Record >   First Name >   Last Name >   Phone >   Height >   Sex >   History >   > > >    while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH)) >    { >       print_r($_POST); Doesn't really make sense to print $_POST here.. >        global $MDRcheck; >        $n1++; >        echo "n1 ";echo $n1; >       { >        if (($n1 > 2) && ($MDRcheck == $row1[1])) >        { >           echo ">2==  "; >           echo $MDRcheck; >           echo " $row1[0] \n"; >           echo " $row1[1] \n"; >           echo " $row1[2] \n"; >           echo " $row1[3] \n"; >           echo " $row1[4] \n"; >           echo " $row1[5] \n"; >           echo " $row1[6] \n"; >           echo " $row1[7] \n"; >           echo "\n"; >        } >        elseif (($n1 > 2) && ($MDRcheck != $row1[1])) >        { >           echo ">2!=  "; > >           echo $MDRcheck; > > >           continue; continue doesn't do anything here. >        } >        elseif ($n1 == 2) >        { > >           define( "MDR" ,  $row1[1]); >           echo "row1 ";echo $row1[1]; >           echo "\n"; > >           $_GLOBALS['mdr']= $row1[1]; >           $_POST['MedRec'] = $row1[1]; You're not supposed to set variables in $_POST... >           $MDRold = $_GLOBALS['mdr']; It appears you want the old value of mdr, if so, then you should do this before you set it again 2 lines above.. >           echo " $row1[0] \n"; >           echo " $row1[1] \n"; >           echo " $row1[2] \n"; >           echo " $row1[3] \n"; >           echo " $row1[4] \n"; >           echo " $row1[5] \n"; >           echo " $row1[6] \n"; >           echo " $row1[7] \n"; >           echo "\n"; >        } > >       } >    } > > ?> You say this routine is probably the one
Re: [PHP] PHP & Database Problems
On 5/2/2012 4:28 PM, Duken Marga wrote: But I don't see any attachments in this message. This was in the first email of this thread. I can easily extract data from the database. However, if I try to enter data, it goes into the incorrect record. Following are some screenshots. The program is attached. [pardon the comical names. This is a test, and any resemblance to true names is not intentional] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP & Database Problems -- Code Snippets
It is a good habbit to write the core code just for inserting/retrieving data from database. It will reduce much of your code complexity. When you see your code is working, you can continue to embed it with your visual front-end or with your filter. On Thu, May 3, 2012 at 4:43 AM, Ethan Rosenberg wrote: > Dear list - > > Sorry for the attachment. Here are code snippets --- > > GET THE DATA FROM INTAKE3: > >function handle_data() >{ > global $cxn; > $query = "select * from Intake3 where 1"; > > > > if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) > { >if ($_REQUEST['Sex'] === "0") >{ > $sex = 'Male'; >} >else >{ > $sex = 'Female'; >} > } > >} > >$allowed_fields = array > ( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => > $_POST['Fname'], 'Lname' => $_POST['Lname'] , > 'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , > 'Height' => $_POST['Height'] ); > >if(empty($allowed_fields)) >{ > echo "ouch"; >} > >$query = "select * from Intake3 where 1 "; > >foreach ( $allowed_fields as $key => $val ) >{ > if ( (($val != '')) ) > >{ > $query .= " AND ($key = '$val') "; >} > $result1 = mysqli_query($cxn, $query); >} > >$num = mysqli_num_rows($result1); >if(($num = mysqli_num_rows($result1)) == 0) >{ > ?> >No > Records Retrieved #1 > exit(); >} > > DISPLAY THE INPUT3 DATA: > > >>> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< > >Search Results > > frame="box"> > >Site >Medical Record >First Name >Last Name >Phone >Height >Sex >History > > > > while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH)) > { >print_r($_POST); > global $MDRcheck; > $n1++; > echo "n1 ";echo $n1; >{ > if (($n1 > 2) && ($MDRcheck == $row1[1])) > { >echo ">2== "; >echo $MDRcheck; >echo " $row1[0] \n"; >echo " $row1[1] \n"; >echo " $row1[2] \n"; >echo " $row1[3] \n"; >echo " $row1[4] \n"; >echo " $row1[5] \n"; >echo " $row1[6] \n"; >echo " $row1[7] \n"; >echo "\n"; > } > elseif (($n1 > 2) && ($MDRcheck != $row1[1])) > { >echo ">2!= "; > >echo $MDRcheck; > > >continue; > } > elseif ($n1 == 2) > { > >define( "MDR" , $row1[1]); >echo "row1 ";echo $row1[1]; >echo "\n"; > >$_GLOBALS['mdr']= $row1[1]; >$_POST['MedRec'] = $row1[1]; >$MDRold = $_GLOBALS['mdr']; >echo " $row1[0] \n"; >echo " $row1[1] \n"; >echo " $row1[2] \n"; >echo " $row1[3] \n"; >echo " $row1[4] \n"; >echo " $row1[5] \n"; >echo " $row1[6] \n"; >echo " $row1[7] \n"; >echo "\n"; > } > >} > } > > ?> > > SELECT AND DISPLAY DATA FROM VISIT3 DATABASE > > $query2 = "select * from Visit3 where 1 AND (Site = 'AA') AND (MedRec > = $_GLOBALS[mdr])"; >$result2 = mysqli_query($cxn, $query2); >$num = mysqli_num_rows($result2); > > >global $finished; >$finished = 0; > > >while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH)) >{ > global $finished; > echo "\n"; > echo " $row2[0] \n"; > echo " $row2[1] \n"; > echo " $row2[2] \n"; > echo " $row2[3] \n"; > echo " $row2[4] \n"; > echo " $row2[5] \n"; > echo " $row2[6] \n"; > echo "\n"; > >} > > echo ""; > > ENTER MORE DATA: > >function More_Data() >{ > $decision = 5; > ?> > >Do you Wish to Enter More Data? > >Yes type="radio" name="decision" value="0" />No > > > > > } //>end function More_Data > > > >switch ( @$_POST[next_step] ) >{ > > case "step10": > { >if (!isset($_POST['decision'])) >{ > $_POST['decision'] = 5; >} > >if ($_POST['decision'] == 0) >{ > exit(); >} >if ($_POST['decision'] == 1) >{ > ; > echo ""; >echo " />"; >echo ""; >echo "Medical Record: value=\" $_GLOBALS[mdr]\" />"; >echo " Weight: name=\"Weight\" /> "; >echo "Notes: "; >
Re: [PHP] PHP & Database Problems
But I don't see any attachments in this message. On Thu, May 3, 2012 at 2:28 AM, Jim Lucas wrote: > I do believe attachments are allowed. Looking back, I see that there have > been messages sent to the list that had odt, php, and ini attachments > > > On 05/02/2012 12:12 PM, Gavin Chalkley wrote: > >> Ethan, >> >> Some coding you are using would be helpful (as far as i am aware >> attachments >> are not support on the mailing list's) >> >> Gav >> >> -Original Message- >> From: Ethan Rosenberg [mailto:eth...@earthlink.net] >> Sent: 02 May 2012 19:54 >> To: php-db-lists.php.net; php-general@lists.php.net >> Subject: [PHP-DB] PHP& Database Problems >> >> have a database >> >> mysql> describe Intake3; >> ++-+--**+-+-+---+ >> | Field | Type| Null | Key | Default | Extra | >> ++-+--**+-+-+---+ >> | Site | varchar(6) | NO | PRI | | | >> | MedRec | int(6) | NO | PRI | NULL| | >> | Fname | varchar(15) | YES | | NULL| | >> | Lname | varchar(30) | YES | | NULL| | >> | Phone | varchar(30) | YES | | NULL| | >> | Height | int(4) | YES | | NULL| | >> | Sex| char(7) | YES | | NULL| | >> | Hx | text| YES | | NULL| | >> ++-+--**+-+-+---+ >> 8 rows in set (0.00 sec) >> >> mysql> describe Visit3; >> ++--+-**-+-+-+**+ >> | Field | Type | Null | Key | Default | Extra | >> ++--+-**-+-+-+**+ >> | Indx | int(4) | NO | PRI | NULL| auto_increment | >> | Site | varchar(6) | YES | | NULL|| >> | MedRec | int(6) | YES | | NULL|| >> | Notes | text | YES | | NULL|| >> | Weight | int(4) | YES | | NULL|| >> | BMI| decimal(3,1) | YES | | NULL|| >> | Date | date | YES | | NULL|| >> ++--+-**-+-+-+**+ >> >> and a program to enter and extract data. >> >> I can easily extract data from the database. However, if I try to enter >> data, it goes into the incorrect record. Following are some screenshots. >> The program is attached. [pardon the comical names. This is a test, and >> any resemblance to true names is not intentional] >> >> Let us say that I wish to deal with Medical Record 1: >> >> >> This it data from Intake3: >> Site Medical Record First Name Last Name Phone Height Sex History AA 1 >> David Dummy 845 365-1456 66 Male c/o obesity. Various treatments w/o >> success >> >> This is data from Visit3: >> Index Site Medical Record Notes Weight BMI Date >> 2322 AA 1 Second Visit. 170 27.4 2010-01-20 >> 2326 AA 1 Third visit. Small progress, but pt is very happy. 165 >> 26.6 2010-02-01 >> >> >> I then request to enter additional data: >> >> Site Medical Record First Name Last Name Phone Height Sex History >> AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his >> friends that he is obese. Normal BMI = 23. >> Index Site Medical Record Notes Weight BMI Date >> >> Notice that it is entered into record 10003 >> >> The data is "First Try" >> >> Index Site Medical Record Notes Weight BMI Date >> 2590 AA 10003 First Try 189 31.4 02 May 2012 >> >> Help and advice, please. >> >> Thanks. >> >> Ethan >> >> >> >> > > -- > Jim Lucas > > http://www.cmsws.com/ > http://www.cmsws.com/examples/ > http://www.bendsource.com/ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Duken Marga
Re: [PHP] PHP & Database Problems -- Code Snippets
On Wed, May 2, 2012 at 11:43 PM, Ethan Rosenberg wrote: > Dear list - > > Sorry for the attachment. Here are code snippets --- Ethan, I don't want to sound rude, but it appears to me you don't have any understanding of what you're doing. It might help if you understand what the code is doing... Let me explain. > > GET THE DATA FROM INTAKE3: > > function handle_data() > { > global $cxn; > $query = "select * from Intake3 where 1"; > > > > if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) $_Request does not exists, you're looking for $_REQUEST. And why are you mixing $_REQUEST and $_POST here? > { > if ($_REQUEST['Sex'] === "0") > { > $sex = 'Male'; > } > else > { > $sex = 'Female'; > } > } > > } What is the point of the handle_data function above? It doesn't do anything. > $allowed_fields = array > ( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => > $_POST['Fname'], 'Lname' => $_POST['Lname'] , > 'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' > => $_POST['Height'] ); > > if(empty($allowed_fields)) > { > echo "ouch"; > } > > $query = "select * from Intake3 where 1 "; > > foreach ( $allowed_fields as $key => $val ) > { > if ( (($val != '')) ) > > { > $query .= " AND ($key = '$val') "; > } > $result1 = mysqli_query($cxn, $query); > } First, this will allow SQL injections, because you insert the values directly from the browser. Second, you should move the last line ($result1=...), outside of the foreach loop, now you're executing the query multiple times. Third, you should check if $result1 === FALSE, in case the query fails > > $num = mysqli_num_rows($result1); > if(($num = mysqli_num_rows($result1)) == 0) Doing the same thing twice? > { > ?> > No Records > Retrieved #1 > exit(); > } > > DISPLAY THE INPUT3 DATA: > THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< > > Search Results > > frame="box"> > > Site > Medical Record > First Name > Last Name > Phone > Height > Sex > History > > > > while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH)) > { > print_r($_POST); Doesn't really make sense to print $_POST here.. > global $MDRcheck; > $n1++; > echo "n1 ";echo $n1; > { > if (($n1 > 2) && ($MDRcheck == $row1[1])) > { > echo ">2== "; > echo $MDRcheck; > echo " $row1[0] \n"; > echo " $row1[1] \n"; > echo " $row1[2] \n"; > echo " $row1[3] \n"; > echo " $row1[4] \n"; > echo " $row1[5] \n"; > echo " $row1[6] \n"; > echo " $row1[7] \n"; > echo "\n"; > } > elseif (($n1 > 2) && ($MDRcheck != $row1[1])) > { > echo ">2!= "; > > echo $MDRcheck; > > > continue; continue doesn't do anything here. > } > elseif ($n1 == 2) > { > > define( "MDR" , $row1[1]); > echo "row1 ";echo $row1[1]; > echo "\n"; > > $_GLOBALS['mdr']= $row1[1]; > $_POST['MedRec'] = $row1[1]; You're not supposed to set variables in $_POST... > $MDRold = $_GLOBALS['mdr']; It appears you want the old value of mdr, if so, then you should do this before you set it again 2 lines above.. > echo " $row1[0] \n"; > echo " $row1[1] \n"; > echo " $row1[2] \n"; > echo " $row1[3] \n"; > echo " $row1[4] \n"; > echo " $row1[5] \n"; > echo " $row1[6] \n"; > echo " $row1[7] \n"; > echo "\n"; > } > > } > } > > ?> You say this routine is probably the one that is failing.. but what is going wrong? And how the heck are we supposed to know what this function should do? > > SELECT AND DISPLAY DATA FROM VISIT3 DATABASE > > $query2 = "select * from Visit3 where 1 AND (Site = 'AA') AND (MedRec = > $_GLOBALS[mdr])"; You're using mdr as a constant here, this will generate a warning, but sadly enough it works. > $result2 = mysqli_query($cxn, $query2); You should check if $result2 === FALSE, in case the query fails. > $num = mysqli_num_rows($result2); You're counting the rows here, but you don't do anything with the result? > << Snip the rest of this crappy code >> > > I hope this helps. > > Ethan > > I think I made my point. I guess if I continued on the rest of the code t
[PHP] PHP & Database Problems -- Code Snippets
Dear list - Sorry for the attachment. Here are code snippets --- GET THE DATA FROM INTAKE3: function handle_data() { global $cxn; $query = "select * from Intake3 where 1"; if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' ) { if ($_REQUEST['Sex'] === "0") { $sex = 'Male'; } else { $sex = 'Female'; } } } $allowed_fields = array ( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' => $_POST['Fname'], 'Lname' => $_POST['Lname'] , 'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' => $_POST['Height'] ); if(empty($allowed_fields)) { echo "ouch"; } $query = "select * from Intake3 where 1 "; foreach ( $allowed_fields as $key => $val ) { if ( (($val != '')) ) { $query .= " AND ($key = '$val') "; } $result1 = mysqli_query($cxn, $query); } $num = mysqli_num_rows($result1); if(($num = mysqli_num_rows($result1)) == 0) { ?> No Records Retrieved #1 >> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<< Search Results cellspacing="55" rules="all" frame="box"> Site Medical Record First Name Last Name Phone Height Sex History n1 ";echo $n1; { if (($n1 > 2) && ($MDRcheck == $row1[1])) { echo ">2== "; echo $MDRcheck; echo " $row1[0] \n"; echo " $row1[1] \n"; echo " $row1[2] \n"; echo " $row1[3] \n"; echo " $row1[4] \n"; echo " $row1[5] \n"; echo " $row1[6] \n"; echo " $row1[7] \n"; echo "\n"; } elseif (($n1 > 2) && ($MDRcheck != $row1[1])) { echo ">2!= "; echo $MDRcheck; continue; } elseif ($n1 == 2) { define( "MDR" , $row1[1]); echo "row1 ";echo $row1[1]; echo "\n"; $_GLOBALS['mdr']= $row1[1]; $_POST['MedRec'] = $row1[1]; $MDRold = $_GLOBALS['mdr']; echo " $row1[0] \n"; echo " $row1[1] \n"; echo " $row1[2] \n"; echo " $row1[3] \n"; echo " $row1[4] \n"; echo " $row1[5] \n"; echo " $row1[6] \n"; echo " $row1[7] \n"; echo "\n"; } } } ?> SELECT AND DISPLAY DATA FROM VISIT3 DATABASE $query2 = "select * from Visit3 where 1 AND (Site = 'AA') AND (MedRec = $_GLOBALS[mdr])"; $result2 = mysqli_query($cxn, $query2); $num = mysqli_num_rows($result2); global $finished; $finished = 0; while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH)) { global $finished; echo "\n"; echo " $row2[0] \n"; echo " $row2[1] \n"; echo " $row2[2] \n"; echo " $row2[3] \n"; echo " $row2[4] \n"; echo " $row2[5] \n"; echo " $row2[6] \n"; echo "\n"; } echo ""; ENTER MORE DATA: function More_Data() { $decision = 5; ?> Do you Wish to Enter More Data? Yes No end function More_Data switch ( @$_POST[next_step] ) { case "step10": { if (!isset($_POST['decision'])) { $_POST['decision'] = 5; } if ($_POST['decision'] == 0) { exit(); } if ($_POST['decision'] == 1) { ; echo ""; echo "value=\"step4\" />"; echo ""; echo "Medical Record: name=\"MedRec\" value=\" $_GLOBALS[mdr]\" />"; echo " Weight: name=\"Weight\" /> "; echo "Notes: "; echo "rows=\"10\" wrap=\"hard\" name=\"Notes\" > "; echo ""; echo " "; echo ""; echo ""; } } /* End Step10 */ case "step4": { if (!isset($_POST['datain'])) { $_POST['datain'] = 5; } if( $_POST['datain'] == "already") { date_default_timezone_set('America/New_York'); $Date = date('Ymd'); $Date2 = date('d M Y'); $sql1 = "select MedRec, Height from Intake3 where (MedRec = $MDRold)"; $result4 = mysqli_query($cxn, $sql1); $row4 = mysqli_fetch_array($result4, MYSQLI_BOTH); $Height = $row4[1]; $Weight = $_POST['Weigh
Re: [PHP] PHP & Database Problems
Dear Ethan, It would be useful to see what code you are using. The syntax is: UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value The data that you are required to enter is for Intake3. I am assuming that the only change is the History and/or Phone that you need to update since the Site, MedRec, Fname, Lname, Height and Sex should remain the same. Therefore I imagine the code should be something like mysql_query("UPDATE Intake3 SET History='Has been convinced by his friends that he is obese. Normal BMI = 23', Phone='325 563-4178' WHERE MedRec='1' LIMIT 1"); Having said that I notice that you have two primary keys in Intake3. Not aware that a table can carry two. Terry On 2 May 2012 19:53, Ethan Rosenberg wrote: > have a database > > mysql> describe Intake3; > ++-+--**+-+-+---+ > | Field | Type| Null | Key | Default | Extra | > ++-+--**+-+-+---+ > | Site | varchar(6) | NO | PRI | | | > | MedRec | int(6) | NO | PRI | NULL| | > | Fname | varchar(15) | YES | | NULL| | > | Lname | varchar(30) | YES | | NULL| | > | Phone | varchar(30) | YES | | NULL| | > | Height | int(4) | YES | | NULL| | > | Sex| char(7) | YES | | NULL| | > | Hx | text| YES | | NULL| | > ++-+--**+-+-+---+ > 8 rows in set (0.00 sec) > > mysql> describe Visit3; > ++--+-**-+-+-+**+ > | Field | Type | Null | Key | Default | Extra | > ++--+-**-+-+-+**+ > | Indx | int(4) | NO | PRI | NULL| auto_increment | > | Site | varchar(6) | YES | | NULL|| > | MedRec | int(6) | YES | | NULL|| > | Notes | text | YES | | NULL|| > | Weight | int(4) | YES | | NULL|| > | BMI| decimal(3,1) | YES | | NULL|| > | Date | date | YES | | NULL|| > ++--+-**-+-+-+**+ > > and a program to enter and extract data. > > I can easily extract data from the database. However, if I try to enter > data, it goes into the incorrect record. Following are some screenshots. > The program is attached. [pardon the comical names. This is a test, and > any resemblance to true names is not intentional] > > Let us say that I wish to deal with Medical Record 1: > > > This it data from Intake3: > Site Medical Record First Name Last Name Phone Height Sex History > AA 1 David Dummy 845 365-1456 66 Male c/o obesity. Various treatments > w/o success > > This is data from Visit3: > Index Site Medical Record Notes Weight BMI Date > 2322 AA 1 Second Visit. 170 27.4 2010-01-20 > 2326 AA 1 Third visit. Small progress, but pt is very happy. 165 26.6 > 2010-02-01 > > > I then request to enter additional data: > > Site Medical Record First Name Last Name Phone Height Sex History > AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his > friends that he is obese. Normal BMI = 23. > Index Site Medical Record Notes Weight BMI Date > > Notice that it is entered into record 10003 > > The data is "First Try" > > Index Site Medical Record Notes Weight BMI Date > 2590 AA 10003 First Try 189 31.4 02 May 2012 > > Help and advice, please. > > Thanks. > > Ethan > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- *Terry Ally* Twitter.com/terryally Facebook.com/terryally ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~ To print or not to print this email is the environmentally-searching question! Which has the highest ecological cost? A sheet of paper or constantly switching on your computer and connecting to the Internet to read your email?
Re: [PHP] PHP & Database Problems
I do believe attachments are allowed. Looking back, I see that there have been messages sent to the list that had odt, php, and ini attachments On 05/02/2012 12:12 PM, Gavin Chalkley wrote: Ethan, Some coding you are using would be helpful (as far as i am aware attachments are not support on the mailing list's) Gav -Original Message- From: Ethan Rosenberg [mailto:eth...@earthlink.net] Sent: 02 May 2012 19:54 To: php-db-lists.php.net; php-general@lists.php.net Subject: [PHP-DB] PHP& Database Problems have a database mysql> describe Intake3; ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-+---+ | Site | varchar(6) | NO | PRI | | | | MedRec | int(6) | NO | PRI | NULL| | | Fname | varchar(15) | YES | | NULL| | | Lname | varchar(30) | YES | | NULL| | | Phone | varchar(30) | YES | | NULL| | | Height | int(4) | YES | | NULL| | | Sex| char(7) | YES | | NULL| | | Hx | text| YES | | NULL| | ++-+--+-+-+---+ 8 rows in set (0.00 sec) mysql> describe Visit3; ++--+--+-+-++ | Field | Type | Null | Key | Default | Extra | ++--+--+-+-++ | Indx | int(4) | NO | PRI | NULL| auto_increment | | Site | varchar(6) | YES | | NULL|| | MedRec | int(6) | YES | | NULL|| | Notes | text | YES | | NULL|| | Weight | int(4) | YES | | NULL|| | BMI| decimal(3,1) | YES | | NULL|| | Date | date | YES | | NULL|| ++--+--+-+-++ and a program to enter and extract data. I can easily extract data from the database. However, if I try to enter data, it goes into the incorrect record. Following are some screenshots. The program is attached. [pardon the comical names. This is a test, and any resemblance to true names is not intentional] Let us say that I wish to deal with Medical Record 1: This it data from Intake3: Site Medical Record First Name Last Name Phone Height Sex History AA 1 David Dummy 845 365-1456 66 Male c/o obesity. Various treatments w/o success This is data from Visit3: Index Site Medical Record Notes Weight BMI Date 2322 AA 1 Second Visit. 170 27.4 2010-01-20 2326 AA 1 Third visit. Small progress, but pt is very happy. 165 26.6 2010-02-01 I then request to enter additional data: Site Medical Record First Name Last Name Phone Height Sex History AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his friends that he is obese. Normal BMI = 23. Index Site Medical Record Notes Weight BMI Date Notice that it is entered into record 10003 The data is "First Try" Index Site Medical Record Notes Weight BMI Date 2590 AA 10003 First Try 189 31.4 02 May 2012 Help and advice, please. Thanks. Ethan -- Jim Lucas http://www.cmsws.com/ http://www.cmsws.com/examples/ http://www.bendsource.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP & Database Problems
have a database mysql> describe Intake3; ++-+--+-+-+---+ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-+---+ | Site | varchar(6) | NO | PRI | | | | MedRec | int(6) | NO | PRI | NULL| | | Fname | varchar(15) | YES | | NULL| | | Lname | varchar(30) | YES | | NULL| | | Phone | varchar(30) | YES | | NULL| | | Height | int(4) | YES | | NULL| | | Sex| char(7) | YES | | NULL| | | Hx | text| YES | | NULL| | ++-+--+-+-+---+ 8 rows in set (0.00 sec) mysql> describe Visit3; ++--+--+-+-++ | Field | Type | Null | Key | Default | Extra | ++--+--+-+-++ | Indx | int(4) | NO | PRI | NULL| auto_increment | | Site | varchar(6) | YES | | NULL|| | MedRec | int(6) | YES | | NULL|| | Notes | text | YES | | NULL|| | Weight | int(4) | YES | | NULL|| | BMI| decimal(3,1) | YES | | NULL|| | Date | date | YES | | NULL|| ++--+--+-+-++ and a program to enter and extract data. I can easily extract data from the database. However, if I try to enter data, it goes into the incorrect record. Following are some screenshots. The program is attached. [pardon the comical names. This is a test, and any resemblance to true names is not intentional] Let us say that I wish to deal with Medical Record 1: This it data from Intake3: Site Medical Record First Name Last Name Phone Height Sex History AA 1 David Dummy 845 365-1456 66 Male c/o obesity. Various treatments w/o success This is data from Visit3: Index Site Medical Record Notes Weight BMI Date 2322 AA 1 Second Visit. 170 27.4 2010-01-20 2326 AA 1 Third visit. Small progress, but pt is very happy. 165 26.6 2010-02-01 I then request to enter additional data: Site Medical Record First Name Last Name Phone Height Sex History AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his friends that he is obese. Normal BMI = 23. Index Site Medical Record Notes Weight BMI Date Notice that it is entered into record 10003 The data is "First Try" Index Site Medical Record Notes Weight BMI Date 2590 AA 10003 First Try 189 31.4 02 May 2012 Help and advice, please. Thanks. Ethan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
> Let me repeat myself: did you have a look at Doctrine2? Hi Peter, I didn't mean to ignore your suggestion, I just got extremely overwealmed by the Doctrine website and didn't even have a response. I get the impression that, like Zend and others, learning how to install and use that would take longer than my 'little' website is worth. Maybe someday when I'm working for a more patient employer who's willing to pay me to learn. Insert laughter here. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On 22 July 2010 21:14, Marc Guay wrote: >> i recommend propel >> http://www.propelorm.org/ > > Holy Moses that thing is a monster. It requires installing extra > libraries (Phing) in order to create an XML schema reverse-engineered > from my existing database. The code looks simple enough but that > installation is brutal. Any other suggestions? I'm thinking of > sticking with good ol' hand coding and a few helper classes. > Let me repeat myself: did you have a look at Doctrine2? Regards Peter -- WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On Thu, Jul 22, 2010 at 1:14 PM, Marc Guay wrote: > > i recommend propel > > http://www.propelorm.org/ > > Holy Moses that thing is a monster. It requires installing extra > libraries (Phing) in order to create an XML schema reverse-engineered > from my existing database. The code looks simple enough but that > installation is brutal. Any other suggestions? I'm thinking of > sticking with good ol' hand coding and a few helper classes. > > Marc > so you spend a little time up front to sav tons of coding time in the future... change your schema; re-generate the base layer.., o yeah, and it preserves custom logic too (upon regeneration), since that resides in sub classes. i used to hand write db wrapper classes but found it tedious and tended to result in a lack of cohesion through the classes themselves, not to mention being error prone. -nathan
Re: [PHP] PHP database interface layer
On Jul 22, 2010, at 3:14 PM, Marc Guay wrote: >> i recommend propel >> http://www.propelorm.org/ > > Holy Moses that thing is a monster. It requires installing extra > libraries (Phing) in order to create an XML schema reverse-engineered > from my existing database. The code looks simple enough but that > installation is brutal. Any other suggestions? I'm thinking of > sticking with good ol' hand coding and a few helper classes. > > Marc > I kind of had the same reaction when I saw it! I started playing around with it and realized that if I ever make any database changes I'm going to have to regenerate everything! Seems a bit cumbersome to me but I'm an "good ol' hand coding and a few helper classes" programmer myself! I wound up creating a very light-weight yet flexible framework that has served me well over the past few years. I've been thinking about releasing it but it doesn't follow the traditional model of most of the MVC frameworks I've seen. Take care, Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
> i recommend propel > http://www.propelorm.org/ Holy Moses that thing is a monster. It requires installing extra libraries (Phing) in order to create an XML schema reverse-engineered from my existing database. The code looks simple enough but that installation is brutal. Any other suggestions? I'm thinking of sticking with good ol' hand coding and a few helper classes. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
> i recommend propel > http://www.propelorm.org/ This looks hopeful. I'd checked it out before but for some reason lumped it in with all of the other half-baked tools that didn't do what I wanted, but even that basic example seems to cover most of what I want. Thanks for the suggestions. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP database interface layer
On Thu, Jul 22, 2010 at 7:35 AM, Marc Guay wrote: > Hi everyone, > > I've built a fairly large normalized database schema for a project. > This is fun for me as I like thinking about how everything is > interconnected. Foreign keys are all set up, many-to-many tables are > go, etc, and so on. But now it's time to create an interface between > that database and the website using PHP. I've searched the web and > this is obviously a very common problem with many solutions, but I > can't help but feel that all of the logic I've built into the database > is worth nothing once I start coding. I found this > article/presentation that essentially sums up my frustration: > http://mag-sol.com/talks/lpm/2006/orm/. Up until now I've been > working on smaller projects with only a few tables that don't really > relate to each other, and have found this tool > (http://www.ricocheting.com/code/php/mysql-database-class-wrapper) > very handy for the reasons he explains, but I'm looking for something > a little different. I've looked at RedBean and it seems pretty handy, > but it also requires me to redefine all of the foreign keys I've > already defined, which is annoying. Any hope of something like > > // Get company where name='Widgets Inc.' or id=1 or > $company = $db->get_company("name='Widgets Inc.'"); > > // Get all clients joined to the company > $clients = $company->get_clients(); > > // Get all projects joined to the client > $projects = $clients->get_projects(); > > ? i recommend propel http://www.propelorm.org/ -nathan
Re: [PHP] PHP database interface layer
On 22 July 2010 15:35, Marc Guay wrote: > Hi everyone, > > I've built a fairly large normalized database schema for a project. > This is fun for me as I like thinking about how everything is > interconnected. Foreign keys are all set up, many-to-many tables are > go, etc, and so on. But now it's time to create an interface between > that database and the website using PHP. I've searched the web and > this is obviously a very common problem with many solutions, but I > can't help but feel that all of the logic I've built into the database > is worth nothing once I start coding. I found this > article/presentation that essentially sums up my frustration: > http://mag-sol.com/talks/lpm/2006/orm/. Up until now I've been > working on smaller projects with only a few tables that don't really > relate to each other, and have found this tool > (http://www.ricocheting.com/code/php/mysql-database-class-wrapper) > very handy for the reasons he explains, but I'm looking for something > a little different. I've looked at RedBean and it seems pretty handy, > but it also requires me to redefine all of the foreign keys I've > already defined, which is annoying. Any hope of something like > > // Get company where name='Widgets Inc.' or id=1 or > $company = $db->get_company("name='Widgets Inc.'"); > > // Get all clients joined to the company > $clients = $company->get_clients(); > > // Get all projects joined to the client > $projects = $clients->get_projects(); > > ? > Have you looked at things like Doctrine2? Regards Peter -- WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind BeWelcome/Couchsurfing: Fake51 Twitter: http://twitter.com/kafe15 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP database interface layer
Hi everyone, I've built a fairly large normalized database schema for a project. This is fun for me as I like thinking about how everything is interconnected. Foreign keys are all set up, many-to-many tables are go, etc, and so on. But now it's time to create an interface between that database and the website using PHP. I've searched the web and this is obviously a very common problem with many solutions, but I can't help but feel that all of the logic I've built into the database is worth nothing once I start coding. I found this article/presentation that essentially sums up my frustration: http://mag-sol.com/talks/lpm/2006/orm/. Up until now I've been working on smaller projects with only a few tables that don't really relate to each other, and have found this tool (http://www.ricocheting.com/code/php/mysql-database-class-wrapper) very handy for the reasons he explains, but I'm looking for something a little different. I've looked at RedBean and it seems pretty handy, but it also requires me to redefine all of the foreign keys I've already defined, which is annoying. Any hope of something like // Get company where name='Widgets Inc.' or id=1 or $company = $db->get_company("name='Widgets Inc.'"); // Get all clients joined to the company $clients = $company->get_clients(); // Get all projects joined to the client $projects = $clients->get_projects(); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Database Abstraction Layer
I once read a great article in the first or second issue of http://www.phparch.com/ on database abstraction layers. At which point I used the tutorial as a starting point for creating a very similar structure I named dbWave. There are only minor differences and a postgresql driver is now included for the most common pg_* functions. I was just wondering if anyone has developed a database abstraction layer that allows you to separate your SQL queries from your application logic like dbWave does? I'm looking for a more advanced way of doing this? Attached is dbWave for anyone to look at/use. To run it you need to use the following tags in your file: // DBWave include files include( "[attached_filename].php" ); To instantiate the dbWave object you use the following code in a file name connect.php connect( 'yourhost', 'yourport', 'yourdbname', 'yourdbuser', 'yourdbpass' ); ?> Thanks, Luke Woollard Programmer / Analyst TABORVISION.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Database
You need to understand the relations between the entities in order to design the database, there are 3 types: 1 to 1: - one team has one couch, no team has more couches and no couch has more teams. - usually in one table (team_name, couch_name), but might be also in two interconnected with keys (team_id, team_name)(team_id, couch_name) 1 to many: - one team has more players, but every playes has only one team - two tables interconnected with key (team_id, team_name)(player_id, team_id, player_name) many to many: - each team plays with more team (this is many to many, but references to the same table, better example would be mailing lists and subscribers, lists have many subscribers and subscribers might participate in more mailing lists) - this is done using another table holding multiple references, but might hold also additional information (domestic_team_id, host_team_id, dom_team_score, host_team_score, match_date) this is about design, but you have to make it yourself, I don't know about it much Steven Priddy wrote: I am looking into how I can make a database like this one that is MySql controlled. http://www.uhlfans.com/uhlstats/ That is one of my partners sites but the guy that created the database can't or won't tell me how to build one myself for a different subject. Thanks for your help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Database
On Friday 15 November 2002 14:00, Steven Priddy wrote: > I am looking into how I can make a database like this one that is MySql > controlled. With a lot of hard work I would say. > http://www.uhlfans.com/uhlstats/ That is one of my partners > sites but the guy that created the database can't or won't tell me how to > build one myself for a different subject. Thanks for your help! Without knowing what your level of knowledge is and exactly what you're expecting as an answer it's very difficult to give you much help. - Do you want a step by step guide? (You've come to the wrong place!) - Do you want some help on general database design? (Search for some database design and sql tutorials). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Volley Theory: It is better to have lobbed and lost than never to have lobbed at all. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Database
I am looking into how I can make a database like this one that is MySql controlled. http://www.uhlfans.com/uhlstats/ That is one of my partners sites but the guy that created the database can't or won't tell me how to build one myself for a different subject. Thanks for your help! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php Database
> Hi everyone! > To use de DBA database format, first i had to configurate php with > --with-db2 option. All works (configure, make and make install). But the > php script still not works. The line of the script that has a problem > is: > > $id = dba_open ("/home/httpd/html/testes/test.db", "n", "db2"); > > Fatal error: Call to undefined function: dba_open() in > /home/httpd/html/testes/teste.php on line 5 That means the --with-db2 didn't take effect somehow. Check the config.log (?) and config.status (?) files and see if you can find out why configure ignored your --with-db2 [Basically, dig around in every config.xxx file you can find in the PHP source directory, and search for db2] Sometimes it does that and doesn't complain about it for some reason... Also, double-check that the library (the libphp.so thingie) in your .../apache/modules/ directory actually has the date you would expect on it. And, stop your Apache and restart it to get it to load the new PHP library. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm -- 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] Php Database
Muito obrigado pela ajuda Michael! Hi everyone! To use de DBA database format, first i had to configurate php with --with-db2 option. All works (configure, make and make install). But the php script still not works. The line of the script that has a problem is: $id = dba_open ("/home/httpd/html/testes/test.db", "n", "db2"); Fatal error: Call to undefined function: dba_open() in /home/httpd/html/testes/teste.php on line 5 That's the error. But, when i looks at phpinfo(), it shows that the php wasn't configurated with --with-db2. I wanna know, how to upgrate the configurations of php... I already tried to delete the config.cache file, but still not working. Anyone knows it? Tks, Sorry for the English... /me from Brazil Scratch -- 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] Php database
Bom dia Vinicius: Yo nao falo o portugues muito bem ... sabes espanol? Si no puedes usar un database SQL, porque no pruebas un database DBA que es un database 'flat file' mas o menos como un '.txt file' ... entonces podrias tratar del data con los funciones DBA de PHP que seguramente son mas faciles. Busca mas informacion sobre DBA en el manual de PHP. Mick On Thu, 1 Feb 2001, Vinicius Garcia wrote: > HI... I always have to work with databases in .txt file. But its very > slow... To find something in the text, i use exec(grep...)... to get all > the text i work with .. while(!eof)... Anyone know how to optimize this > search and how to optimize all the database use using .txt files? > > Sorry for the english... I'm from Brazil... > Tks.. > > Scratch > > > -- > 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] Php database
HI... I always have to work with databases in .txt file. But its very slow... To find something in the text, i use exec(grep...)... to get all the text i work with .. while(!eof)... Anyone know how to optimize this search and how to optimize all the database use using .txt files? Sorry for the english... I'm from Brazil... Tks.. Scratch -- 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]