[PHP-DB] Cookie problem
Hi, I'm trying to use PHP to set a cookie to recognize people returning within a month. However no matter how i use the code, no cookie is being set. I've been in touch with my host, who assures me that cookies function in the 'normal' way on their servers, so its probably something wrong with my code. I'm using this: $time = mktime()+(60*60*24*30); setcookie('lifevision', $dist_id, $time, '/', 'www.dono.co.uk','0'); i've also tried without the www and without the www. in the domain. To test if the cookie is being set, the url www.dono.co.uk/testing/ should set a cookie. It also starts a session for people who can't accept cookies. (i've also put a print_r at the end of the page to print the cookie contents, if any) However the cookie just isnt appearing. Any suggestions appreciated, Don
[PHP-DB] Re: Subject: Cookie problem
First check that you are not sending any content before trying to set the cookie : It effectively is sending a header, and headers must be sent before any other content - even a white space before your PHP script which sets your cookie will send headers so then your cookie will not be set. You can check if headers have been sent with the convenient headers_sent() PHP function, which returns true if headers have already been sent. That's the most likely diagnosis IME, if everything else checks out. Cheers - Neil. At 13:26 07/02/2004 +, you wrote: From: Donovan Hutchinson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Date: Sat, 7 Feb 2004 13:26:25 - MIME-Version: 1.0 Content-Type: multipart/alternative; boundary==_NextPart_000_0039_01C3ED7D.FC683AD0 Message-ID: [EMAIL PROTECTED] Subject: Cookie problem Hi, I'm trying to use PHP to set a cookie to recognize people returning within a month. However no matter how i use the code, no cookie is being set. I've been in touch with my host, who assures me that cookies function in the 'normal' way on their servers, so its probably something wrong with my code. I'm using this: $time = mktime()+(60*60*24*30); setcookie('lifevision', $dist_id, $time, '/', 'www.dono.co.uk','0'); i've also tried without the www and without the www. in the domain. To test if the cookie is being set, the url www.dono.co.uk/testing/ should set a cookie. It also starts a session for people who can't accept cookies. (i've also put a print_r at the end of the page to print the cookie contents, if any) However the cookie just isnt appearing. Any suggestions appreciated, Don CaptionKit http://www.captionkit.com : Production tools for accessible subtitled internet media, transcripts and searchable video. Supports Real Player, Quicktime and Windows Media Player. VideoChat with friends online, get Freshly Toasted every day at http://www.fresh-toast.net : NetMeeting solutions for a connected world. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Question
Dear friends, On submitting form to mysql database I get a parse error,There is no problem with connection code, Problem is some where around create the sql statement Can any one figure out where is the precise error, please. Following is the code from php file ?php // open the connection $conn = mysql_connect(localhost, , ); // pick the database to use mysql_select_db(testDB,$conn); // create the SQL statement $sql = INSERT INTO testtable values ('{$_POST[testField]}',' {$_POST[testFielda]}','{$_POST[testFieldb]}','{$_POST[testFieldd]}',' {$_POST[testFieldc]}','{$_POST[testFielde]}'); // execute the SQL statement if (mysql_query($sql, $conn)) { echo record added!; } else { echo something went wrong; } ? - Asif
[PHP-DB] Re: substr() problems
I don't see anything initially wrong with this statement, but you might try a variation and see what you get. First: condense this: $DB_sub_ref = substr($DB_temp_ref , 0, 1); $DB_sub_ref .= substr($DB_temp_ref , 1, 1); to this: $DB_sub_ref = substr($DB_temp_ref , 0, 2); Your code will run slightly faster... Second change the third line there to: $DB_sub_ref .= substr($DB_temp_ref , -1); That should do the same thing, grab the last character in that string. Try that and see what you get. Jeremy James Meers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all, I am trying to use substr() negative start, but I get nothing returned - if i do a positive start then i do get something back, below is my code and a line of what i get returned: $DB_ref = 210020007; $DB_temp_ref = $DB_ref; $DB_sub_ref = substr($DB_temp_ref , 0, 1); $DB_sub_ref .= substr($DB_temp_ref , 1, 1); $DB_sub_ref .= substr($DB_temp_ref , -1, 1); echo $DB_sub_ref - $DB_ref; RESULT: 21 - 210020007 note: 210020007 is an example this is actually within a while statement using mysql_fetch_array from a SQL query - all results are not returning the negative string. Can anyone help? PHP Version 4.3.3 Apache/2.0.47 (Fedora) Many thanks in advance, James. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] page hit tracking
even simpler you could add a counter column to each vegetable table and increment it...that will save you an extra table. Jeremy Ricardo Lopes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] you could create a counter table and store there the vegetable id and the hits. After that each time you search for a vegetable, make an update to the table. - Original Message - From: js [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 06, 2004 8:18 AM Subject: [PHP-DB] page hit tracking i am using php MySQL and i want to know how i can make a hidden value for certain entries in a table and how many times they are called. for instance, say i have a table of vegetables people can look at. the page displays all of the vegetables, and then it generates links to each one and if the user clicks on one then the page just calls itself and displays more information about the vegetables. now, how do i make a counter where theres a field in the table where it increases by 1 everytime someone looks at a particular vegetable. i really am new to this so thank you for your help. thanks -james -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Question
Quotes: $_POST['testField'] _ - Original Message - From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 20:36 Subject: [PHP-DB] Question Dear friends, On submitting form to mysql database I get a parse error,There is no problem with connection code, Problem is some where around create the sql statement Can any one figure out where is the precise error, please. Following is the code from php file ?php // open the connection $conn = mysql_connect(localhost, , ); // pick the database to use mysql_select_db(testDB,$conn); // create the SQL statement $sql = INSERT INTO testtable values ('{$_POST[testField]}',' {$_POST[testFielda]}','{$_POST[testFieldb]}','{$_POST[testFieldd]}',' {$_POST[testFieldc]}','{$_POST[testFielde]}'); // execute the SQL statement if (mysql_query($sql, $conn)) { echo record added!; } else { echo something went wrong; } ? -- --- Asif -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] php to mysql client problem.
This is my setup: Not really worried about security. W2kPro w\sp4 Mysql 5.O Mysqlcc0.9.4 Php 5.0.0.b3 [As CGI] Apache2.0.48 I can now connect to my server from anywhere using Mysqlcc or another server... home, work, etc. I can run Php scripts. I can connect to the Apache Server. Login to Mysql: Works. ==C:\mysql -u mike -p ==Enter password: ==Welcome to the MySQL monitor. Commands end with ; or \g. ==Your MySQL connection id is 28 to server version: 5.0.0-alpha-max-nt ==Type 'help;' or '\h' for help. Type '\c' to clear the buffer. PhpInfo Shows: ==MySQL Support enabled ==Active Persistent Links 0 ==Active Links 0 ==Client API version 3.23.57 ==Directive Local Value Master Value ==mysql.allow_persistent On On ==mysql.connect_timeout 60 60 ==mysql.default_host localhost localhost ==mysql.default_password no value no value ==mysql.default_port 3306 3306 ==mysql.default_socket no value no value ==mysql.default_user root root ==mysql.max_links Unlimited Unlimited ==mysql.max_persistent Unlimited Unlimited ==mysql.trace_mode Off Off I Try to connect from PHP and I get: ==Not connected : Client does not support authentication protocol ==requested by server; consider upgrading MySQL client Could this be the Reason?: From the PHP info above. ==Client API version 3.23.57== I'm thinking yes, but since copying the new files to the same directory overwrote all the others, is this the client version for all servers currently?? If not how do I force it to update. I have all the servers working. I don't really at this point want to delete anything. Michael G. Tracey ___ Join Excite! - http://www.excite.com The most personalized portal on the Web! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mktime question
i have a page that displays an essay someone has written. and people who come to the site can submit comments. the comments are taken quickly in a form and posted. everything is posting perfect except for the time to get the time i dont know what to use? time() or date() or mktime() ??? im really stuck. i dont know how to submit the time to the MySQL database so it takes the correct format for the time area. i have a substr() script that formats it when it is retrived and displayed, but i do not know how to make the INSERT INTO with the time. if you can help me out i thank you! -james
Re: [PHP-DB] Question
Dear friend, I changed $_POST['testField'] instead of $_post[testField] Before it was returning parse error now it doesnt return any error nor writes to mysql database, however I used following sql staatement which wrote to database before // create the SQL statement $sql = INSERT INTO testTable values ('', '$_POST[testField]'); Now I have added more columns to database and form and made similar changes in the php script, now it doesnt write with this sql statement to database // create the SQL statement $sql = INSERT INTO testtable values ('{$_POST[testField]}',' {$_POST[testFielda]}','{$_POST[testFieldb]}','{$_POST[testFieldd]}',' {$_POST[testFieldc]}','{$_POST[testFielde]}'); Any advice, please. Asif
[PHP-DB] Form doesnt write to database
Dear friends, Form doesn't write to mysql database. I have pasted code of mysal table structure,html form and php script. Any comments, please. -- mysql describe testtable; ++-+--+-+-++ | Field | Type| Null | Key | Default | Extra | ++-+--+-+-++ | id | int(4) | | PRI | NULL| auto_increment | | testField | varchar(10) | | | || | testFielda | varchar(10) | | | || | testFieldb | varchar(10) | | | || | testFieldd | varchar(10) | | | || | testFieldc | varchar(10) | | | || | testFielde | varchar(10) | | | || ++-+--+-+-++ 7 rows in set (0.80 sec) - //html form code HTML HEAD TITLEInsert Form/TITLE /HEAD BODY FORM ACTION=insert.php METHOD=POST PQuestioninput type=text name=testField size=30 br PAnswer1input type=text name=testFielda size=30 br PAnswer2input type=text name=testFieldb size=30 br PAnswer3input type=text name=testFieldc size=30br PAnswer4input type=text name=testFieldd size=30 br Pcorrect answerinput type=text name=testFielde size=30 br pinput type=submit name=submit value=Insert Record/p /FORM /BODY /HTML -- //php code ?php // open the connection $conn = mysql_connect(localhost, , ); // pick the database to use mysql_select_db(testDB,$conn); // create the SQL statement $sql = INSERT INTO testtable values ('{'', $_POST['testField']}',' {'', $_POST['testFielda']}','{'', $_POST['testFieldb']}','{'', $_POST['testFieldd']}',' {'', $_POST['testFieldc']}','{'', $_POST['testFielde']}'); // execute the SQL statement if (mysql_query($sql, $conn)) { echo record added!; } else { echo something went wrong; } ?
[PHP-DB] FW: db design - which is better
-Original Message- From: Gilbert Midonnet [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:09 PM To: php-db Subject: db design - which is better I have a client who has hundreds of articles. Each article can be seen by one or more permission groups. I have questions regarding setting up the an article_display table. The easiest table to read and to conceptualize would list the articles and use a boolean for each of the permission groups (let's call the PGs for this example). (articleNameID refers back to the article table) articleNameID---PG1---PG2---PG3---PG4---PG5 1001-1-0-0-0-0 1002-1-1-0-0-0 1003-0-0-1-0-0 Or should the table set up be: articleNameID--PG 10011 10021 10022 10033 etc... gil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FW: db design - which is better
Use the second design. SQL 101 / 1st normal form. _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:19 Subject: [PHP-DB] FW: db design - which is better -Original Message- From: Gilbert Midonnet [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:09 PM To: php-db Subject: db design - which is better I have a client who has hundreds of articles. Each article can be seen by one or more permission groups. I have questions regarding setting up the an article_display table. The easiest table to read and to conceptualize would list the articles and use a boolean for each of the permission groups (let's call the PGs for this example). (articleNameID refers back to the article table) articleNameID---PG1---PG2---PG3---PG4---PG5 1001-1-0-0-0-0 1002-1-1-0-0-0 1003-0-0-1-0-0 Or should the table set up be: articleNameID--PG 10011 10021 10022 10033 etc... gil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Rules in a database
If you string-concatenate atomic rules in a field, IMHO you will never manage to extract any information. Parsing these strings will be a nightmare. With the fully normalized model I have in mind, your SQL should be a breeze. This is quite logical after all: your flattened rules are polynoms of degree 1 in an arbitrary number of variables; each monome of which is homéomorphic (?) to a subset of the rule set. This structure matches well the representation of records in a SQL table as set elements: - it is easy to check that a given monome exists, - then it is easy to check that the required monomes have been associated as a complex rule. HTH (hope I am right! - not tested) Ignatius _ - Original Message - From: John Dillon [EMAIL PROTECTED] To: Ignatius Reilly [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 20:56 Subject: Re: [PHP-DB] Rules in a database Thanks for that. I understand you'd have one table with simple phrases like a=b being atomic rule 1, c=d being atomic rule 2...e=f being atomic rule 4, say; the second table with 1,2 as an AND group rule 1, being the 2 alternative - OR - conditions, one of which must exist; and the third table with 1-4, stating that AND group rule 1 would lead to result 4. In total, if 1 or 2 is true then e=f. I think, however, that I might find it easier to combine: - store AND rule groups in a table (1-n relation to the atomic table) - store full rules in a table (1-n relation to the AND table) into one table column and use string functions to extract the rule. The first table remains the same, being a list of a=b rules. The second table might have a record in the IF field +(12 OR 3) AND (13 OR 4) and 4 in the THEN field.. Looking beyond to the sort of queries I might want to run. If I knew a condition was true, say condition 12, I would want to know what possible rules might be relevant (I think of a rule as an IF:THEN set). Or if I knew two conditions were true, say 12 and 13, I would want to know what rules applied when those two conditions were true. The queries would be: SELECT full_rule FROM full_rules_table WHERE INSTR('/12/',IF) - I don't know if that INSTR works as shown. That would tell me if the rule might apply. To know whether the rule would actually apply - is fully qualified - I need to know if condition 13 - or alternative 4) is also true. I envisage parsing the expression +(12 OR 3) AND (13 OR 4) into array elements (12 OR 3) and (13 OR 4) and then going through each and comparing to the conditions I know exist, then reporting various facets of the rule, including alternatives or additional conditions required. The report would contain information like: These conditions are true to start with. The following results follow (since all conditions needed are true) - the same result would occur in alternative conditions: ..instead of condition 12 condition 3 applied etc The following results could occur if additional conditions were true:... - result 1 ...the following extra conditions are requiredetc. Do you think this is feasible? Regards, John - Original Message - From: Ignatius Reilly [EMAIL PROTECTED] To: DB list PHP [EMAIL PROTECTED]; John [EMAIL PROTECTED] Sent: Friday, February 06, 2004 3:13 PM Subject: Re: [PHP-DB] Rules in a database A bit of algebra first: any expression formed of atomic expressions, AND, OR and parentheses can be reduced to a canonical form, by using the De Morgan laws: a AND ( b OR c ) is equiv. to a AND b OR a AND c So a rule can eventually be reduced to AND groups, joined by OR: a(1) AND... AND a(n) OR ... OR z(1) AND ... AND z(p) Each AND group contains 1 or more rules. Therefore, to model input rules: - store atomic rules in a table - store AND rule groups in a table (1-n relation to the atomic table) - store full rules in a table (1-n relation to the AND table) Now you can model output rules likewise, and finally create a table of associations between input and output rules Problem is: once you've flattened your rules to the canonical form, they can become illegible. So perhaps a hierarchical data model (XML) would be more appropriate, for your rules would remain human-legible (and thererfore human-maintainable) HTH Ignatius _ - Original Message - From: John [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, February 06, 2004 15:35 Subject: [PHP-DB] Rules in a database I work in tax and thus have to read legislation - some complex - and I wanted to store some of the logic in a database so that if I know certain conditions were true I could look up what results this might have. Thus I am thinking of having two tables - one of phrases and the other of how these phrases are linked together as rules. A rule structure could be: IF A THEN B IF A OR A1 OR A2 THEN B IF A THEN B
RE: [PHP-DB] FW: db design - which is better
Thanks, There just seems to be times when non-normalized table structures are easier to work with. A few hundred to a few thousand records, maybe 20 fields, rarely adding another field. I wonder sometimes whether it make sense to put everything in one table instead of using joins. yours, putting-his-foot-in-his-mouth, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:33 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better Use the second design. SQL 101 / 1st normal form. _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:19 Subject: [PHP-DB] FW: db design - which is better -Original Message- From: Gilbert Midonnet [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:09 PM To: php-db Subject: db design - which is better I have a client who has hundreds of articles. Each article can be seen by one or more permission groups. I have questions regarding setting up the an article_display table. The easiest table to read and to conceptualize would list the articles and use a boolean for each of the permission groups (let's call the PGs for this example). (articleNameID refers back to the article table) articleNameID---PG1---PG2---PG3---PG4---PG5 1001-1-0-0-0-0 1002-1-1-0-0-0 1003-0-0-1-0-0 Or should the table set up be: articleNameID--PG 10011 10021 10022 10033 etc... gil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] FW: db design - which is better
Let's say you have a page that is hit fairly frequently and spits out 100s of results. On it you have articleTitle, authorFName, authorLName. I ran a few tests and found that if all the above fields are in one table it gets processed quicker than if there's a join. (authorID - authorFName, authorLName) So, I'm beginning to think that processing time would be quicker if I insert authorFName and authorLName into 2 tables. One the author table and the other the *VERY* frequently hit article table. That way when someone wants a list of articles, author FName, author LName all the data comes from one table. This would be probably very stupid in a financial or medical database which has tens of millions of records and 100s if not 1000s of tables but SEEMS (I'm very open to being corrected) to work better on a fairly small web accessed database. yours, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 6:01 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better There are perhaps such times, but I have yet to meet one. with 1NF: - your table space will be smaller - your indexes will work better - your SQL will be easier to write - ease of maintenance Just my 2 Belgian francs Ignatius _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:45 Subject: RE: [PHP-DB] FW: db design - which is better Thanks, There just seems to be times when non-normalized table structures are easier to work with. A few hundred to a few thousand records, maybe 20 fields, rarely adding another field. I wonder sometimes whether it make sense to put everything in one table instead of using joins. yours, putting-his-foot-in-his-mouth, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:33 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better Use the second design. SQL 101 / 1st normal form. _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:19 Subject: [PHP-DB] FW: db design - which is better -Original Message- From: Gilbert Midonnet [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:09 PM To: php-db Subject: db design - which is better I have a client who has hundreds of articles. Each article can be seen by one or more permission groups. I have questions regarding setting up the an article_display table. The easiest table to read and to conceptualize would list the articles and use a boolean for each of the permission groups (let's call the PGs for this example). (articleNameID refers back to the article table) articleNameID---PG1---PG2---PG3---PG4---PG5 1001-1-0-0-0-0 1002-1-1-0-0-0 1003-0-0-1-0-0 Or should the table set up be: articleNameID--PG 10011 10021 10022 10033 etc... gil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FW: db design - which is better
Hmmm... What of maintenance? One day your pointed-headed boss asks you to add a civility field (Mr|Mrs|Colonel|...), a birthdate, etc. How do you do that with a 1-table design? You will have to create 1-NF temporary tables in the process... How do you search for an author? You will have to create a needlessly large and inefficient index on (LastName + FirstName), instead of a nice integer index. And when querying the articleID, I do not think that there should be a significant performance penalty, if your indexes are properly designed. cheers Ignatius _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Sunday, February 08, 2004 00:10 Subject: RE: [PHP-DB] FW: db design - which is better Let's say you have a page that is hit fairly frequently and spits out 100s of results. On it you have articleTitle, authorFName, authorLName. I ran a few tests and found that if all the above fields are in one table it gets processed quicker than if there's a join. (authorID - authorFName, authorLName) So, I'm beginning to think that processing time would be quicker if I insert authorFName and authorLName into 2 tables. One the author table and the other the *VERY* frequently hit article table. That way when someone wants a list of articles, author FName, author LName all the data comes from one table. This would be probably very stupid in a financial or medical database which has tens of millions of records and 100s if not 1000s of tables but SEEMS (I'm very open to being corrected) to work better on a fairly small web accessed database. yours, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 6:01 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better There are perhaps such times, but I have yet to meet one. with 1NF: - your table space will be smaller - your indexes will work better - your SQL will be easier to write - ease of maintenance Just my 2 Belgian francs Ignatius _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:45 Subject: RE: [PHP-DB] FW: db design - which is better Thanks, There just seems to be times when non-normalized table structures are easier to work with. A few hundred to a few thousand records, maybe 20 fields, rarely adding another field. I wonder sometimes whether it make sense to put everything in one table instead of using joins. yours, putting-his-foot-in-his-mouth, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:33 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better Use the second design. SQL 101 / 1st normal form. _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:19 Subject: [PHP-DB] FW: db design - which is better -Original Message- From: Gilbert Midonnet [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:09 PM To: php-db Subject: db design - which is better I have a client who has hundreds of articles. Each article can be seen by one or more permission groups. I have questions regarding setting up the an article_display table. The easiest table to read and to conceptualize would list the articles and use a boolean for each of the permission groups (let's call the PGs for this example). (articleNameID refers back to the article table) articleNameID---PG1---PG2---PG3---PG4---PG5 1001-1-0-0-0-0 1002-1-1-0-0-0 1003-0-0-1-0-0 Or should the table set up be: articleNameID--PG 10011 10021 10022 10033 etc... gil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List
RE: [PHP-DB] FW: db design - which is better
Yeah, I think it's just the devil sending me strange thoughts. :-) It does sound dumb to have normalized tables AND to duplicate some of the data in another table. thx, just tossing off some ideas. -- gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 6:31 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better Hmmm... What of maintenance? One day your pointed-headed boss asks you to add a civility field (Mr|Mrs|Colonel|...), a birthdate, etc. How do you do that with a 1-table design? You will have to create 1-NF temporary tables in the process... How do you search for an author? You will have to create a needlessly large and inefficient index on (LastName + FirstName), instead of a nice integer index. And when querying the articleID, I do not think that there should be a significant performance penalty, if your indexes are properly designed. cheers Ignatius _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Sunday, February 08, 2004 00:10 Subject: RE: [PHP-DB] FW: db design - which is better Let's say you have a page that is hit fairly frequently and spits out 100s of results. On it you have articleTitle, authorFName, authorLName. I ran a few tests and found that if all the above fields are in one table it gets processed quicker than if there's a join. (authorID - authorFName, authorLName) So, I'm beginning to think that processing time would be quicker if I insert authorFName and authorLName into 2 tables. One the author table and the other the *VERY* frequently hit article table. That way when someone wants a list of articles, author FName, author LName all the data comes from one table. This would be probably very stupid in a financial or medical database which has tens of millions of records and 100s if not 1000s of tables but SEEMS (I'm very open to being corrected) to work better on a fairly small web accessed database. yours, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 6:01 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better There are perhaps such times, but I have yet to meet one. with 1NF: - your table space will be smaller - your indexes will work better - your SQL will be easier to write - ease of maintenance Just my 2 Belgian francs Ignatius _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:45 Subject: RE: [PHP-DB] FW: db design - which is better Thanks, There just seems to be times when non-normalized table structures are easier to work with. A few hundred to a few thousand records, maybe 20 fields, rarely adding another field. I wonder sometimes whether it make sense to put everything in one table instead of using joins. yours, putting-his-foot-in-his-mouth, Gil -Original Message- From: Ignatius Reilly [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:33 PM To: mayo; php-db Subject: Re: [PHP-DB] FW: db design - which is better Use the second design. SQL 101 / 1st normal form. _ - Original Message - From: mayo [EMAIL PROTECTED] To: php-db [EMAIL PROTECTED] Sent: Saturday, February 07, 2004 23:19 Subject: [PHP-DB] FW: db design - which is better -Original Message- From: Gilbert Midonnet [mailto:[EMAIL PROTECTED] Sent: Saturday, February 07, 2004 5:09 PM To: php-db Subject: db design - which is better I have a client who has hundreds of articles. Each article can be seen by one or more permission groups. I have questions regarding setting up the an article_display table. The easiest table to read and to conceptualize would list the articles and use a boolean for each of the permission groups (let's call the PGs for this example). (articleNameID refers back to the article table) articleNameID---PG1---PG2---PG3---PG4---PG5 1001-1-0-0-0-0 1002-1-1-0-0-0 1003-0-0-1-0-0 Or should the table set up be:
[PHP-DB] Re: Form doesnt write to database
Dear friends, Form doesn't write to mysql database. I have pasted code of mysal table structure,html form and php script. Any comments, please. // create the SQL statement $sql = INSERT INTO testtable values ('{'', $_POST['testField']}',' {'', $_POST['testFielda']}','{'', $_POST['testFieldb']}','{'', $_POST['testFieldd']}',' {'', $_POST['testFieldc']}','{'', $_POST['testFielde']}'); I tried your code on my system and got an error of 'incorrect number of parameters'. That's when I realized you need NULL as the first parameter in your values. I didn't see in the MySQL docs where it requires the NULL, but in one of the examples, it was there. Insert NULL as the first parameter and it should work. I also got a parse error because of the '{' and '}' symbols around your $_POST variables. I changed it to: $sql = INSERT INTO testtable values ( NULL, '.$_POST['testField'].', '.$_POST['testFielda'].', '.$_POST['testFieldb'].', '.$_POST['testFieldd'].', '.$_POST['testFieldc'].', '.$_POST['testFielde'].' ); and got a working solution. Suggestion: You could try using the mysql_errno() and mysql_error() functions. Print them out after your failed statement and you'll see why the mysql call failed. Example: print Error # .mysql_errno(). - .mysql_error().BR\n; will print the error number and message. This will give you some idea of what went wrong. Good coding practice dictates that you check for an error condition after mysql calls [using mysql_errno()] and handle any errors appropriately. If you don't already have it, you'll want a list of the error codes and their meanings. You can find it in the mysql source code Docs/mysqld_error.txt file. If you can't find that right now, copy this web page I whipped up right now: http://web.netmask.com/2004/02/mysql-error-codes.html or, if you prefer a flat, text file: http://web.netmask.com/2004/02/mysql-error-codes.txt Good luck! :Mike S. :Austin TX --- Sent: February 7, 2004, 6:48 pm -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Windows XP and PHP
I installed Apache/Perl/PHP onto a Windows XP machine today and ran into this problem when I tried to access the MS SQL Server via PHP: can't load dynamic library php_mssql.dll The dll is in the extensions directory. Apache is running fine. Any ideas, on what might be wrong? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Windows XP and PHP
I installed Apache/Perl/PHP onto a Windows XP machine today and ran into this problem when I tried to access the MS SQL Server via PHP: can't load dynamic library php_mssql.dll The dll is in the extensions directory. Apache is running fine. Any ideas, on what might be wrong? I think this is in the php documentation but here is an answer from: http://forums.devshed.com/archive/5/2002/11/2/47028 = MSSQL connection using PHP (ERROR) micros_bytes This is happening because you do not have the required MS-SQL client libraries. In addition to having the PHP extension DLL, you have to have the Microsoft DLLs for accessing SQL Server. I don't recall the exact files but you can get them by installing the SQL Server Client Tools from the SQL Server install CD. Once you have that installed, you should be able to connect without errors. = -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php-db Digest 8 Feb 2004 01:40:01 -0000 Issue 2250
Hi, I want to grab a value from one table field and place another value in another table fied. So If I had table value1 and it was set to 3 I want to recognise the value 3 and put value 1 in table value2. Example: value1: 3 value2: (blank) So now I need to check value1 and MAKE SURE 3 is the value, if a lower value I want to do nothing. If 3 than I want to use the value Example 2: value1: 0 (grab 3 and reset to 0, if higher than 3 do the same) value2: 1 (If value1 is 3 than value 1 needs to go in value2) But how can I achieve this? The queries are ran once a day, no more. So when the query is ran I could than execute the second query to change the value#'s. Would I be right in saying that I'd use a 'IF statement' for this? Or is there another way to do this? I am not sure exactly about executing a query with the IF statement, I do know how to execute a message or HTML information to output to the webpage. I've done some reading online, but have not found what I am requiring ... Could be looking in the wrong place, as usual. All help appreciated. Jerry http://greetings.yahoo.com.au - Yahoo! Greetings Send your love online with Yahoo! Greetings - FREE! -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] FW: db design - which is better
There just seems to be times when non-normalized table structures are easier to work with. There are times when de-normalizing is acceptable. One of the more common uses of denormalized data is in data warehousing. Such as pre-summing sales, and storing pre-calculated aggregate information to relieve the db of doing heavy or complex calculations when summary data is going to be queried on a frequent basis. Often php-based message boards will use columns of pre-sumed data as part of a normal table (for example, a count of total user posts stored in the user table, that is incremented/decremented when a user adds/deletes a post, or the total number posts in a given thread stored in the topic table). This helps to allieviate the need for a count() whenever a message thread is built and you want to show the number of posts each user in the thread has, etc. So there are some acceptable situations :) Cheers, Keith. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Windows XP and PHP
Duane Lakoduk wrote: I installed Apache/Perl/PHP onto a Windows XP machine today and ran into this problem when I tried to access the MS SQL Server via PHP: can't load dynamic library php_mssql.dll The dll is in the extensions directory. Apache is running fine. Any ideas, on what might be wrong? I think this is in the php documentation but here is an answer from: http://forums.devshed.com/archive/5/2002/11/2/47028 = MSSQL connection using PHP (ERROR) micros_bytes This is happening because you do not have the required MS-SQL client libraries. In addition to having the PHP extension DLL, you have to have the Microsoft DLLs for accessing SQL Server. I don't recall the exact files but you can get them by installing the SQL Server Client Tools from the SQL Server install CD. Once you have that installed, you should be able to connect without errors. = I had this bookmarked too, and I had forgotten about it. Would installing the MDAC Microsoft have on their site install the ntwdblib.dll? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Windows XP and PHP
I had this bookmarked too, and I had forgotten about it. Would installing the MDAC Microsoft have on their site install the ntwdblib.dll? Don't think so, I have current MDAC installed and it is not on my ws. I just found this on: http://www.php.net/function.mssql-connect GET ntwdblib.dll This dll can also be found in the binary zip of php 4.3 in the dlls subdir. put it in the system32 dir. WATCH OUT... i used a copy found on a MSSQL server, used that.. couldn't get it to work.. My function calls seamed OK, could call the mssql routines but I got a connection error When I used the dll distributed with the binary zip of php 4.3 it worked. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Windows XP and PHP
I had this bookmarked too, and I had forgotten about it. Would installing the MDAC Microsoft have on their site install the ntwdblib.dll? I just checked php-4.3.4-WIN32.zip and ntwdblib.dll is in there. Drop it in your extensions directory and make sure the line: extension=php_mssql.dll ... in the ;Windows Extensions section of php.ini is uncommented. Verify your - extension_dir = path - setting also. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] PEAR DB 1.6.0RC5 released, please test it
Hello Again: Another release of PEAR DB was made yesterday, 1.6.0RC5. The most important change was fixing the bug for people who use arrays for the DSN information when connecting. It also adds a new method called quoteIdentifier(), which is used for delimiting identifiers (such as field names and table names). I'm planning to issue the stable 1.6.0 release on Tuesday. So, please download the package and test it out. File bug reports if stuff doesn't work or is unclear. Download:http://pear.php.net/get/DB Manual: http://pear.php.net/manual/en/package.database.php Report Bugs: http://pear.php.net/bugs/report.php?package=DB Home Page: http://pear.php.net/package/DB Oh, and if you like the new features, the fixing of over 40 bugs, and/or the documentation improvements that have happened since 1.5.0RC2, take note of my Wishlist page at http://www.analysisandsolutions.com/donate/donate.htm The Financial Donations secition is now working again, too. Enjoy, --Dan PS: I'm not on the list. Just posting this as an announcement. -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Compilation issue with php 5.00 and mysqli-extension
Hi all, i am trying to compile php 5.0.0 beta 3 using: Apache 2.0.47 MySQL 4.1.1-alpha-debug-debug with the mysqli extensions under linux. When i try to compile php, gcc will bail of with the following message: /bin/sh /home/jochen/Documents/php/php-5.0.0b3/libtool --silent --preserve-dup-deps --mode=compile gcc -Iext/mysqli/ -I/home/jochen Documents/php/php-5.0.0b3/ext/mysqli/ -DPHP_ATOM_INC -I/home/jochen Documents/php/php-5.0.0b3/include -I/home/jochen/Documents/php/php-5.0.0b3 main -I/home/jochen/Documents/php/php-5.0.0b3 -I/home/jochen/Documents/php php-5.0.0b3/Zend -I/usr/include/libxml2 -I/usr/local/mysql/include -I home/jochen/Documents/php/php-5.0.0b3/TSRM -g -O2 -prefer-pic -c /home jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c -o ext/mysqli mysqli_report.lo /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c: In function `php_mysqli_report_index': /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:64: error: `SERVER_QUERY_NO_GOOD_INDEX_USED' undeclared (first use in this function) /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:64: error: (Each undeclared identifier is reported only once /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:64: error: for each function it appears in.) /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:66: error: `SERVER_QUERY_NO_INDEX_USED' undeclared (first use in this function) make: *** [ext/mysqli/mysqli_report.lo] Fehler 1 Nor i can find a definition of SERVER_QUERY_NO_GOOD_INDEX_USED or SERVER_QUERY_NO_INDEX_USED my ./configure parameters are: ./configure --with-apxs2=/usr/local/apache2/bin/apxs --without-mysql --with-mysqli=/usr/local/mysql/bin/mysql_config Has anyone got an idea of how to avoid that? Regards, Jochen -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-QA] Compilation issue with php 5.00 and mysqli-extension
Hello Jochen, you need mysql 4.1.2+ your version is too old :-) Saturday, February 7, 2004, 7:09:13 PM, you wrote: Hi all, i am trying to compile php 5.0.0 beta 3 using: Apache 2.0.47 MySQL 4.1.1-alpha-debug-debug with the mysqli extensions under linux. When i try to compile php, gcc will bail of with the following message: /bin/sh /home/jochen/Documents/php/php-5.0.0b3/libtool --silent --preserve-dup-deps --mode=compile gcc -Iext/mysqli/ -I/home/jochen Documents/php/php-5.0.0b3/ext/mysqli/ -DPHP_ATOM_INC -I/home/jochen Documents/php/php-5.0.0b3/include -I/home/jochen/Documents/php/php-5.0.0b3 main -I/home/jochen/Documents/php/php-5.0.0b3 -I/home/jochen/Documents/php php-5.0.0b3/Zend -I/usr/include/libxml2 -I/usr/local/mysql/include -I home/jochen/Documents/php/php-5.0.0b3/TSRM -g -O2 -prefer-pic -c /home jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c -o ext/mysqli mysqli_report.lo /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c: In function `php_mysqli_report_index': /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:64: error: `SERVER_QUERY_NO_GOOD_INDEX_USED' undeclared (first use in this function) /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:64: error: (Each undeclared identifier is reported only once /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:64: error: for each function it appears in.) /home/jochen/Documents/php/php-5.0.0b3/ext/mysqli/mysqli_report.c:66: error: `SERVER_QUERY_NO_INDEX_USED' undeclared (first use in this function) make: *** [ext/mysqli/mysqli_report.lo] Fehler 1 Nor i can find a definition of SERVER_QUERY_NO_GOOD_INDEX_USED or SERVER_QUERY_NO_INDEX_USED my ./configure parameters are: ./configure --with-apxs2=/usr/local/apache2/bin/apxs --without-mysql --with-mysqli=/usr/local/mysql/bin/mysql_config Has anyone got an idea of how to avoid that? Regards, Jochen -- Best regards, Marcusmailto:[EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php