[PHP-DB] please help.. serial number generator
Any ideas how to generate a unique serial number that you can check that it's valid.. Thanks... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: Percentage...
OK, here is the answer in (unedited except for comments)code: $query = select count(vid) as total_qs from poll_vote where pid = $pid; // count the number of fields in the table $result = mysql_query($query) or die(Query failed: $querybr . mysql_error()); $row = mysql_fetch_array($result); $query = 'select count(poll_vote.vid) as total, (count(poll_vote.vid) / '.$row['total_qs'].' * 100) as percentage, poll_option.poption from poll_vote, poll_option where poll_vote.oid = poll_option.oid and poll_vote.pid = '.$pid.' group by poll_vote.oid'; /* count the number of rows for a id or something then devide it by the number of total rows. then mulitply it by 100. use group by clause to group results by the thing you want to group it by */ $result = mysql_query($query) or die(Query failed: $querybr . mysql_error()); $num_results = mysql_num_rows($result); for ($i=0; $i $num_results; $i++) { $row = mysql_fetch_array($result); echo 'trtd'.$row['poption'].' - '; echo $row['total'].' Votes./tdtdimg alt=line.gif (1K) src=images/line.gif height=15 width='.$row['percentage'].''./td/tr\n; } here it is in the two SQL queries + required code to get var: $query = select count(vid) as total_qs from poll_vote where pid = $pid; // count the number of fields in the table $result = mysql_query($query) or die(Query failed: $querybr . mysql_error()); $row = mysql_fetch_array($result); $query = 'select count(poll_vote.vid) as total, (count(poll_vote.vid) / '.$row['total_qs'].' * 100) as percentage, poll_option.poption from poll_vote, poll_option where poll_vote.oid = poll_option.oid and poll_vote.pid = '.$pid.' group by poll_vote.oid'; -- JJ Harrison [EMAIL PROTECTED] www.tececo.com César aracena [EMAIL PROTECTED] wrote in message 002901c23716$b352a020$84c405c8@gateway">news:002901c23716$b352a020$84c405c8@gateway... Hi JJ. I know we all should do what you did, but I've seen this kind of mails quite a lot lately in these lists. I'm sure that many of you, like me, keep these mails for further reading and reference... it would be nice if you also state what was the answer to your original question. I mean, if you came up with a question that some of us might have in the future, it would be nice to have the answer off-line (in our mail soft) instead of going on-line for search... Shear it with others! Thanks, C. -Original Message- From: JJ Harrison [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 7:03 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Re: Percentage... Plz ignore this. found it after more searching... -- JJ Harrison [EMAIL PROTECTED] www.tececo.com Jj Harrison [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... How, using the group by and where statments can I return the percentage of something? ie: pid| oid| uid | 1 |2 |1 1 |2 |1 1 |2 |1 1 |1 |1 would return oid | percent 2| 75 1| 25 Thx, -- JJ Harrison [EMAIL PROTECTED] www.tececo.com -- 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-DB] Re: please help.. serial number generator
if u are looking for a simple random string try this php: echo md5(time()); or md5() a random number your choice. md5() genetates a one way non-reversable hash. which could be kept in a db. here is an example of the md5 hash of my library card number: 11d560821fb027c227d837df53a5a73a md5() is often used to store passwords and make them non-viewable. if you are just looking for a unique number an auto-increment coloumn in mysql or what ever should do it. -- JJ Harrison [EMAIL PROTECTED] www.tececo.com Rainydays Sunshine [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Any ideas how to generate a unique serial number that you can check that it's valid.. Thanks... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: please help.. serial number generator
I need to create some kind of 10 digits serial number where I can generate and check that it is valid. Sort of like a checksum.. Jj Harrison [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... if u are looking for a simple random string try this php: echo md5(time()); or md5() a random number your choice. md5() genetates a one way non-reversable hash. which could be kept in a db. here is an example of the md5 hash of my library card number: 11d560821fb027c227d837df53a5a73a md5() is often used to store passwords and make them non-viewable. if you are just looking for a unique number an auto-increment coloumn in mysql or what ever should do it. -- JJ Harrison [EMAIL PROTECTED] www.tececo.com Rainydays Sunshine [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Any ideas how to generate a unique serial number that you can check that it's valid.. Thanks... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mySQL max connections
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi I have a database thats taking a bit of a hammering - enough so that the number of connections spirals up and out of control. max_connections was originally at the default of 100 - but rising above 50 or so meant actual throughput dropped so the db never got a chance to keep up (meaning manually restarting the db). I've lowered max_connections to 40 which at least keeps the db alive. But, the number of connections keeps rising to and bouncing off this limit - and for the users that hit it a 'Too many connections' error is given. Now, I've optimised everything as much as is humanely possible - and the only way out I can see so far is to have some kind of connection queue to keep people waiting for the 1/2 second or so until the load spike drops off (I'd rather have a few slow pages than errors any day). Is there any way of doing this - I've looked at back_log (the listen() backlog), but that doesnt really apply. Short of writing a 'hide-warning-wait-a-bit-and-try-again' chunk in PHP (sucky!) I'm stuck! Using persistent connections doesn't stunningly help either - it only gives a small performance increase Any help appreciated, thanks. - -- Shane http://www.shanewright.co.uk/ Public key: http://www.shanewright.co.uk/files/public_key.asc -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE9RneQ5DXg6dCMBrQRAsQTAKCxNem6+NTNY/I1Wtwstil7axtykACgpUiG c1e7on4Fu9jgYWhYNLxJAH4= =H/Op -END PGP SIGNATURE- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] How can you include an https?
Hi guys, Just stumble on this problem. I need to be able to include a file from another server into one of my script. Not to difficult except that the file is on a secure server and it doesn't seem to work. Anybody knows of a way around. I have php 4 running on Red Hat with mysql databse. Thanks in advance Cami
Re: [PHP-DB] How can you include an https?
on 7/30/02 9:10 AM, Camelia Enderby at [EMAIL PROTECTED] appended the following bits to my mbox: Just stumble on this problem. I need to be able to include a file from another server into one of my script. Not to difficult except that the file is on a secure server and it doesn't seem to work. Anybody knows of a way around. I have php 4 running on Red Hat with mysql databse. Not related to databases, so it should be on PHP General That said, unless something's changed recently, you *cannot* do this with just an include or fopen call. One option is to use the CURL functions: http://php.us.themoes.org/manual/en/ref.curl.php I'd suggest looking for an RPM that has them included. Sincerely, Paul Burney http://paulburney.com/ ?php while ($self != asleep) { $sheep_count++; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql_fetch_array limit? - more details
I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mySQL max connections
I would suggest looking into MySQL's replication support. Split reads and writes so they go to separate servers. That is, create a master server where you send all database writes. And do all reads on the replicated slave servers. Have a look at this presentation I gave last week on this stuff: http://pres.lerdorf.com/show/osconmysql The last couple of slides should be interesting to you. (works best with Mozilla, click on the yellow text at the top to change slides, or use cursor-right/left) -Rasmus On Tue, 30 Jul 2002, Shane Wright wrote: Hi I have a database thats taking a bit of a hammering - enough so that the number of connections spirals up and out of control. max_connections was originally at the default of 100 - but rising above 50 or so meant actual throughput dropped so the db never got a chance to keep up (meaning manually restarting the db). I've lowered max_connections to 40 which at least keeps the db alive. But, the number of connections keeps rising to and bouncing off this limit - and for the users that hit it a 'Too many connections' error is given. Now, I've optimised everything as much as is humanely possible - and the only way out I can see so far is to have some kind of connection queue to keep people waiting for the 1/2 second or so until the load spike drops off (I'd rather have a few slow pages than errors any day). Is there any way of doing this - I've looked at back_log (the listen() backlog), but that doesnt really apply. Short of writing a 'hide-warning-wait-a-bit-and-try-again' chunk in PHP (sucky!) I'm stuck! Using persistent connections doesn't stunningly help either - it only gives a small performance increase Any help appreciated, thanks. -- Shane http://www.shanewright.co.uk/ Public key: http://www.shanewright.co.uk/files/public_key.asc -- gpg: Warning: using insecure memory! gpg: Signature made Tue 30 Jul 2002 04:25:04 AM PDT using DSA key ID D08C06B4 gpg: Can't check signature: public key not found -- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array limit? - more details
Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
Thank you for that idea. I don't think that's it, though, because this script is the only one I'm ever running on this site. The problem is perfectly consistent and repeatable, which leads me to believe it's something in the way the array is being built. Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01cd01c237e8$7e1438b0$1601a8c0@nik">news:01cd01c237e8$7e1438b0$1601a8c0@nik... Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
Do you have PhpMyAdmin installed? If you have try with it to see the results. It uses native mysql functions. Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:53 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details Thank you for that idea. I don't think that's it, though, because this script is the only one I'm ever running on this site. The problem is perfectly consistent and repeatable, which leads me to believe it's something in the way the array is being built. Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01cd01c237e8$7e1438b0$1601a8c0@nik">news:01cd01c237e8$7e1438b0$1601a8c0@nik... Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
No I don't have PhpMyAdmin installed. I work directly in MySQL via a terminal, so all my checking is with native calls anyway. Working natively in MySQL, all my data is there and everything works the way I expect it to. Using mysql_fetch_array() in PHP results in a truncated result set. And I am trying to figure out why, and how I can work around this problem. Thanks again, Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01ed01c237ea$0d0fcf10$1601a8c0@nik">news:01ed01c237ea$0d0fcf10$1601a8c0@nik... Do you have PhpMyAdmin installed? If you have try with it to see the results. It uses native mysql functions. Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:53 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details Thank you for that idea. I don't think that's it, though, because this script is the only one I'm ever running on this site. The problem is perfectly consistent and repeatable, which leads me to believe it's something in the way the array is being built. Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01cd01c237e8$7e1438b0$1601a8c0@nik">news:01cd01c237e8$7e1438b0$1601a8c0@nik... Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
What do you mean it uses 2? It does not. On Tue, 30 Jul 2002, Andrey Hristov wrote: Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
Hello, last week I read this article : http://phplens.com/lens/php-book/optimizing-debugging-php.php It is long one. Extract from it (look where is it and read around it): [snip] Overload on 40 connections When we pushed the benchmark to use 40 connections, the server overloaded with 35% failed requests. On further investigation, it was because the MySQL server persistent connects were failing because of Too Many Connections. The benchmark also demonstrates the lingering behavior of Apache child processes. Each PHP script uses 2 persistent connections, so at 40 connections, we should only be using at most 80 persistent connections, well below the default MySQL max_connections of 100. However Apache idle child processes are not assigned immediately to new requests due to latencies, keep-alives and other technical reasons; these lingering child processes held the remaining 20+ persistent connections that were the straws that broke the Camel's back. The Fix By switching to non-persistent database connections, we were able to fix this problem and obtained a result of 5.340 seconds. An alternative solution would have been to increase the MySQL max_connections parameter from the default of 100. [/snip] Andrey - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: Paul Worthington [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:59 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details What do you mean it uses 2? It does not. On Tue, 30 Jul 2002, Andrey Hristov wrote: Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
The only reason it uses two is if the code using persistent connections connects with different credentials. ie. you have 2 different apps on the same server that connects as 2 different user ids and they are both using persistent connections. Eventually every httpd will have 2 connections. -R On Tue, 30 Jul 2002, Andrey Hristov wrote: Hello, last week I read this article : http://phplens.com/lens/php-book/optimizing-debugging-php.php It is long one. Extract from it (look where is it and read around it): [snip] Overload on 40 connections When we pushed the benchmark to use 40 connections, the server overloaded with 35% failed requests. On further investigation, it was because the MySQL server persistent connects were failing because of Too Many Connections. The benchmark also demonstrates the lingering behavior of Apache child processes. Each PHP script uses 2 persistent connections, so at 40 connections, we should only be using at most 80 persistent connections, well below the default MySQL max_connections of 100. However Apache idle child processes are not assigned immediately to new requests due to latencies, keep-alives and other technical reasons; these lingering child processes held the remaining 20+ persistent connections that were the straws that broke the Camel's back. The Fix By switching to non-persistent database connections, we were able to fix this problem and obtained a result of 5.340 seconds. An alternative solution would have been to increase the MySQL max_connections parameter from the default of 100. [/snip] Andrey - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: Paul Worthington [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:59 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details What do you mean it uses 2? It does not. On Tue, 30 Jul 2002, Andrey Hristov wrote: Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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:
Re: [PHP-DB] mysql_fetch_array limit? - more details
Yeaah! I am a fool. My biggest excuses. Sorry Rasmus and everyone else. Andrey - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 8:11 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details The only reason it uses two is if the code using persistent connections connects with different credentials. ie. you have 2 different apps on the same server that connects as 2 different user ids and they are both using persistent connections. Eventually every httpd will have 2 connections. -R On Tue, 30 Jul 2002, Andrey Hristov wrote: Hello, last week I read this article : http://phplens.com/lens/php-book/optimizing-debugging-php.php It is long one. Extract from it (look where is it and read around it): [snip] Overload on 40 connections When we pushed the benchmark to use 40 connections, the server overloaded with 35% failed requests. On further investigation, it was because the MySQL server persistent connects were failing because of Too Many Connections. The benchmark also demonstrates the lingering behavior of Apache child processes. Each PHP script uses 2 persistent connections, so at 40 connections, we should only be using at most 80 persistent connections, well below the default MySQL max_connections of 100. However Apache idle child processes are not assigned immediately to new requests due to latencies, keep-alives and other technical reasons; these lingering child processes held the remaining 20+ persistent connections that were the straws that broke the Camel's back. The Fix By switching to non-persistent database connections, we were able to fix this problem and obtained a result of 5.340 seconds. An alternative solution would have been to increase the MySQL max_connections parameter from the default of 100. [/snip] Andrey - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Andrey Hristov [EMAIL PROTECTED] Cc: Paul Worthington [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:59 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details What do you mean it uses 2? It does not. On Tue, 30 Jul 2002, Andrey Hristov wrote: Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc.
RE: [PHP-DB] mysql_fetch_array limit? - more details
-Original Message- From: Paul Worthington [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 30, 2002 9:34 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array limit? - more details What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. I'm a little curious about this assumption, given that I know I've successfully used mysql_query() and mysql_fetch_array() on pieces of data much bigger than that. Does echo strlen($myrow[txtSWDesc1]); produce the output you'd expect? --- Mark Roedel | There is only one truly satisfying way Systems Programmer| to boot a computer. LeTourneau University | Longview, Texas USA | -- J.H.Goldfuss -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array limit? - more details
I use mysql_fetch array to retrieve large text data many many times without a problem. I've actually written functions to retrieve the data for me using this function, and I never had a single problem, truncated or speed, on Unix, Linux or Windows platform. Check out the code for the functions getrow(), getrows(), they use mysql_fetch array. http://zc8.com/zc8/samplecode/sqltools.phps This is the explanations of the functions: http://zc8.net/zc8/shownews.php?articleid=98 You can use those as you please if you want On Tue, 30 Jul 2002, Paul Worthington wrote: No I don't have PhpMyAdmin installed. I work directly in MySQL via a terminal, so all my checking is with native calls anyway. Working natively in MySQL, all my data is there and everything works the way I expect it to. Using mysql_fetch_array() in PHP results in a truncated result set. And I am trying to figure out why, and how I can work around this problem. Thanks again, Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01ed01c237ea$0d0fcf10$1601a8c0@nik">news:01ed01c237ea$0d0fcf10$1601a8c0@nik... Do you have PhpMyAdmin installed? If you have try with it to see the results. It uses native mysql functions. Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:53 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details Thank you for that idea. I don't think that's it, though, because this script is the only one I'm ever running on this site. The problem is perfectly consistent and repeatable, which leads me to believe it's something in the way the array is being built. Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01cd01c237e8$7e1438b0$1601a8c0@nik">news:01cd01c237e8$7e1438b0$1601a8c0@nik... Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
One thing I haven't seen yet is a cut-n-paste of your db tables. Could you post that to this list? Maybe there's something you're overlooking there? Maybe seomebody will find something amiss there. I know it sounds simple and you might think you have it all down right, but how many times have you been nagged for something stupid like forgetting the ; at the end of a query or PHP statement? Just a thought. -Original Message- From: Paul Worthington [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 30, 2002 10:34 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
on 7/30/02 10:34 AM, Paul Worthington at [EMAIL PROTECTED] appended the following bits to my mbox: I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: . ... $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; . What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in Are you sure that the printf() function can take more than 256 characters of input? Since you are only outputting strings, printf isn't really necessary so you can use the echo command instead. Also, though this probably isn't the reason, you should quote your key names. while ($myrow = mysql_fetch_array($result)) { echo 'trtd',$myrow['Name'],'/td'; echo 'td',$myrow['txtSWDesc1'],'/td/tr'; } HTH. Sincerely, Paul Burney http://paulburney.com/ ?php while ($self != asleep) { $sheep_count++; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Comparison with formatted numbers
I've run into a sticky case where my query is failing (PHP4.x/MySQL). I have a table where the price value is imported from an external source, so I can't change it on the fly, and they embed thousands seperators (in my case ','). When I try to do a query such as .. where price = '25' .. if finds values that meet or exceed that value (returns some in the range of 2,500,000. I gather that it is failing because of the comma (the price field contains values of '2,500,000'). Is there a function that I can use to force the price format to integer before/during the query? Or would it work if I did a number_format on the test value? ie: '.. where price = '200,000' ..' Help would be appreciated. Terry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array limit? - more details
I am a bonehead. In stripping down my code for posting here, the problem suddenly went away. I was building a temporary table and all this time I've been overlooking the fact that my txtSWDesc1 field in the tmp table was set to 255. My apologies to everyone. And thanks for trying to help me. Paul Mark A. Roedel [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... -Original Message- From: Paul Worthington [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 30, 2002 9:34 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array limit? - more details What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. I'm a little curious about this assumption, given that I know I've successfully used mysql_query() and mysql_fetch_array() on pieces of data much bigger than that. Does echo strlen($myrow[txtSWDesc1]); produce the output you'd expect? --- Mark Roedel | There is only one truly satisfying way Systems Programmer| to boot a computer. LeTourneau University | Longview, Texas USA | -- J.H.Goldfuss -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array limit? - more details
My mistake: I was setting the limit myself via an incorrect column definition whilst creating a temporary table. I feel so stupid. Thanks for trying to help me. Paul Kodrik [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I use mysql_fetch array to retrieve large text data many many times without a problem. I've actually written functions to retrieve the data for me using this function, and I never had a single problem, truncated or speed, on Unix, Linux or Windows platform. Check out the code for the functions getrow(), getrows(), they use mysql_fetch array. http://zc8.com/zc8/samplecode/sqltools.phps This is the explanations of the functions: http://zc8.net/zc8/shownews.php?articleid=98 You can use those as you please if you want On Tue, 30 Jul 2002, Paul Worthington wrote: No I don't have PhpMyAdmin installed. I work directly in MySQL via a terminal, so all my checking is with native calls anyway. Working natively in MySQL, all my data is there and everything works the way I expect it to. Using mysql_fetch_array() in PHP results in a truncated result set. And I am trying to figure out why, and how I can work around this problem. Thanks again, Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01ed01c237ea$0d0fcf10$1601a8c0@nik">news:01ed01c237ea$0d0fcf10$1601a8c0@nik... Do you have PhpMyAdmin installed? If you have try with it to see the results. It uses native mysql functions. Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 7:53 PM Subject: Re: [PHP-DB] mysql_fetch_array limit? - more details Thank you for that idea. I don't think that's it, though, because this script is the only one I'm ever running on this site. The problem is perfectly consistent and repeatable, which leads me to believe it's something in the way the array is being built. Paul Worthington [EMAIL PROTECTED] Andrey Hristov [EMAIL PROTECTED] wrote in message 01cd01c237e8$7e1438b0$1601a8c0@nik">news:01cd01c237e8$7e1438b0$1601a8c0@nik... Maybe it will help you but I've read that when using persistent connections PHP uses 2 on every request. So if in one moment you have 10 scripts,that use persistent connections, running you will have 20 connections used to the mysql. Regards, Andrey - Original Message - From: Paul Worthington [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 30, 2002 5:34 PM Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- PHP
Re: [PHP-DB] mysql_fetch_array limit? - more details
Problem solved. I was stupidly overlooking an incorrect column definition in a temporary table. Everything's fine now. Thank you so much for trying to help me, and please excuse my errors. Paul Richard Hutchins [EMAIL PROTECTED] wrote in message 1EA7D3AE70ACD511BE6D006097A78C1E022BF618@USROCEXC">news:1EA7D3AE70ACD511BE6D006097A78C1E022BF618@USROCEXC... One thing I haven't seen yet is a cut-n-paste of your db tables. Could you post that to this list? Maybe there's something you're overlooking there? Maybe seomebody will find something amiss there. I know it sounds simple and you might think you have it all down right, but how many times have you been nagged for something stupid like forgetting the ; at the end of a query or PHP statement? Just a thought. -Original Message- From: Paul Worthington [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 30, 2002 10:34 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array limit? - more details I'm running MySQL 3.23.47 and PHP 4.1.2 on Mac OS X 10.1.5. In my table, I've got two fields: Name VARCHAR(35) and txtSWDesc1 TEXT. According to the manual, TEXT will give me a maximum space of 65,536 bytes per field. I've entered text in this field in the amount of approximately 500 characters. I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: .. $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; ... What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in mysql_fetch_array(), that it must have some size limitation that truncates whatever data it has read to exactly 256 chars. Another possibility is that the mysql_query() could be truncing the result. I've checked my data directly in MySQL, and all the characters are there in direct SELECTs. Can someone please help? I've checked all manuals and FAQs I can, but I can't figure out why I'm having this problem. It should not be happening at all. Is there some size limitation to the array created via mysql_fetch_array()? Is there some other function that will accomodate my data? Is there any custom code to handle my data correctly? Thanks, Paul Worthington [EMAIL PROTECTED] -- The views expressed here are those of the user, not necessarily those of Evolving Systems, Inc. -- 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] mysql_fetch_array limit? - more details
Thanks for all your helpful suggestions. It turns out I was limiting the array myself by setting a temporary table column definition to varchar(255). I have been overlooking it all this time. I feel so stupid. Thanks again for trying to help me. Paul Paul Burney [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... on 7/30/02 10:34 AM, Paul Worthington at [EMAIL PROTECTED] appended the following bits to my mbox: I'm using this PHP code, very simple and straightforward, to select two columns into an array and then display the results in an HTML table: . ... $db = mysql_connect(localhost, user1); mysql_select_db(testdb,$db); $sql = SELECT * FROM tmp ORDER BY Name; $result = mysql_query($sql,$db); echo TABLE\n; echo TR\nTHPlace Name/TH\nTHDescription/TH\n/TR\n; while ($myrow = mysql_fetch_array($result)) { printf(TRTD%s/TDTD%s/TD/TR\n, $myrow[Name], $myrow[txtSWDesc1]); } echo /TABLE\n; . What happens is I'm only getting the first 256 characters of txtSWDesc1 displayed in my table. I am assuming the problem is in Are you sure that the printf() function can take more than 256 characters of input? Since you are only outputting strings, printf isn't really necessary so you can use the echo command instead. Also, though this probably isn't the reason, you should quote your key names. while ($myrow = mysql_fetch_array($result)) { echo 'trtd',$myrow['Name'],'/td'; echo 'td',$myrow['txtSWDesc1'],'/td/tr'; } HTH. Sincerely, Paul Burney http://paulburney.com/ ?php while ($self != asleep) { $sheep_count++; } ? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] time field query problems.
Thanks, I wasn't sure what kind of field to use, I'll give the timestamp a try and set 0 as default. Regards, Steve. -Original Message- From: DL Neil [mailto:[EMAIL PROTECTED]] Sent: Monday, July 29, 2002 6:34 PM To: Steve Bradwell; [EMAIL PROTECTED]; Php-Db (E-mail) Subject: Re: [PHP-DB] time field query problems. Steve, For some reason the below statement is not working. Can anyone tell me why? Select EDIT_LOCK from ordmaster where EDIT_LOCK + INTERVAL 10 MINUTE now() AND ORDER_NO = '5' AND EDIT_LOCK 0; -EDIT_LOCK is a MySQL (ver 3.23.49-max) time field, allows nulls, default is NULL. If this cannot be done in a query, whats the best way to compare time in php? The best way to compare time in PHP is to use the MySQL RDBMS that is managing/retrieving the data for you. Recommendation 1: do not use a Time field (you did mean the back 'half' of a Date-time field didn't you?). Because you are (apparently only) using this field to temporarily lock a row, the value is only ever used for computation (cf display). A Timestamp field is best for computation - a Time field for presentation. Consider also storing such data as an integer field or beware the automatic update feature for Timestamp fields. Recommendation 2: re-consider the (default) use of NULL - this may be the root of the question you're asking: what if the row has never been 'locked' and attempt the (above) SELECT? (then the last comparison clause would be illogical) If the default were zero (0 or 00:00:00) and the retrieval logic updated slightly, things should be less complicated. Regards, =dn - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] A little upgrade help...
I am upgrading from PHP 4.1.2 to 4.2.2, and I cannot get the make install to work. I am doing this on HP-UX 11.00, and I have tried the suggestion of renaming the libphp4.sl files to libphp4.so, but I still get failures. Below is the output of the make install before changing the libphp4 filename: Making install in . /build/php-4.2.2/build/shtool mkdir -p /usr/local/apache/libexec /u sr/local/apache/bin/apxs -S LIBEXECDIR=/usr/local/apache/libexec -i -a -n php4 libs/libphp4.sl apxs:Error: file libs/libphp4.sl is not a DSO *** Error exit code 1 Here is the output after renaming libphp4.sl to libphp4.so in both the libs and .libs directories: Making install in . *** Error exit code 1 Stop. *** Error exit code 1 I am pretty much at my wits end at this point. Any help on this would be most appreciated. Thanks. Scott Nipp Phone: (214) 858-1289 E-mail: [EMAIL PROTECTED] Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Comparison with formatted numbers
try the good ol' SETTYPE function to set the variable type from string to numeric and visa versa... http://www.php.net/manual/en/function.settype.php Terry Romine wrote: I've run into a sticky case where my query is failing (PHP4.x/MySQL). I have a table where the price value is imported from an external source, so I can't change it on the fly, and they embed thousands seperators (in my case ','). When I try to do a query such as .. where price = '25' .. if finds values that meet or exceed that value (returns some in the range of 2,500,000. I gather that it is failing because of the comma (the price field contains values of '2,500,000'). Is there a function that I can use to force the price format to integer before/during the query? Or would it work if I did a number_format on the test value? ie: '.. where price = '200,000' ..' Help would be appreciated. Terry -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Leo G. Divinagracia III [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: Auto Increment Problems....
[straying OT, but...] Instead of incrementing to find the next row to count them, you dont have to set the ID if it is auto increment. MySQL will do it for you (and i think it might fill the holes too). Also, to get the num. of rows just do this - $get_rows = mysql_query(SELECT * FROM `table`); $num_rows = mysql_num_rows($get_rows); Oh my, don't do that! If you only want to get the number of rows in a table, don't bog down the MySQL server by doing a 'SELECT *' on it. This could be a *ton* of data... Why not use MySQL's built-in counting functionality: $result = mysql_query('SELECT count(*) AS count FROM table'); $count_arr = mysql_fetch_assoc($result); $count = $count_arr['count']; MySQL will be able to simply count rows a lot faster than actually SELECTing all of the data. Of course, if you're counting rows just to find out what the next value for an ID is, then, as you already said, you're doing the wrong thing. Joel -- [ joel boonstra | [EMAIL PROTECTED] ] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] dynamic pages
look up HTTP_POST_VARS an related, it's used to retrieve the form data when globals are off. I would like to have the same page (test.php) have different text in it depending on a database entry. which is easy enough. but I want it to be on the fly. example list would be created on the fly depending on databse entries. which ever entry was picked (lets say STLT) it would open up my template test.php and it would but the STLT info on the page. Is there a way to do this without turning on Global_Variables which come standard off in php4.2.2 I'm using apache 2.0.39, PHP4.2.2, FreeBSD4.6, Mysql3.23.51 My database entries would be deparmentpageartical template stlt1body of page test.php aps 1body of page test.php srp 1body of page test2.php main 1body of page test.php the list would be created by a query that looks for all page 1 entries from there the main page would show up(default), but once you pick from the list it would show the database enteries for that department. |---|--- |main | |STLT | STLT was picked show STLT artical database entry |aps | this is are STLT page |srp | | | |---|--- |---|--- |main | |stlt | APS was picked show APS artical database entry |APS | this is are APS page |srp | | | |---|--- I assume that Gobal_Variables are off for a reason. Rolando -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --__-__-__ eat pasta type fasta -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP-DEV] [CROSS POST] PHP Meetup Texas PHP Users
Jay Blanchard wrote: Howdy all! Just wanted to remind everyone that sign-up for the PHP Meetup is still in progress at http://php.meetup.com . At latest count there are 289 folks signed up world-wide with the top 10 cities being; Washington DC (9 members) Toronto (9 members) Leeds, UK (8 members) London, England (8 members) Amsterdam (7 members) Melbourne (6 members) Atlanta (5 members) Oakland-Alameda, CA (5 members) Manhattan (below 42nd St) (5 members) Montréal (4 members) Why do something like this? Meet other developers, networking (you can never tell when you're going to need another pair of hands for a project), networking (you can never tell when someone is going to need to hire extra hands for a project), and networking (you get the idea). Sign up soon! There are thousands of PHP folks out there, spread the word. First of all, sorry for the additional cross post. MeetUp.com lacks the ability to let you contact other folks who have signed up. In my general area, Massachusetts, there are a bunch of tiny groups scattered about, and I'd like a chance to get all of them to converge in one place to make the meetup worth it for all of us. I know there's only a few days before the meetup is to take place, but if folks from the following areas could email me, then we can try and work out somewhere we can all meet, instead of there being 5 groups of 2 or 3 people. Boston, Ma Hyannis, Ma North Boston Suburbs Springfield, Ma Manchester, NH (heck, even people in RI and CT who don't mind driving) Meetup.com cancels meetups for groups less than 5 also, so I'd like to see if we can just get one or two big groups. Also, anyone else in this area... I've been looking for user groups in the Massachusetts area, and the only one that did exist, was PHPUG New England, which doesn't seem to exist anymore. Anyone interested in getting one going around here? Again, sorry for the cross post. -- Gabriel Ricard [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Re: please help.. serial number generator
use the MD5 function and just take the 1st 10 chars or better yet, once you have the MD5 value, use a wacky routine to take the first 10 odd position values... since each time you run the function, it will always return the same value (given the same string parameter...). [EMAIL PROTECTED] wrote: I need to create some kind of 10 digits serial number where I can generate and check that it is valid. Sort of like a checksum.. Jj Harrison [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... if u are looking for a simple random string try this php: echo md5(time()); or md5() a random number your choice. md5() genetates a one way non-reversable hash. which could be kept in a db. here is an example of the md5 hash of my library card number: 11d560821fb027c227d837df53a5a73a md5() is often used to store passwords and make them non-viewable. if you are just looking for a unique number an auto-increment coloumn in mysql or what ever should do it. -- JJ Harrison [EMAIL PROTECTED] www.tececo.com Rainydays Sunshine [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Any ideas how to generate a unique serial number that you can check that it's valid.. Thanks... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Leo G. Divinagracia III [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php