RE: [PHP-DB] not a valid MySQL result resource
When you get that error, it generally means your query failed, or you have the wrong variable in a mysql_fetch_*() function. Use mysql_error() to see what the error is if the query failed. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ > -Original Message- > From: Addison Ellis [mailto:[EMAIL PROTECTED]] > Sent: Monday, January 20, 2003 2:30 PM > To: [EMAIL PROTECTED] > Subject: [PHP-DB] not a valid MySQL result resource > > hello and thank you for your time. > can you tell me why the below: i think this whole section is > line 22 because whatever i change in these first four lines still has > the error message point to line 22. > $cobj = mysql_db_query($dbname,"select * from category where > id=$category"); //line 22 > $crow = mysql_fetch_object($cobj); > $scobj = mysql_db_query($dbname,"select * from subcategory where > category=$category"); > $scrow = mysql_fetch_object($scobj); > > name;?> >name;?> > > gives me this: > Warning: Supplied argument is not a valid MySQL result resource in > /users/infoserv/web/register/ca/direct.php on line 22 > > > perhaps i should use something different. i am trying to print the > results from two previous selections on this third page. the second > page works with > $cobj = mysql_db_query($dbname,"select * from category where > id=$category"); > $crow = mysql_fetch_object($cobj); > name;?> > > and then they make selection two... > thank you again. addison > -- > Addison Ellis > small independent publishing co. > 114 B 29th Avenue North > Nashville, TN 37203 > (615) 321-1791 > [EMAIL PROTECTED] > [EMAIL PROTECTED] > subsidiaries of small independent publishing co. > [EMAIL PROTECTED] > [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Not a valid MySQL result resource
don't you need it to be SELECT login, password... lowercase first letter? - if you're comparing the columns user.login and user.password. -Original Message- From: DL Neil [mailto:[EMAIL PROTECTED]] Sent: 09 November 2001 01:34 To: MPropre Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Not a valid MySQL result resource > //.../... first part of the code is to connect to the right DB on a MySQL > server. It works fine > //This code to show the query. It runs well under MySQL and gives 1 result : > $query="SELECT Login, Password FROM `user` WHERE user.login=''$login'' and > user.password=''$password''"; > //This var should contain a query result ressource: > $result_query=mysql_query($query); > //Here's my error message after executing: > // Supplied argument is not a valid MySQL result resource in this line: > $result_table=mysql_fetch_array($result_query); > // I thought that this var ($result_table) should contain the row of 2 cells > //And I expected to read $result_table['login'] or $result_table[0] as the > first cell of the row... > // I any of you can help me, poor php newby... :o) Great thanks !! > ?> =Please check the archives for advice about checking the result of every mysql_...() call. It's much better to know/be told by PHP/MySQL than to say "I thought that...I expected to ..." =the $query assignment statement contains multiple double-quotes. These cannot be 'nested'. Use a mixture of single and double-quotes or 'escape' the inner set(s). =also (and this may be a function of our email packages not a PHP thing) are those single quotes around user? =dn -- 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] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.295 / Virus Database: 159 - Release Date: 01/11/01 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.295 / Virus Database: 159 - Release Date: 01/11/01 -- 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] Not a valid MySQL result resource
I'd check for mysql_num_rows( $result_query) > 0 as well. It's entirely possible the user mis-typed the login or password values. Miles At 07:26 PM 11/8/01 -0600, Paul DuBois wrote: >At 2:04 AM +0100 11/9/01, MPropre wrote: >>>//.../... first part of the code is to connect to the right DB on a MySQL >>server. It works fine >> >> >>//This code to show the query. It runs well under MySQL and gives 1 result : >> $query="SELECT Login, Password FROM `user` WHERE user.login=''$login'' and >>user.password=''$password''"; >> >>//This var should contain a query result ressource: >> $result_query=mysql_query($query); >> >>//Here's my error message after executing: > >Not so fast. Where's your error checking to verify that the >query actually succeeded? > >if (!$result_query) >{ > die ("Gee, I guess error checking is a good thing after all!" > . mysql_error ()); >} > >>// Supplied argument is not a valid MySQL result resource in this line: >> $result_table=mysql_fetch_array($result_query); >> >>// I thought that this var ($result_table) should contain the row of 2 cells >>//And I expected to read $result_table['login'] or $result_table[0] as the >>first cell of the row... >>// I any of you can help me, poor php newby... :o) Great 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 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] Not a valid MySQL result resource
> //.../... first part of the code is to connect to the right DB on a MySQL > server. It works fine > //This code to show the query. It runs well under MySQL and gives 1 result : > $query="SELECT Login, Password FROM `user` WHERE user.login=''$login'' and > user.password=''$password''"; > //This var should contain a query result ressource: > $result_query=mysql_query($query); > //Here's my error message after executing: > // Supplied argument is not a valid MySQL result resource in this line: > $result_table=mysql_fetch_array($result_query); > // I thought that this var ($result_table) should contain the row of 2 cells > //And I expected to read $result_table['login'] or $result_table[0] as the > first cell of the row... > // I any of you can help me, poor php newby... :o) Great thanks !! > ?> =Please check the archives for advice about checking the result of every mysql_...() call. It's much better to know/be told by PHP/MySQL than to say "I thought that...I expected to ..." =the $query assignment statement contains multiple double-quotes. These cannot be 'nested'. Use a mixture of single and double-quotes or 'escape' the inner set(s). =also (and this may be a function of our email packages not a PHP thing) are those single quotes around user? =dn -- 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] Not a valid MySQL result resource
At 2:04 AM +0100 11/9/01, MPropre wrote: >//.../... first part of the code is to connect to the right DB on a MySQL >server. It works fine > > >//This code to show the query. It runs well under MySQL and gives 1 result : > $query="SELECT Login, Password FROM `user` WHERE user.login=''$login'' and >user.password=''$password''"; > >//This var should contain a query result ressource: > $result_query=mysql_query($query); > >//Here's my error message after executing: Not so fast. Where's your error checking to verify that the query actually succeeded? if (!$result_query) { die ("Gee, I guess error checking is a good thing after all!" . mysql_error ()); } >// Supplied argument is not a valid MySQL result resource in this line: > $result_table=mysql_fetch_array($result_query); > >// I thought that this var ($result_table) should contain the row of 2 cells >//And I expected to read $result_table['login'] or $result_table[0] as the >first cell of the row... >// I any of you can help me, poor php newby... :o) Great 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]