[PHP-DB] Mysql_fetch_array
Does anyone have an idea what may probably be the cause of this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/ng/mailsender2.php on line 17 - A passion till tomorrow, www.opeyemi.tk - Do you Yahoo!? Y! Messenger - Communicate in real time. Download now.
Re: [PHP-DB] Mysql_fetch_array
Yup, we're mind readers, I can figure out your entire script and database structure from the error message. On Thu, 30 Sep 2004 13:30:25 -0700 (PDT), Yemi Obembe [EMAIL PROTECTED] wrote: Does anyone have an idea what may probably be the cause of this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/ng/mailsender2.php on line 17 - A passion till tomorrow, www.opeyemi.tk - Do you Yahoo!? Y! Messenger - Communicate in real time. Download now. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Mysql_fetch_array
It means that the supplied argument is not a valid MySQL result resource so.. Line 17 of your script mailsender2.php is trying to manipulate a variable that isn't actually a mysql result. In some previous line you should have set the result resource variable equal to something else, on that line there is probably some problem with your query or it is empty altogether. We usually call result resource variables $rs, but it can be anything you or your program wanted to call it... Ryan -Original Message- From: Yemi Obembe [mailto:[EMAIL PROTECTED] Sent: Thursday, September 30, 2004 2:30 PM To: [EMAIL PROTECTED] Subject: *** Detected as Spam ***[PHP-DB] Mysql_fetch_array Does anyone have an idea what may probably be the cause of this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /var/www/ng/mailsender2.php on line 17 - A passion till tomorrow, www.opeyemi.tk - Do you Yahoo!? Y! Messenger - Communicate in real time. Download now. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql_fetch_array issues.
I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array issues.
Do you have an 'or die(mysql_error())' statement following your mysql_query($result) line. 99% of the time, this error means your query failed. if it works on another serverare the fields the same, the dbname, the tablename? hth jeff Greg Hetrick [EMAIL PROTECTED]To: [EMAIL PROTECTED] net cc: Subject: [PHP-DB] mysql_fetch_array issues. 07/09/2003 12:04 PM I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- 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 issues.
As far as I know, that error means that the query that was supposed to produce $result did not run because of errors in the SQL (or the database). Suggest you check your query in myPHPAdmin or MySQLfront or whatever to be sure that it has no errors. Terry --Original Message- I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array issues.
I do not have the die statment -- the DB is the same except the name and I have double checked that I just did a back up of the previous db and moved it to the new server. I have done some more digging, my query appears to work, but I almost appears that I have a problem with selecting the database -- if I comment out the mysql_select -- statment I get the same error, perhaps I just can't get to that DB. intresting. I guess I can assume at this point there is something flaky with my DB Jeffrey N Dyke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Do you have an 'or die(mysql_error())' statement following your mysql_query($result) line. 99% of the time, this error means your query failed. if it works on another serverare the fields the same, the dbname, the tablename? hth jeff Greg Hetrick [EMAIL PROTECTED]To: [EMAIL PROTECTED] net cc: Subject: [PHP-DB] mysql_fetch_array issues. 07/09/2003 12:04 PM I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- 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 issues.
Query is correct appears to be a problem connecting to the db -- I can comment out the mysql_select line and I get no change. Terry Riley [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] As far as I know, that error means that the query that was supposed to produce $result did not run because of errors in the SQL (or the database). Suggest you check your query in myPHPAdmin or MySQLfront or whatever to be sure that it has no errors. Terry --Original Message- I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql_fetch_array issues.
Do you have select permissions on that DB/table? If you have GRANT permissions, try GRANS SELECT, INSERT, UPDATE, DELETE ON db.tablename to 'youruser'@'your.ip.address' IDENTIFIED BY 'yourpassword'; your.ip.address can be substituted with localhost if you're on the same box. Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 Pay It Forward mailto:[EMAIL PROTECTED] http://accessingram.com -Original Message- From: Greg Hetrick [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 12:31 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array issues. I do not have the die statment -- the DB is the same except the name and I have double checked that I just did a back up of the previous db and moved it to the new server. I have done some more digging, my query appears to work, but I almost appears that I have a problem with selecting the database -- if I comment out the mysql_select -- statment I get the same error, perhaps I just can't get to that DB. intresting. I guess I can assume at this point there is something flaky with my DB Jeffrey N Dyke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Do you have an 'or die(mysql_error())' statement following your mysql_query($result) line. 99% of the time, this error means your query failed. if it works on another serverare the fields the same, the dbname, the tablename? hth jeff Greg Hetrick [EMAIL PROTECTED]To: [EMAIL PROTECTED] net cc: Subject: [PHP-DB] mysql_fetch_array issues. 07/09/2003 12:04 PM I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- 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 issues.
Yup, I have all permissions -- it appears that I can access mysql but not the database itself. Gary Every [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] . Do you have select permissions on that DB/table? If you have GRANT permissions, try GRANS SELECT, INSERT, UPDATE, DELETE ON db.tablename to 'youruser'@'your.ip.address' IDENTIFIED BY 'yourpassword'; your.ip.address can be substituted with localhost if you're on the same box. Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 Pay It Forward mailto:[EMAIL PROTECTED] http://accessingram.com -Original Message- From: Greg Hetrick [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 12:31 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array issues. I do not have the die statment -- the DB is the same except the name and I have double checked that I just did a back up of the previous db and moved it to the new server. I have done some more digging, my query appears to work, but I almost appears that I have a problem with selecting the database -- if I comment out the mysql_select -- statment I get the same error, perhaps I just can't get to that DB. intresting. I guess I can assume at this point there is something flaky with my DB Jeffrey N Dyke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Do you have an 'or die(mysql_error())' statement following your mysql_query($result) line. 99% of the time, this error means your query failed. if it works on another serverare the fields the same, the dbname, the tablename? hth jeff Greg Hetrick [EMAIL PROTECTED]To: [EMAIL PROTECTED] net cc: Subject: [PHP-DB] mysql_fetch_array issues. 07/09/2003 12:04 PM I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- 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 issues.
this error only means that your msql_query($result) was correct, but did not have any result... meaning, there was nothing to select, there for there is nothing to fetch... hence you can not do a msql_fetch_array() on an empty result set. KD On Wed, 9 Jul 2003, Greg Hetrick wrote: Yup, I have all permissions -- it appears that I can access mysql but not the database itself. Gary Every [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] . Do you have select permissions on that DB/table? If you have GRANT permissions, try GRANS SELECT, INSERT, UPDATE, DELETE ON db.tablename to 'youruser'@'your.ip.address' IDENTIFIED BY 'yourpassword'; your.ip.address can be substituted with localhost if you're on the same box. Gary Every Sr. UNIX Administrator Ingram Entertainment (615) 287-4876 Pay It Forward mailto:[EMAIL PROTECTED] http://accessingram.com -Original Message- From: Greg Hetrick [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 09, 2003 12:31 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array issues. I do not have the die statment -- the DB is the same except the name and I have double checked that I just did a back up of the previous db and moved it to the new server. I have done some more digging, my query appears to work, but I almost appears that I have a problem with selecting the database -- if I comment out the mysql_select -- statment I get the same error, perhaps I just can't get to that DB. intresting. I guess I can assume at this point there is something flaky with my DB Jeffrey N Dyke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Do you have an 'or die(mysql_error())' statement following your mysql_query($result) line. 99% of the time, this error means your query failed. if it works on another serverare the fields the same, the dbname, the tablename? hth jeff Greg Hetrick [EMAIL PROTECTED]To: [EMAIL PROTECTED] net cc: Subject: [PHP-DB] mysql_fetch_array issues. 07/09/2003 12:04 PM I am getting the following error when attempting to pull data out of a mysql DB Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pffl/public_html/pffl/webpage/html/dataentry.php on line 125 I can take this same code to a different web server and it is pulling correctly! I am currently running Apache 2.0.46 with PHP 4.3.2 I was running Apache 1.3.x with PHP 4.3.1 and getting the same thing, any ideas? here is the chunk of code where I use the function. while ($myrow=mysql_fetch_array($result)) { ? option value=?print $myrow['name'];?, ?print $myrow['team'];? ? echo $myrow[name]; ?/option ? } Any Ideas. -- 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-DB] mysql_fetch_array
Hi, Here is my code: ? require(util.php); $sql= new MySQL_class; $sql-Setup(user,user,localhost); $sql-connexion(materiel); $sql-Query(select nom from personne); $cpt=0; while($row=mysql_fetch_array($sql-result)) { print($cpt); print(br); print($row[nom]); print(br); $cpt++; } $sql-close; ? The personne table has 14 articles. but with this code i can see only 13 articles here is the output on a browser: 0BRUYÈRE 1COLLINEAU 2ELIAS 3GLOANEC 4HUGOT 5LE BRIS 6LE FLOCH 7LEMAUVIEL 8LOUVEL 9MARTINIERE 10OGUET 11THOMAS 12VASSELET What is the problem ? Thanks Franck -- Faites un voeu et puis Voila ! www.voila.fr -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] mysql_fetch_array and extract() with LEFT SELECT
I'm having a problem when I use mysql_fetch_array and extract() following a left select query. As an example... $query = SELECT id,LEFT(fluff,80) FROM sometable; $result = mysql_query($query) or die('message'); while ($row = mysql_fetch_array($result){ extract($row); echo P . $id . : . $fluff . /P; } would echo the $id, but there would be nothing for $fluff. However, if I select only 'fluff' from the MySQL table, I get the full text for $fluff. I am reluctant to SELECT the entire fluff text from the table and shorten it in PHP as that seems inefficient to me - (but correct me if I am wrong). I expect the solution must be dead easy, but I can't find it or figure it out. Many thanks, Jeffrey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array and extract() with LEFT SELECT
Try SELECT id,LEFT(fluff,80) as fluffy FROM sometable Then extract() will have a value for fluffy --- Baumgartner Jeffrey [EMAIL PROTECTED] wrote: I'm having a problem when I use mysql_fetch_array and extract() following a left select query. As an example... $query = SELECT id,LEFT(fluff,80) FROM sometable; $result = mysql_query($query) or die('message'); while ($row = mysql_fetch_array($result){ extract($row); echo P . $id . : . $fluff . /P; } would echo the $id, but there would be nothing for $fluff. However, if I select only 'fluff' from the MySQL table, I get the full text for $fluff. I am reluctant to SELECT the entire fluff text from the table and shorten it in PHP as that seems inefficient to me - (but correct me if I am wrong). I expect the solution must be dead easy, but I can't find it or figure it out. Many thanks, Jeffrey -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php = Mark Weinstock [EMAIL PROTECTED] *** You can't demand something as a right unless you are willing to fight to death to defend everyone else's right to the same thing. *** __ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mysql_fetch_array() question
On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like eg. userid) which links the two together. If there isn't one then you should seriously restructure your tables so that there is one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Cats are smarter than dogs. You can't make eight cats pull a sled through the snow. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] mysql_fetch_array() question
I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like eg. userid) which links the two together. If there isn't one then you should seriously restructure your tables so that there is one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Cats are smarter than dogs. You can't make eight cats pull a sled through the snow. */ -- 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() question
Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like eg. userid) which links the two together. If there isn't one then you should seriously restructure your tables so that there is one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Cats are smarter than dogs. You can't make eight cats pull a sled through the snow. */ -- 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() question
In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, shortcomings of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like eg. userid) which links the two together. If there isn't one then you should seriously restructure your tables so that there is one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Cats are smarter than dogs. You can't make eight cats pull a sled through the snow. */ -- 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() question
That's not true. You can assign them to different variables and it works fine. $r1 = mysql_query(select * from main limit 1) or die(mysql_error()); $r2 = mysql_query(select * from apft limit 1) or die(mysql_error()); $row1 = mysql_fetch_array($r1); $row2 = mysql_fetch_array($r2); print_r($row1); echo brhr; print_r($row2); ---John Holmes... - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 1:02 PM Subject: RE: [PHP-DB] mysql_fetch_array() question In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, shortcomings of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like eg. userid) which links the two together. If there isn't one then you should seriously restructure your tables so that there is one. -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* Cats are smarter than dogs. You can't make eight cats pull a sled through the snow. */ -- PHP Database Mailing List (http
RE: [PHP-DB] mysql_fetch_array() question
:) see why I love mailing lists! :) It must have been their logic then, I respectfully retract everything I said, sorry Graeme! Why do I have to work, I could spend my days researching this stuff before I post! Thanks John! -- Josh -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: Wednesday, November 06, 2002 1:21 PM To: Josh Johnson; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question That's not true. You can assign them to different variables and it works fine. $r1 = mysql_query(select * from main limit 1) or die(mysql_error()); $r2 = mysql_query(select * from apft limit 1) or die(mysql_error()); $row1 = mysql_fetch_array($r1); $row2 = mysql_fetch_array($r2); print_r($row1); echo brhr; print_r($row2); ---John Holmes... - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 1:02 PM Subject: RE: [PHP-DB] mysql_fetch_array() question In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, shortcomings of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question On Tuesday 05 November 2002 05:47, Graeme McLaren wrote: Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } Unless I've missed something you're going about this the wrong way. For what you want to do, you should (in general) be able to accomplish it using just a single query. What fields do the tables 'users' and 'Members' contain? There should be a field there (like
Re: [PHP-DB] mysql_fetch_array() question
John is right. In fact one routinely calls two different $result(s) when coding nested loops: while( $details = mysql_fetch_array( $result ) ) { while ( $Email = mysql_fetch_array( $result2 ) ) .. } } when executing the next instance of your loop: while( $details = mysql_fetch_array( $result ) and $Email = mysql_fetch_array( $result2 ) ), each mysql_fetch_array will push both pointers (on your two result resources) by one position. if your result sets do not have the same number of rows, the shorter one will choke before the longer one is finished. therefore you will finish the loop not having called all results from the long resource. My 0.02 Belgian francs Ignatius - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: '1LT John W. Holmes' [EMAIL PROTECTED]; 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 7:24 PM Subject: RE: [PHP-DB] mysql_fetch_array() question :) see why I love mailing lists! :) It must have been their logic then, I respectfully retract everything I said, sorry Graeme! Why do I have to work, I could spend my days researching this stuff before I post! Thanks John! -- Josh -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: Wednesday, November 06, 2002 1:21 PM To: Josh Johnson; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question That's not true. You can assign them to different variables and it works fine. $r1 = mysql_query(select * from main limit 1) or die(mysql_error()); $r2 = mysql_query(select * from apft limit 1) or die(mysql_error()); $row1 = mysql_fetch_array($r1); $row2 = mysql_fetch_array($r2); print_r($row1); echo brhr; print_r($row2); ---John Holmes... - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 1:02 PM Subject: RE: [PHP-DB] mysql_fetch_array() question In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, shortcomings of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able to accomplish what you want to do with two separate connections, but again, this is seriously overkill. :) I'd definitely recommend restructuring your talbes as Jason suggested. -- Josh -Original Message- From: Jason Wong [mailto:phplist;gremlins.com.hk] Sent: Wednesday, November 06, 2002 5:24 AM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB
RE: [PHP-DB] mysql_fetch_array() question
Of course, you can avoid that problem if you use a join, I guess it all comes down to code complexity vs SQL complexity. -- Josh -Original Message- From: Ignatius Reilly [mailto:ignatius.reilly;free.fr] Sent: Wednesday, November 06, 2002 1:38 PM To: Josh Johnson; '1LT John W. Holmes'; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question John is right. In fact one routinely calls two different $result(s) when coding nested loops: while( $details = mysql_fetch_array( $result ) ) { while ( $Email = mysql_fetch_array( $result2 ) ) .. } } when executing the next instance of your loop: while( $details = mysql_fetch_array( $result ) and $Email = mysql_fetch_array( $result2 ) ), each mysql_fetch_array will push both pointers (on your two result resources) by one position. if your result sets do not have the same number of rows, the shorter one will choke before the longer one is finished. therefore you will finish the loop not having called all results from the long resource. My 0.02 Belgian francs Ignatius - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: '1LT John W. Holmes' [EMAIL PROTECTED]; 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 7:24 PM Subject: RE: [PHP-DB] mysql_fetch_array() question :) see why I love mailing lists! :) It must have been their logic then, I respectfully retract everything I said, sorry Graeme! Why do I have to work, I could spend my days researching this stuff before I post! Thanks John! -- Josh -Original Message- From: 1LT John W. Holmes [mailto:holmes072000;charter.net] Sent: Wednesday, November 06, 2002 1:21 PM To: Josh Johnson; 'Graeme McLaren'; [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question That's not true. You can assign them to different variables and it works fine. $r1 = mysql_query(select * from main limit 1) or die(mysql_error()); $r2 = mysql_query(select * from apft limit 1) or die(mysql_error()); $row1 = mysql_fetch_array($r1); $row2 = mysql_fetch_array($r2); print_r($row1); echo brhr; print_r($row2); ---John Holmes... - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: 'Graeme McLaren' [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 1:02 PM Subject: RE: [PHP-DB] mysql_fetch_array() question In my experience, (I haven't checked the docs just yet to figure out exactly why), you can only work with one result id at a time. Every time you call mysql_query, it resets the result id (I think it frees the result id automatically so you can send another query before getting the new result id), so even if you store it in two separate variables, it will only refrence the last id (which sounds just like what happened in your initial post). I think this is limited to a given connection, but I'm not sure. One of the, I guess you could say, shortcomings of the mysql interface in php is that you can only execute one query at a time, and I think this odd result id overwrighting that happens is due to that fact (I might be wrong, but I think you can execute multiple queries at a time with perl's DBI module). I hope that makes more sense :) -- Josh -Original Message- From: Graeme McLaren [mailto:mickel;ntlworld.com] Sent: Wednesday, November 06, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] mysql_fetch_array() question Josh, Thank you for reply. Thank you to everyone else who replied to my email also. I solved the problem shortly after posting my question, I've now got a massive SQL query which does the trick. I was interested when you replied and part of it read: Just remember that you can only work with one mysql result per connection at a time. Can you explain a little more about that please? I don't think I fully understand what you mean. Cheers, Graeme :) - Original Message - From: Josh Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, November 06, 2002 12:29 PM Subject: RE: [PHP-DB] mysql_fetch_array() question I concur with Jason, but if restructuring is out of the question, just rearrange your queries like this: $query = SELECT Name, Address FROM users; $result = mysql_query($query); while($details = mysql_fetch_array($result)){ echo Name: $details[Name]; echo Address: $details[Address]; } $query2 = SELECT EmailAddress From Members; $result2 = mysql_query($query2); while($details = mysql_fetch_array($result2)){ echo Email: $Email[EmailAddress]; } The results won't come out at the same time, but you could use some logic to combine the results into an array by a common factor. Just remember that you can only work with one mysql result per connection at a time. You *may* (untested!) be able
[PHP-DB] mysql_fetch_array() question
Hi, Anyone know how I can use two mysql_fetch_array() functions similar to the code below? I've tried a few different ways but I keep getting Resource ID #4. I need to do this to retrieve an email address from one table and retrieve details from another. Cheers for any tips - I'm stumped with this one, Graeme :) $query = SELECT Name, Address FROM users; $query2 = SELECT EmailAddress From Members; $result = mysql_query($query); $result2 = mysql_query($query2); while($details = mysql_fetch_array($result) and $Email = mysql_fetch_array($result2)) { echo Name: $details[Name]; echo Address: $details[Address]; echo Email: $Email[EmailAddress]; } -- 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_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 Datab
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
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.
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] mysql_fetch_array() doesn't work
echo a href='$PHP_SELF?offset=$i*$step' target='_top' Missing end quote and semicolon on this line may be the reason... Try properly indenting and formatting your code. Also take advantage of going in and out of php mode to seperate your code from your display of content... Ex: instead of this: ? echo(td align=\center\ width=\$nWidth\$sContent/td); ? Try this: td align=center width=? echo($nWidth); ?? echo($sContent); ?/td Or even this: td align=center width=?=$nWidth??=$sContent?/td It makes it MUCH easier to read and maintain, and seperates the PHP code from the HTML content as much as possible. Any questions, please ask me. -Jason Garber Lead Programmer - www.pulseaday.com [EMAIL PROTECTED] At 12:48 PM 9/27/2001 +0800, you wrote: System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line] What's the problem wiht mysql_fetch_array() or other? What does the T_STRING' or `T_VARIABLE' or `T_NUM_STRING' mean? THANKS Mike The full code below: ? $link=mysql_connect(localhost,,); if($link==false){ echo Failed linking to database.; exit(); } $handler=mysql_select_db(database1); if($handler==false) echo Failed linking to database.; $query=selct count(*) from users where sign=1; $res=mysql_query($query); $row=mysql_fetch_row($res); $all=$row[0]; $step=5; $pages=ceil($all/$step); /*the number of pages needed to listed */ if(empty($offset)) $offset=0; $query=select user_id, user_name, time, status, comment from users where sign=1 order by user_name limit $offset, $step; $res=mysql_query($query); echo tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/td/tr; $num=mysql_num_rows($res); for($i=0; $i$num; $i++) { $arr=mysql_fetch_array($res); /* HERE is line where the error occurs!!! */ echo trtd align=centera href=\profile.php?id=$arr['user_id']\ target='_top' $arr['user_name']/a/td; echo td align=center$arr['time']/td; echo td align=center$arr['status']/td/tr; echo tr colspan=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd align='center'; /* show others in multi-pages */ for($i=0; $i$pages; $i++){ echo a href='$PHP_SELF?offset=$i*$step' target='_top' echo ($i+1)./a; echo nbsp;nbsp;; } echo /td/tr/table; ? - create table users ( user_id int not null auto_increment primary key, user_name varchar(30), time datetime, status tinyint(1), comment text, sign tinyint(1) default '1' ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] mysql_fetch_array() doesn't work
change coding to (note, each line is enclosed in quotes and ends withn .): $query=select user_id, user_name, time, status, comment from users. where sign=1. order by user_name. limit $offset, $step; print $query; //sanity check...contents of $query $res=mysql_query($query) or die(mysql_error()); //note the die() clause -Original Message- From: Web user [mailto:[EMAIL PROTECTED]] Sent: 27 September 2001 05:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array() doesn't work System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line] What's the problem wiht mysql_fetch_array() or other? What does the T_STRING' or `T_VARIABLE' or `T_NUM_STRING' mean? THANKS Mike The full code below: - ? $link=mysql_connect(localhost,,); if($link==false){ echo Failed linking to database.; exit(); } $handler=mysql_select_db(database1); if($handler==false) echo Failed linking to database.; $query=selct count(*) from users where sign=1; $res=mysql_query($query); $row=mysql_fetch_row($res); $all=$row[0]; $step=5; $pages=ceil($all/$step); /*the number of pages needed to listed */ if(empty($offset)) $offset=0; $query=select user_id, user_name, time, status, comment from users where sign=1 order by user_name limit $offset, $step; $res=mysql_query($query); echo tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/td/tr; $num=mysql_num_rows($res); for($i=0; $i$num; $i++) { $arr=mysql_fetch_array($res); /* HERE is line where the error occurs!!! */ echo trtd align=centera href=\profile.php?id=$arr['user_id']\ target='_top' $arr['user_name']/a/td; echo td align=center$arr['time']/td; echo td align=center$arr['status']/td/tr; echo tr colspan=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd align='center'; /* show others in multi-pages */ for($i=0; $i$pages; $i++){ echo a href='$PHP_SELF?offset=$i*$step' target='_top' echo ($i+1)./a; echo nbsp;nbsp;; } echo /td/tr/table; ? - create table users ( user_id int not null auto_increment primary key, user_name varchar(30), time datetime, status tinyint(1), comment text, sign tinyint(1) default '1' ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mysql_fetch_array() doesn't work
System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line] What's the problem wiht mysql_fetch_array() or other? What does the T_STRING' or `T_VARIABLE' or `T_NUM_STRING' mean? THANKS Mike The full code below: - ? $link=mysql_connect(localhost,,); if($link==false){ echo Failed linking to database.; exit(); } $handler=mysql_select_db(database1); if($handler==false) echo Failed linking to database.; $query=selct count(*) from users where sign=1; $res=mysql_query($query); $row=mysql_fetch_row($res); $all=$row[0]; $step=5; $pages=ceil($all/$step); /*the number of pages needed to listed */ if(empty($offset)) $offset=0; $query=select user_id, user_name, time, status, comment from users where sign=1 order by user_name limit $offset, $step; $res=mysql_query($query); echo tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/td/tr; $num=mysql_num_rows($res); for($i=0; $i$num; $i++) { $arr=mysql_fetch_array($res); /* HERE is line where the error occurs!!! */ echo trtd align=centera href=\profile.php?id=$arr['user_id']\ target='_top' $arr['user_name']/a/td; echo td align=center$arr['time']/td; echo td align=center$arr['status']/td/tr; echo tr colspan=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd align='center'; /* show others in multi-pages */ for($i=0; $i$pages; $i++){ echo a href='$PHP_SELF?offset=$i*$step' target='_top' echo ($i+1)./a; echo nbsp;nbsp;; } echo /td/tr/table; ? - create table users ( user_id int not null auto_increment primary key, user_name varchar(30), time datetime, status tinyint(1), comment text, sign tinyint(1) default '1' ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] mysql_fetch_array() doesn't work
that's not a mysql_fetch_array() error it's a coding error -Original Message- From: Web user [mailto:[EMAIL PROTECTED]] Sent: 27 September 2001 05:48 To: [EMAIL PROTECTED] Subject: [PHP-DB] mysql_fetch_array() doesn't work System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\web\site1\list.php on line --[the number of line] What's the problem wiht mysql_fetch_array() or other? What does the T_STRING' or `T_VARIABLE' or `T_NUM_STRING' mean? THANKS Mike The full code below: - ? $link=mysql_connect(localhost,,); if($link==false){ echo Failed linking to database.; exit(); } $handler=mysql_select_db(database1); if($handler==false) echo Failed linking to database.; $query=selct count(*) from users where sign=1; $res=mysql_query($query); $row=mysql_fetch_row($res); $all=$row[0]; $step=5; $pages=ceil($all/$step); /*the number of pages needed to listed */ if(empty($offset)) $offset=0; $query=select user_id, user_name, time, status, comment from users where sign=1 order by user_name limit $offset, $step; $res=mysql_query($query); echo tabletd align=centerUser/td td align=centerAdded time/tdtd align=centerStatus/td/tr; $num=mysql_num_rows($res); for($i=0; $i$num; $i++) { $arr=mysql_fetch_array($res); /* HERE is line where the error occurs!!! */ echo trtd align=centera href=\profile.php?id=$arr['user_id']\ target='_top' $arr['user_name']/a/td; echo td align=center$arr['time']/td; echo td align=center$arr['status']/td/tr; echo tr colspan=3td$arr['comment']/td/tr; } echo /tablebrbrbr; echo tabletrtd align='center'; /* show others in multi-pages */ for($i=0; $i$pages; $i++){ echo a href='$PHP_SELF?offset=$i*$step' target='_top' echo ($i+1)./a; echo nbsp;nbsp;; } echo /td/tr/table; ? - create table users ( user_id int not null auto_increment primary key, user_name varchar(30), time datetime, status tinyint(1), comment text, sign tinyint(1) default '1' ); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mysql_fetch_array() doesn't work
System: PHP4.06 + Mysql3.23.41 Win32 + Apache 1.3.20 Win32 + Win98 ? .. .. $res=mysql_query($query); $num=mysql_num_rows($res); for($i=0; $i$num; $i++){ $arr=mysql_fetch_array($res); ... } ... When PHP is running at the line: $arr=mysql_fetch_array($res); The IE always show info as below: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\...\page.php on line ... What's the problem wiht mysql_fetch_array() or other? Thanks! Mike -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mysql_fetch_array missing first record
Hi, I have this code to display records from a table by reading them into an array: while ($previews = mysql_fetch_array($result) { code to display record here... } For some reason it refuses to display the very first record in the table. Why is this and how can I get round it? Thanks. Jamie Saunders -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql_fetch_array missing first record
on 8/7/01 1:41 PM, Jamie ([EMAIL PROTECTED]) wrote: while ($previews = mysql_fetch_array($result) { code to display record here... } For some reason it refuses to display the very first record in the table. Why is this and how can I get round it? Are you calling mysql_fetch_array before this in your code, perhaps to see if there is a result? If so, that's the problem. Each call to mysql_fetch_array (mysql_fetch_row) increments the array pointer. If that isn't your problem, please post more of the code so that we can make a better diagnosis. Sincerely, Paul Burney +-+-+ | Paul Burney | P: 310.825.8365 | | Webmaster Programmer | E: [EMAIL PROTECTED] | | UCLA - GSEIS - ETU | W: http://www.gseis.ucla.edu/ | +-+-+ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql_fetch_array missing first record
At 9:41 PM +0100 8/7/01, Jamie wrote: Hi, I have this code to display records from a table by reading them into an array: while ($previews = mysql_fetch_array($result) { code to display record here... } For some reason it refuses to display the very first record in the table. The first record in the table, or the first record in the result set? Why is this and how can I get round it? Hard to say without seeing the surrounding context. Thanks. Jamie Saunders -- Paul DuBois, [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql_fetch_array missing first record
This was indeed the problem, I was calling the mysql_fetch_array earlier in the code. Once removed it worked fine. Thanks. Jamie Paul Burney [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... on 8/7/01 1:41 PM, Jamie ([EMAIL PROTECTED]) wrote: while ($previews = mysql_fetch_array($result) { code to display record here... } For some reason it refuses to display the very first record in the table. Why is this and how can I get round it? Are you calling mysql_fetch_array before this in your code, perhaps to see if there is a result? If so, that's the problem. Each call to mysql_fetch_array (mysql_fetch_row) increments the array pointer. If that isn't your problem, please post more of the code so that we can make a better diagnosis. Sincerely, Paul Burney +-+-+ | Paul Burney | P: 310.825.8365 | | Webmaster Programmer | E: [EMAIL PROTECTED] | | UCLA - GSEIS - ETU | W: http://www.gseis.ucla.edu/ | +-+-+ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mysql_fetch_array problem
Greetings, I'm experiencing the strangest problem and I was wondering if anyone else has had the same problem. I have a fairly simple script setup that queries a mySQL database and displays the records in a HTML table. Everything works fine except it keeps omitting the first record. Running the query directly on the database returns 3 records but only 2 are displayed in the table. I just upgraded to PHP 4.0.6 and I'm still having the problem. I've also tried using mysql_fetch_array and mysql_fetch_object, both produce the same results. The first record is left out every time. Any idea as to what the problem might be? Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql_fetch_array problem
I was having the same problem for a while... although, I was using this: for($i=0;$imysql_num_rows($result);$i++) doStuffTo(mysql_result($result, $i, foo); If I remember correctly... it has to do with zero-based indexing versus 1-based indexing. Now... I think I fixed it by using = instead of just . But, it has been a while so I could be totally off = Good luck, Ben Quoting BrianSander [EMAIL PROTECTED]: Greetings, I'm experiencing the strangest problem and I was wondering if anyone else has had the same problem. I have a fairly simple script setup that queries a mySQL database and displays the records in a HTML table. Everything works fine except it keeps omitting the first record. Running the query directly on the database returns 3 records but only 2 are displayed in the table. I just upgraded to PHP 4.0.6 and I'm still having the problem. I've also tried using mysql_fetch_array and mysql_fetch_object, both produce the same results. The first record is left out every time. Any idea as to what the problem might be? Thanks. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] mysql_fetch_array problem...!
I want to run a query to my db, fetching different fields from three different tables. In order to recognise the individual fields I give them names: select portal.portal as portal, portal.portalid as id... etc etc How can I refer to one specific row in this query..? What I mean is, how can i refer to result row number 4...? If I only selected rows from one table I could do something like this: $i = mysql_fetch_array($sql) ; echo "$i[4]" ; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql_fetch_array problem...!
How can I refer to one specific row in this query..? What I mean is, how can i refer to result row number 4...? If I only selected rows from one table I could do something like this: $i = mysql_fetch_array($sql) ; echo "$i[4]" ; Actually, no. mysql_fetch_array return the _current row_ from the query (use this function in a loop to process each row of the resulting data). $i[4] in your case is the fourth field in the current row. If you really don't want to process the rows in order, look at the documentation for mysql_data_seek; it can be used to jump around the result set. - Darryl -- Darryl Friesen, B.Sc., Programmer/Analyst[EMAIL PROTECTED] Education Research Technology Services, http://gollum.usask.ca/ Department of Computing Services, University of Saskatchewan -- "Go not to the Elves for counsel, for they will say both no and yes" -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] mysql_fetch_array problem...!
You must use a loop to show each row of your query. "mysql_fetch_array($result)" only get the current row. while($row = mysql_fetch_array($result) ){ // do something } The "mysql_fetch_array" function returns an associative array where you can use the field names to have access to its value : $row = mysql_fetch_array($result) ; $v1 = $row["fieldname1"] ; $v2 = $row["fieldname2"] ; $v3 = $row["fieldname3"] ; You're going to use the alias names you are creating on the query. See more details on php manual at mysql functions. HTH. Jayme. -Mensagem Original- De: Trond Erling Hundal [EMAIL PROTECTED] Para: PHP-DB-LIST [EMAIL PROTECTED] Enviada em: segunda-feira, 5 de maro de 2001 09:56 Assunto: [PHP-DB] mysql_fetch_array problem...! I want to run a query to my db, fetching different fields from three different tables. In order to recognise the individual fields I give them names: select portal.portal as portal, portal.portalid as id... etc etc How can I refer to one specific row in this query..? What I mean is, how can i refer to result row number 4...? If I only selected rows from one table I could do something like this: $i = mysql_fetch_array($sql) ; echo "$i[4]" ; -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]