Re: Re: Formatting
Karl DeSaulniers <[email protected]>
| Newsgroups | gmane.comp.php.database |
|---|---|
| Message-ID | <[email protected]> |
Ethan, is this valid PHP? What is the ampersand for? What is it doing? Just curious. $args[] = &$_POST[$k]; // Note the addition of the ampersand here Karl On Nov 26, 2012, at 12:14 AM, Matt Pelmear wrote: > FYI, this really is not the appropriate mailing list for these types > of questions. > > Are you positive they are empty lines? i.e., are they in the html > code of the page, or only appear as empty space in the rendered page? > > If they are just in the rendered page, in addition to losing the "</ > div>" in the middle of your table (as someone has suggested), you > might also want to check your stylesheets. In particular, this looks > like it could cause some strange things to happen depending on what > you're doing with it: > <td class="first-col"> > > Try loading up firebug and looking at the table element and the > elements around it to see if there is some strange padding. Or, try > disabling any stylesheets you are loading with the page to see if it > still renders in an undesirable way. > > > Good luck, > -Matt > > On 11/25/2012 07:05 PM, Jim Giner wrote: >> On 11/25/2012 5:39 PM, Ethan Rosenberg, PhD wrote: >>> List - >>> >>> Any more ideas. >>> ===== >>> Keep on debugging >>> >>> jg >>> >>> Jim - >>> >>> I've been at this for a few weeks, and am stuck. >>> Thanks for all your help. >>> >>> Ethan >>> >>> +++++++++ >>> >>> On Nov 25, 2012, at 1:59 PM, "Ethan Rosenberg, PhD" >>> <[email protected]> wrote: >>> >>>> On 11/25/2012 12:56 PM, Jim Giner wrote: >>>>> >>>>> On 11/25/2012 12:46 PM, Ethan Rosenberg, PhD wrote: >>>>>> Dear list - >>>>>> >>>>>> When I run the following code, the results are preceded by at >>>>>> least one >>>>>> screen full of blank lines. I am showing you a large code block >>>>>> since I >>>>>> do not know where the error is: >>>>>> >>>>>> if(isset($_REQUEST['Sex'])&& trim($_POST['Sex']) != '' ) >>>>>> { >>>>>> if ($_REQUEST['Sex'] === "0") >>>>>> { >>>>>> $sex = 'Male'; >>>>>> } >>>>>> >>>>>> else >>>>>> { >>>>>> $sex = 'Female'; >>>>>> } >>>>>> >>>>>> } >>>>>> $allowed_fields = array >>>>>> ('Site' => 's', 'MedRec' => 'i', 'Fname' => 's', >>>>>> 'Lname' => 's','Phone'=> 's', 'Height' => 'i', 'Sex' => 's', >>>>>> 'Hx' => 's','Bday' => 's', 'Age' => 'i' >>>>>> ); >>>>>> >>>>>> if(empty($allowed_fields)) >>>>>> { >>>>>> echo "ouch"; >>>>>> } >>>>>> >>>>>> // Configure the query and the acceptable params to >>>>>> put >>>>>> into the WHERE clause >>>>>> $sql12 = 'SELECT * FROM Intake3 WHERE 1'; >>>>>> >>>>>> // Magically put everything together >>>>>> $types = ''; >>>>>> $args = array(); >>>>>> foreach( $allowed_fields as $k => $type ) >>>>>> { >>>>>> if( !array_key_exists( $k, $allowed_fields ) ) >>>>>> continue; >>>>>> else >>>>>> { >>>>>> if( ($_POST[$k]) != '') >>>>>> { >>>>>> $args[] = &$_POST[$k]; // Note the >>>>>> addition of >>>>>> the ampersand here >>>>>> $types .= $type; >>>>>> $sql12 .= " AND ($k = ?)"; >>>>>> } >>>>>> } >>>>>> } >>>>>> $stmt = mysqli_stmt_init($cxn); >>>>>> mysqli_stmt_prepare( $stmt, $sql12 ); >>>>>> >>>>>> if( !$stmt ) >>>>>> throw new Exception( 'Error preparing >>>>>> statement' ); >>>>>> >>>>>> // Put the statement and types variables at the >>>>>> front of >>>>>> the params to pass to mysqli_stmt_bind_param() >>>>>> array_unshift( $args, $stmt, $types ); // Note that >>>>>> I've >>>>>> moved this call. Apparently it doesn't pass back the result. I >>>>>> guess >>>>>> sometimes I just forget these things. >>>>>> >>>>>> // mysqli_stmt_bind_param() >>>>>> if( !call_user_func_array( 'mysqli_stmt_bind_param', >>>>>> $args ) ) >>>>>> throw new Exception( 'Failed calling >>>>>> mysqli_stmt_bind_param' ); >>>>>> >>>>>> if( !mysqli_stmt_execute( $stmt ) ) >>>>>> throw new Exception( 'Error while executing >>>>>> statement' ); >>>>>> >>>>>> mysqli_stmt_bind_result( $stmt, $Site, $MedRec, >>>>>> $Fname, >>>>>> $Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age); >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> if(count($errors_array) == 0) >>>>>> { >>>>>> >>>>>> >>>>>> ?> >>>>>> <center><b>Search Results</b></center><br /> >>>>>> <center> >>>>>> <!-- This is the block that prints about one screen full down >>>>>> bellow >>>>>> the Search Results header --> >>>>>> >>>>>> <table border="4" cellpadding="5" cellspacing="55" rules="all" >>>>>> frame="box" style="table-layout: fixed;"> >>>>>> <tr class="heading"> >>>>>> <th>Site</th> >>>>>> <th>Medical Record</th> >>>>>> <th>First Name</th> >>>>>> <th>Last Name</th> >>>>>> <th>Phone</th> >>>>>> <th>Height</th> >>>>>> <th>Sex</th> >>>>>> <th>History</th> >>>>>> <th>Birthday</th> >>>>>> <th>Age</th> >>>>>> </tr> >>>>>> </div> >>>>>> >>>>>> <?php $i = 0; >>>>>> do >>>>>> { >>>>>> { >>>>>> $vara2 = array(array($Site, $MedRec, >>>>>> $Fname, >>>>>> $Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age)); >>>>>> >>>>>> $vara2[$i][0] = $Site; >>>>>> $vara2[$i][1] = $MedRec; >>>>>> $vara2[$i][2] = $Fname; >>>>>> $vara2[$i][3] = $Lname; >>>>>> $vara2[$i][4] = $Phone; >>>>>> $vara2[$i][5] = $Height; >>>>>> $vara2[$i][6] = $Sex; >>>>>> $vara2[$i][7] = $Hx; >>>>>> $vara2[$i][8] = $Bday; >>>>>> $vara2[$i][9] = $Age; >>>>>> >>>>>> echo "<tr>\n"; >>>>>> $_SESSION['exe'] = 2; >>>>>> ?> >>>>>> <td> <?php echo $vara2[$i][0]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][1]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][2]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][3]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][4]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][5]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][6]?> </td><br /> >>>>>> <td class="first-col"><?php echo $vara2[$i][7] ?></td><br /> >>>>>> <td> <?php echo $vara2[$i][8]?> </td><br /> >>>>>> <td> <?php echo $vara2[$i][9]?> </td><br /> >>>>>> <?php echo "</tr>\n"; >>>>>> $i = $i +1; >>>>>> >>>>>> } >>>>>> } while (mysqli_stmt_fetch($stmt)); //end do- >>>>>> while >>>>>> $imax = $i; >>>>>> echo "</table>"; >>>>>> echo "</center>"; >>>>>> echo "</form>"; >>>>>> >>>>>> } // end count($errors_array) >>>>>> >>>>>> Help and advice, please >>>>>> >>>>>> Ethan >>>>>> >>>>> If this is the ACTUAL code you are executing you need to >>>>> remember to >>>>> NOT include any blank lines. Each and every one gets echoed to >>>>> the >>>>> client and with all the blank lines I see above, that could very >>>>> well >>>>> be a full but empty page. >>>>> >>>> +++++++++++++ >>>> Jim - >>>> >>>> Thank you. >>>> >>>> I removed all the blank lines, and get the same behavior. >>>> >>>> Ethan >>>> >>>> Ethan >>> >> I see nothing in this code but you really should do some more >> debugging. Add some echos all around in your script so you can see >> where the blank lines are coming from. Come on - we can't do your >> work for you - you have to be creative and find a way to isolate >> and identify your problem. >> > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php