Re: [PHP-DB] Re: Formatting
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 erosenb...@hygeiabiomedical.com 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) { ? centerbSearch Results/b/centerbr / 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 thSite/th thMedical Record/th thFirst Name/th thLast Name/th thPhone/th thHeight/th thSex/th thHistory/th thBirthday/th thAge/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;
RE: [PHP-DB] Re: Formatting
-Original Message- From: Karl DeSaulniers [mailto:k...@designdrumm.com] Sent: 26 November 2012 08:48 To: php-db@lists.php.net Subject: Re: [PHP-DB] Re: Formatting 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 That's a perfectly valid reference assignment. Please see the Fine Manual at: http://php.net/manual/language.references.whatdo.php Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Portland PD507, City Campus, Leeds Metropolitan University, Portland Way, LEEDS, LS1 3HE, United Kingdom E: m.f...@leedsmet.ac.uk T: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Formatting - Solved
Dear list Here is the answer ORIGINAL centerbSearch Results/b/centerbr / 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 thSite/th thMedical Record/th thFirst Name/th thLast Name/th thPhone/th thHeight/th thSex/th thHistory/th thBirthday/th thAge/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]? /tdbr / td ?php echo $vara2[$i][1]? /tdbr / td ?php echo $vara2[$i][2]? /tdbr / td ?php echo $vara2[$i][3]? /tdbr / td ?php echo $vara2[$i][4]? /tdbr / td ?php echo $vara2[$i][5]? /tdbr / td ?php echo $vara2[$i][6]? /tdbr / td class=first-col?php echo $vara2[$i][7] ?/tdbr / td ?php echo $vara2[$i][8]? /tdbr / td ?php echo $vara2[$i][9]? /tdbr / ?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) THIS IS THE CORRECTED VERSION: if(count($errors_array) == 0) { ? centerbSearch Results/b/centerbr / center table border=4 cellpadding=5 cellspacing=55 rules=all frame=box style=table-layout: fixed; tr class=heading thSite/th thMedical Record/th thFirst Name/th thLast Name/th thPhone/th thHeight/th thSex/th thHistory/th thBirthday/th thAge/th ?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; ? tr td ?php echo $vara2[$i][0]? /td td ?php echo $vara2[$i][1]? /td td ?php echo $vara2[$i][2]? /td td ?php echo $vara2[$i][3]? /td td ?php echo $vara2[$i][4]? /td td ?php echo $vara2[$i][5]? /td td ?php echo $vara2[$i][6]? /td td class=first-col?php echo $vara2[$i][7] ?/td td ?php echo $vara2[$i][8]? /td td ?php echo $vara2[$i][9]? /td ?php echo /tr\n; $i = $i +1; } } while (mysqli_stmt_fetch($stmt)); //end do-while $imax = $i; echo /table; echo /center; echo /form; ? ?php }//end count($errors_array) NOTE THE ABSENCE OF the br / AFTER EACH td LINE That was the problem!!! Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Formatting - Solved
On 11/26/2012 1:04 PM, Ethan Rosenberg, PhD wrote: Dear list Here is the answer ORIGINAL centerbSearch Results/b/centerbr / 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 thSite/th thMedical Record/th thFirst Name/th thLast Name/th thPhone/th thHeight/th thSex/th thHistory/th thBirthday/th thAge/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]? /tdbr / td ?php echo $vara2[$i][1]? /tdbr / td ?php echo $vara2[$i][2]? /tdbr / td ?php echo $vara2[$i][3]? /tdbr / td ?php echo $vara2[$i][4]? /tdbr / td ?php echo $vara2[$i][5]? /tdbr / td ?php echo $vara2[$i][6]? /tdbr / td class=first-col?php echo $vara2[$i][7] ?/tdbr / td ?php echo $vara2[$i][8]? /tdbr / td ?php echo $vara2[$i][9]? /tdbr / ?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) THIS IS THE CORRECTED VERSION: if(count($errors_array) == 0) { ? centerbSearch Results/b/centerbr / center table border=4 cellpadding=5 cellspacing=55 rules=all frame=box style=table-layout: fixed; tr class=heading thSite/th thMedical Record/th thFirst Name/th thLast Name/th thPhone/th thHeight/th thSex/th thHistory/th thBirthday/th thAge/th ?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; ? tr td ?php echo $vara2[$i][0]? /td td ?php echo $vara2[$i][1]? /td td ?php echo $vara2[$i][2]? /td td ?php echo $vara2[$i][3]? /td td ?php echo $vara2[$i][4]? /td td ?php echo $vara2[$i][5]? /td td ?php echo $vara2[$i][6]? /td td class=first-col?php echo $vara2[$i][7] ?/td td ?php echo $vara2[$i][8]? /td td ?php echo $vara2[$i][9]? /td ?php echo /tr\n; $i = $i +1; } } while (mysqli_stmt_fetch($stmt)); //end do-while $imax = $i; echo /table; echo /center; echo /form; ? ?php }//end count($errors_array) NOTE THE ABSENCE OF the br / AFTER EACH td LINE That was the problem!!! Ethan Did not notice; was not looking for them. Of course if you knew about html tables you would know not to put them in there. A little knowledge seems to be the root of all your bugs once again. You really should read up on HEREDOCS in the php manual. It will save you mucho amounts of typing and confusion when mixing php and html code. Ex. $code =heredocs tr td$vara2[$i][0]/td td$vara2[$i][1]/td td$vara2[$i][2]/td td$vara2[$i][3]/td td$vara2[$i][4]/td td$vara2[$i][5]/td td$vara2[$i][6]/td td class=first-col$vara2[$i][7]/td td$vara2[$i][8]/td td$vara2[$i][9]/td /tr heredocs; echo $code; This does all that you code does with much less chafe in the code. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] CSV storage InnoDB?
Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysqli_bind_result
Dear List - Here is some code: $sql13 = SELECT * FROM Intake3 WHERE MedRec = ?; $stmt = mysqli_stmt_init($cxn); mysqli_stmt_prepare( $stmt, $sql13 ); $_SESSION['stmt'] = $stmt; $args = array(); $args[0] = $_POST['MR']; $types = 'i'; 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); throw new Exception( 'Failed calling mysqli_stmt_bind_result' ); Fatal error: Uncaught exception 'Exception' with message 'Failed calling mysqli_stmt_bind_result' What is my error?? FYI - MR comes from here -- centerstrongDo you Wish to Enter Visit Data?/center centerIf Yes:/center form name=form2 method=post centerChoose the Medical Record that You Wish to Use/strong/center form method=post centerinput type=text name=MR/input/center centerinput type=submit value=Enter Medical Record//center input type=hidden name=next_step value=step10 / /form Advice and help, please. Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
On Nov 26, 2012, at 7:29 PM, Bastien wrote: Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien Hi Bastien, Thanks for your reply. Sorry, I should have elaborated. There is a table that holds all the discount codes. Keeps them grouped with a product id or if they are to be applied cart wide. So the field I am asking for will hold codes that are being used by either a product or by a user or if it is a cart discount. Each have their own tables, the products, the users and the cart. In these tables is where I need to insert this field. An example of the discount table would be like: Discount table: | discount code | product id | discount perc. | discount type | +-+-+-- +---+ |8lKzv_=== | 22 | 20 | item | +-+-+-- +---+ | NpLK23 | 0 | 50 | cart | +-+-+-- +---+ but in the user table for instance: User table: | user_discounts | +---+ |8lKzv_===, YjMlio_===, NpLK23, hDflp0_=| +---+ Just trying to figure out the best way to store multiple variables if you will in one field like so. Or if this is even the best way to do such a thing. I am open to alternatives. I will need to read this new filed out of the database as an array that I can then utilize with an in_array or something of the sort. There may be a best practices on this that I am not aware of with my somewhat limited PHP exp. Hope that makes more sense. TIA. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
On Nov 26, 2012, at 8:01 PM, Karl DeSaulniers wrote: On Nov 26, 2012, at 7:29 PM, Bastien wrote: Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien Hi Bastien, Thanks for your reply. Sorry, I should have elaborated. There is a table that holds all the discount codes. Keeps them grouped with a product id or if they are to be applied cart wide. So the field I am asking for will hold codes that are being used by either a product or by a user or if it is a cart discount. Each have their own tables, the products, the users and the cart. In these tables is where I need to insert this field. An example of the discount table would be like: Discount table: | discount code | product id | discount perc. | discount type | +-+- +--+---+ |8lKzv_=== | 22 | 20 | item | +-+- +--+---+ | NpLK23 | 0 | 50 | cart | +-+- +--+---+ but in the user table for instance: User table: | user_discounts | +---+ |8lKzv_===, YjMlio_===, NpLK23, hDflp0_=| +---+ Just trying to figure out the best way to store multiple variables if you will in one field like so. Or if this is even the best way to do such a thing. I am open to alternatives. I will need to read this new filed out of the database as an array that I can then utilize with an in_array or something of the sort. There may be a best practices on this that I am not aware of with my somewhat limited PHP exp. Hope that makes more sense. TIA. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think I may have asked this already a year or so ago, but cannot find my old emails. Sorry for any redundancy. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
Unsuscribe me please. Thanks El 26/11/12 23:01, Karl DeSaulniers escribió: On Nov 26, 2012, at 7:29 PM, Bastien wrote: Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien Hi Bastien, Thanks for your reply. Sorry, I should have elaborated. There is a table that holds all the discount codes. Keeps them grouped with a product id or if they are to be applied cart wide. So the field I am asking for will hold codes that are being used by either a product or by a user or if it is a cart discount. Each have their own tables, the products, the users and the cart. In these tables is where I need to insert this field. An example of the discount table would be like: Discount table: | discount code | product id | discount perc. | discount type | +-+-+--+---+ |8lKzv_=== | 22 | 20 | item | +-+-+--+---+ | NpLK23 | 0 | 50 | cart | +-+-+--+---+ but in the user table for instance: User table: | user_discounts | +---+ |8lKzv_===, YjMlio_===, NpLK23, hDflp0_=| +---+ Just trying to figure out the best way to store multiple variables if you will in one field like so. Or if this is even the best way to do such a thing. I am open to alternatives. I will need to read this new filed out of the database as an array that I can then utilize with an in_array or something of the sort. There may be a best practices on this that I am not aware of with my somewhat limited PHP exp. Hope that makes more sense. TIA. Best, Karl DeSaulniers Design Drumm http://designdrumm.com U } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysqli_bind_result
On Mon, Nov 26, 2012 at 7:28 PM, Ethan Rosenberg, PhD erosenb...@hygeiabiomedical.com wrote: Dear List - Here is some code: $sql13 = SELECT * FROM Intake3 WHERE MedRec = ?; $stmt = mysqli_stmt_init($cxn); mysqli_stmt_prepare( $stmt, $sql13 ); $_SESSION['stmt'] = $stmt; $args = array(); $args[0] = $_POST['MR']; $types = 'i'; 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); throw new Exception( 'Failed calling mysqli_stmt_bind_result' ); Fatal error: Uncaught exception 'Exception' with message 'Failed calling mysqli_stmt_bind_result' What is my error?? FYI - MR comes from here -- centerstrongDo you Wish to Enter Visit Data?/center centerIf Yes:/center form name=form2 method=post centerChoose the Medical Record that You Wish to Use/strong/center form method=post centerinput type=text name=MR/input/center centerinput type=submit value=Enter Medical Record//center input type=hidden name=next_step value=step10 / /form Advice and help, please. Ethan -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php From the looks of this, you are calling the throw all the time: mysqli_stmt_bind_result( $stmt, $Site, $MedRec, $Fname, $Lname, $Phone, $Height, $Sex, $Hx, $Bday, $Age); throw new Exception( 'Failed calling mysqli_stmt_bind_result' ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
Karl, Typically I would do this as multiple rows rather than comma-separated data in one field. If you go this route, you may consider adding an unsigned int primary key (with auto increment) on the discounts table so you consume less storage space and can do joins more quickly. `discounts`: id discount_code product_id_or_whatever 1sfeijfkjx 34 2kbgrlijf 36 `user_discounts`: user_id discount_id 1231 1232 4563 If you really needed to SELECT the data with comma separation, you could use something like GROUP_CONCAT (http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat), but I would try to avoid that. This is a very basic design principle for relational databases. You may want to do some more reading about database architecture in general. That said, you could use a TEXT field to store a comma separated list, I just wouldn't recommend doing it that way. -Matt On 11/26/2012 06:01 PM, Karl DeSaulniers wrote: On Nov 26, 2012, at 7:29 PM, Bastien wrote: Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien Hi Bastien, Thanks for your reply. Sorry, I should have elaborated. There is a table that holds all the discount codes. Keeps them grouped with a product id or if they are to be applied cart wide. So the field I am asking for will hold codes that are being used by either a product or by a user or if it is a cart discount. Each have their own tables, the products, the users and the cart. In these tables is where I need to insert this field. An example of the discount table would be like: Discount table: | discount code | product id | discount perc. | discount type | +-+-+--+---+ |8lKzv_=== | 22 | 20 | item | +-+-+--+---+ | NpLK23 | 0 | 50 | cart | +-+-+--+---+ but in the user table for instance: User table: | user_discounts | +---+ |8lKzv_===, YjMlio_===, NpLK23, hDflp0_=| +---+ Just trying to figure out the best way to store multiple variables if you will in one field like so. Or if this is even the best way to do such a thing. I am open to alternatives. I will need to read this new filed out of the database as an array that I can then utilize with an in_array or something of the sort. There may be a best practices on this that I am not aware of with my somewhat limited PHP exp. Hope that makes more sense. TIA. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
On Mon, Nov 26, 2012 at 8:10 PM, Karl DeSaulniers k...@designdrumm.com wrote: On Nov 26, 2012, at 8:01 PM, Karl DeSaulniers wrote: On Nov 26, 2012, at 7:29 PM, Bastien wrote: Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien Hi Bastien, Thanks for your reply. Sorry, I should have elaborated. There is a table that holds all the discount codes. Keeps them grouped with a product id or if they are to be applied cart wide. So the field I am asking for will hold codes that are being used by either a product or by a user or if it is a cart discount. Each have their own tables, the products, the users and the cart. In these tables is where I need to insert this field. An example of the discount table would be like: Discount table: | discount code | product id | discount perc. | discount type | +-+-+--+---+ |8lKzv_=== | 22 | 20 | item | +-+-+--+---+ | NpLK23 | 0 | 50 | cart | +-+-+--+---+ but in the user table for instance: User table: | user_discounts | +---+ |8lKzv_===, YjMlio_===, NpLK23, hDflp0_=| +---+ Just trying to figure out the best way to store multiple variables if you will in one field like so. Or if this is even the best way to do such a thing. I am open to alternatives. I will need to read this new filed out of the database as an array that I can then utilize with an in_array or something of the sort. There may be a best practices on this that I am not aware of with my somewhat limited PHP exp. Hope that makes more sense. TIA. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think I may have asked this already a year or so ago, but cannot find my old emails. Sorry for any redundancy. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi, Karl, Your idea can work -- storing the list of discount codes as comma delimited (or some known delimiter that won't show up in the codes) is pretty easy, and when you fetch it out you can explode it into an array, and use in_array to check. (Something you might want to consider is storing it as a JSON string as well.) There's also the right way to do this, for some value of right, which is the many-to-many relationship using a foreign key table. This can be painful if you're not really strong on SQL, especially dealing with updates and deletes. (Example: if you delete a discount code, you need to delete the associated records in the foreign key table.) Generally this sort of operation is best done as stored procedures, rather than multiple queries from PHP. Question: do the discount codes only apply to one product, or can a discount code be used for several products? If the latter, then you have the same sort of issue of a many-to-many relationship, requiring the foreign key table there... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB?
On Nov 26, 2012, at 9:22 PM, tamouse mailing lists wrote: On Mon, Nov 26, 2012 at 8:10 PM, Karl DeSaulniers k...@designdrumm.com wrote: On Nov 26, 2012, at 8:01 PM, Karl DeSaulniers wrote: On Nov 26, 2012, at 7:29 PM, Bastien wrote: Bastien Koert On 2012-11-26, at 7:43 PM, Karl DeSaulniers k...@designdrumm.com wrote: Hello all, Quick question. What is the best way to store a comma separated list of discount codes in a InnoDB? Text, varchar, blob, ? I want to be able to store discount codes offered to users in their profile, in their cart, etc. So I am thinking of storing the codes as a comma separated list that I can then refer to, add to or remove codes from. The codes will change every once and a while and they list of codes may be rather large after say a year, so I am shying away from an enum() or anything like that. Any help/pointers is greatly appreciated. Best, Karl -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Karl. Is there a way to group these codes? Can profiles be the same for different users? If so another table for the code and a join table for the users to codes might be simpler to manage Bastien Hi Bastien, Thanks for your reply. Sorry, I should have elaborated. There is a table that holds all the discount codes. Keeps them grouped with a product id or if they are to be applied cart wide. So the field I am asking for will hold codes that are being used by either a product or by a user or if it is a cart discount. Each have their own tables, the products, the users and the cart. In these tables is where I need to insert this field. An example of the discount table would be like: Discount table: | discount code | product id | discount perc. | discount type | +-+- +--+---+ |8lKzv_=== | 22 | 20 | item | +-+- +--+---+ | NpLK23 | 0 | 50 | cart | +-+- +--+---+ but in the user table for instance: User table: | user_discounts | +---+ |8lKzv_===, YjMlio_===, NpLK23, hDflp0_=| +---+ Just trying to figure out the best way to store multiple variables if you will in one field like so. Or if this is even the best way to do such a thing. I am open to alternatives. I will need to read this new filed out of the database as an array that I can then utilize with an in_array or something of the sort. There may be a best practices on this that I am not aware of with my somewhat limited PHP exp. Hope that makes more sense. TIA. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I think I may have asked this already a year or so ago, but cannot find my old emails. Sorry for any redundancy. Best, Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi, Karl, Your idea can work -- storing the list of discount codes as comma delimited (or some known delimiter that won't show up in the codes) is pretty easy, and when you fetch it out you can explode it into an array, and use in_array to check. (Something you might want to consider is storing it as a JSON string as well.) There's also the right way to do this, for some value of right, which is the many-to-many relationship using a foreign key table. This can be painful if you're not really strong on SQL, especially dealing with updates and deletes. (Example: if you delete a discount code, you need to delete the associated records in the foreign key table.) Generally this sort of operation is best done as stored procedures, rather than multiple queries from PHP. Question: do the discount codes only apply to one product, or can a discount code be used for several products? If the latter, then you have the same sort of issue of a many-to-many relationship, requiring the foreign key table there... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Hi guys, Thanks for your responses. I do have a auto incremented id for the codes. Yes multiple product can have the same code. Table is as follows. CREATE TABLE `discounts` ( `d_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `p_id` int(10) unsigned
Re: [PHP-DB] CSV storage InnoDB?
BLOB and TEXT are basically the same thing, except that BLOB can be used for storing binary data (like an image). You would only need one additional table to do what I was describing, but if you're dead-set on using a comma separated list then TEXT or LONGTEXT is probably what you want, depending on how large you anticipate those lists becoming. If you care about efficiency you may want to look at this blog post: http://www.mysqlperformanceblog.com/2010/02/09/blob-storage-in-innodb/ -Matt On 11/26/2012 09:55 PM, Karl DeSaulniers wrote: Hi guys, Thanks for your responses. I do have a auto incremented id for the codes. Yes multiple product can have the same code. Table is as follows. CREATE TABLE `discounts` ( `d_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `p_id` int(10) unsigned NOT NULL DEFAULT '0', `d_discode` varchar(16) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_type` enum('item','cart') NOT NULL DEFAULT 'item', `d_discamt` float(5,2) unsigned NOT NULL DEFAULT '0.00', `d_discper` int(3) unsigned NOT NULL DEFAULT '0', `d_qty` int(10) unsigned NOT NULL DEFAULT '0', `d_description` varchar(25) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_expire` datetime NOT NULL DEFAULT '-00-00 00:00:00', `d_user` varchar(30) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_userip` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_date` datetime NOT NULL DEFAULT '-00-00 00:00:00', PRIMARY KEY (`d_id`), KEY `d_discode` (`d_discode`), KEY `d_expire` (`d_expire`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; This is where the discounts and their codes and any info are stored including who set the discount (this user does not apply to our situation, FYI). Then in say the user table I set the codes that user gets to use. ... `u_discodes` (???This is my question. What to use???) CHARACTER SET utf8 NOT NULL DEFAULT '', ... I just need to store the separate codes a user has available to them here. So what would be the best suited? I am thinking a blob or text, because like tamouse said, I can explode the results and or check an in_array on the results. It seems the logical route to me for what I am doing. u_discodes just is a reference to check against. I then apply the amounts or percentages according to what is in the discounts table for that code. Am I moling this? Missing something? I'd like ( I guess ) to stay away from creating separate tables that hold the references for users, products, carts, etc and their codes. To me the blob seems so much simpler. But alas, I may have answered my own question. : \ Best, Karl Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] CSV storage InnoDB? - Solved
You have a valid point there Matt. Not dead set. Table it is. Thanks guys. Best, Karl On Nov 27, 2012, at 12:30 AM, Matt Pelmear wrote: BLOB and TEXT are basically the same thing, except that BLOB can be used for storing binary data (like an image). You would only need one additional table to do what I was describing, but if you're dead-set on using a comma separated list then TEXT or LONGTEXT is probably what you want, depending on how large you anticipate those lists becoming. If you care about efficiency you may want to look at this blog post: http://www.mysqlperformanceblog.com/2010/02/09/blob-storage-in-innodb/ -Matt On 11/26/2012 09:55 PM, Karl DeSaulniers wrote: Hi guys, Thanks for your responses. I do have a auto incremented id for the codes. Yes multiple product can have the same code. Table is as follows. CREATE TABLE `discounts` ( `d_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `p_id` int(10) unsigned NOT NULL DEFAULT '0', `d_discode` varchar(16) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_type` enum('item','cart') NOT NULL DEFAULT 'item', `d_discamt` float(5,2) unsigned NOT NULL DEFAULT '0.00', `d_discper` int(3) unsigned NOT NULL DEFAULT '0', `d_qty` int(10) unsigned NOT NULL DEFAULT '0', `d_description` varchar(25) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_expire` datetime NOT NULL DEFAULT '-00-00 00:00:00', `d_user` varchar(30) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_userip` varchar(15) CHARACTER SET utf8 NOT NULL DEFAULT '', `d_date` datetime NOT NULL DEFAULT '-00-00 00:00:00', PRIMARY KEY (`d_id`), KEY `d_discode` (`d_discode`), KEY `d_expire` (`d_expire`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; This is where the discounts and their codes and any info are stored including who set the discount (this user does not apply to our situation, FYI). Then in say the user table I set the codes that user gets to use. ... `u_discodes` (???This is my question. What to use???) CHARACTER SET utf8 NOT NULL DEFAULT '', ... I just need to store the separate codes a user has available to them here. So what would be the best suited? I am thinking a blob or text, because like tamouse said, I can explode the results and or check an in_array on the results. It seems the logical route to me for what I am doing. u_discodes just is a reference to check against. I then apply the amounts or percentages according to what is in the discounts table for that code. Am I moling this? Missing something? I'd like ( I guess ) to stay away from creating separate tables that hold the references for users, products, carts, etc and their codes. To me the blob seems so much simpler. But alas, I may have answered my own question. : \ Best, Karl Karl DeSaulniers Design Drumm http://designdrumm.com -- 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