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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird PHP/mySQL problem...

Status
Not open for further replies.

steijssen

Programmer
Mar 25, 2001
92
BE
Okay this one's a bit weird..

I have re-installed my pc here, and installed apache 1.3.26 with PHP 4.2.3 and MySQL 3.23.52. I can perfectly run the server, view pages contain PHP stuff, but once I try to show some mysql data it shows nothing. Well, it displays the page and simply ignores all code that has something to do with mySQL. The other code it processed just fine.

Anyone has an idea on this one?

Thanks!
 
Is MySQL running? Are you getting any MySQL errors (is MySQL stating any errors on failed queries)?

If you are not seeing any errors from PHP, try turning on error checking/debugging.
 
mySQL is running as a service, and runs fine. Stuff like phpMyAdmin works ok, I can do all my queries in there.

I get a bunch of errors after setting display_errors to on, all in the form of:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in d:\web\lidium\php_inc\display_downloads.inc on line 16

While this inc file works fine on the remote webserver, it doesn't at my test server here at home...
My connection setup:

$db_error_0 = "blahblah";
mysql_connect("127.0.0.1") or die($db_error_0);
mysql_select_db("lidiumon_general");

Where did I go wrong? 127.0.0.1 is correct, else my phpMyAdmin wouldn't be working. There's no username/pw needed on my test server here.
 
You may have problems with variables being passed to MySQL. Are you familiar with the new global variable deal with PHP 4.2.x? Your remote web server may have these turned on. PHP distributions of 4.2.x have them turned off by default.

If this is the problem, you can either re-write your PHP code or go to you ini file and set the global variables to 'on'. Details about this are on PHP.net. The 4 page introduction to PHP includes a quick description of this. Even if you have used PHP in the past, a re-read is worthwhile.
 
It seems to me as you aren't connecting with any username or password. Try changing your current mysql_connect line to
Code:
$conn = mysql_connnect("127.0.0.1", "root");
//Daniel
 
Nope, none of the above does the trick... I still get the same message.
I don't need to specify a username and password to connect to mySQL on my test server.

Help, anyone?
 
The single most common cause of the dreaded "supplied argument is not a valid MySQL result resource" is a bad query string. If the string is no good, the return from mysql_query() is FALSE. FALSE is not a valid MySQL result resource.

1. Print out the string to the screen and verify that it is in the condition you think it should be.
2. If that works, copy that printout of the string and pass it into whatever MySQL administration console you are using to see whether it's a valid SQL string.

Also, in your code check for errors at each step of the process required to retrieve datat from MySQL. If at any point you get an error (universally indicated by a return of FALSE from a functoin) print out the result of mysql_error() to see what went wrong. ______________________________________________________________________
TANSTAAFL!
 
Yup I got it now. It wasn't something in the query, it was something with how I called one of the mysql functions.

Thanks for the brainstorm guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top