Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP errors from MySQL extension

Status
Not open for further replies.

StickyBit

Technical User
Jan 4, 2002
264
CA
Hello,

I'm receiving the following PHP errors from my web application:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Inetpub\ on line 31

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Inetpub\ on line 32

Warning: mysql_affected_rows(): supplied argument is not a valid MySQL-Link resource in C:\Inetpub\ on line 33

I receive this error when I direct the code to a dev database in my lab. The code works fine when directed to the production database - not sure if this is a PHP or MySQL issue.

Thanks,
Stickybit.
 
mysql_query() can return a resource handle, the boolean value FALSE or the boolean value TRUE, depending on the type of SQL query you pass the function and whether that query generated errors. If you pass mysql_query() a SELECT query, then the function will return a resource handle if the query is successful and FALSE if it is not. I would guess that your code is passing mysql_query() a query that generates a MySQL error (from which mysql_query() will return FALSE), and your code attempts to use the FALSE value returned as if it were a resource handle without checking for error conditions.

See section 1.5 if faq434-2999 or the PHP online manual page for mysql_query() (


Want the best answers? Ask the best questions! TANSTAAFL!
 
In other words, There is something wrong with your actual query. Try adding [green]or die(mysql_error())[/green] after you issue the mysql_query command in your code i.e

Code:
$results=mysql_query("Select...") [red]or die(mysql_error());[/red]

and post back with error it produces. It should give you an idea of what it doesn't like about it.



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
as all he is doing is redirecting working code to a dev machine (and one assumes that the dev environment has the same application version base as the live flavour) it might perhaps be that the poster has forgotten to change the db login information when switching to the dev platform and suppressed erros on the relevant lines.
 
Thank you folks - using "die(mysql_error());" at the end of the connect function resolved my problem. Access was denied to the user.

Thanks folks.
 
Glad you sorted it out.

In conclusion, error checking people, error checking.


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top