By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

mysql errors

P: n/a
Hi,
I've run a php script that uses mysql databases without problems
on one server, but then I changed web hosts and installed it the same
way buy I get a lot of errors which are all derived from the
script not being able to interact with the database.
It finds the database and connects, but then can't do anything else.
When it uses a database on a different server, things work fine,
so I'm guessing it's just a mysql error and not the fault of the script.

I'd appreciate any suggestions on how to deal with this.

thank you,
David

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"David Bruno" <we*******@lowestdomains.info> writes:
I've run a php script that uses mysql databases without problems
on one server, but then I changed web hosts and installed it the same
way buy I get a lot of errors which are all derived from the
script not being able to interact with the database.
What are the errors? Saying "I get a lot of errors" doesn't give
us much to analyze.
It finds the database and connects, but then can't do anything else.
How do you know the connection is successful? Does the code do
error checking? Is PHP configured to send errors to the browser?
If not, are you looking in the web server's error logs? See what
happens when you add the following lines to your script before
connecting to the database:

error_reporting(E_ALL);
ini_set('display_errors', True);

Errors can reveal Interesting Things to Bad Guys, so when you're
finished debugging it's usually a good idea to set display_errors
to False.
When it uses a database on a different server, things work fine,
so I'm guessing it's just a mysql error and not the fault of the script.
Possibly. Have you verified that you have permission to connect
to the database and that you have the necessary privileges once
connected?
I'd appreciate any suggestions on how to deal with this.


Please post the exact error messages and the code that caused them.
That'll probably tell us what's wrong.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #2

P: n/a
> What are the errors? Saying "I get a lot of errors" doesn't give
us much to analyze.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/webzero/public_html/skijumping/global.inc.php on line 35

Warning: mysql_free_result(): supplied argument is not a valid MySQL result
resource in /home/webzero/public_html/skijumping/global.inc.php on line 36
How do you know the connection is successful? Does the code do
error checking? Is PHP configured to send errors to the browser?
Errors appear in the browser. Script has as setup.php file which
displays that is has connected to the database, but then
can't write any tables to it.
Possibly. Have you verified that you have permission to connect
to the database and that you have the necessary privileges once
connected?

I just have virtual hosting with cpanel 8.5. I create the database and
that's it. The script does all the set-up. How can I verifty or change
permissions.
Everything is chmod as the installation instructions say.

Thank you very much for your help.
-David
Jul 17 '05 #3

P: n/a
"David Bruno" <we*******@lowestdomains.info> writes:
What are the errors? Saying "I get a lot of errors" doesn't give
us much to analyze.


Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
resource in /home/webzero/public_html/skijumping/global.inc.php on line 35

Warning: mysql_free_result(): supplied argument is not a valid MySQL result
resource in /home/webzero/public_html/skijumping/global.inc.php on line 36


It looks like mysql_query() is failing but the code isn't checking
for that failure. Modify your code to look like this:

$result = mysql_query($sql)
or die("mysql_query() failed: " . htmlentities(mysql_error()));

For production you might want to handle the error more gracefully.

The message from mysql_error() should tell you what's wrong. If
you still can't figure out the problem, then please post some code
so we can see exactly what you're doing.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Jul 17 '05 #4

P: n/a
"Michael Fuhr" <mf***@fuhr.org> wrote in message
news:3f**********@omega.dimensional.com...
"David Bruno" <we*******@lowestdomains.info> writes:
What are the errors? Saying "I get a lot of errors" doesn't give
us much to analyze.
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/webzero/public_html/skijumping/global.inc.php on line 35
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/webzero/public_html/skijumping/global.inc.php on line

36
It looks like mysql_query() is failing but the code isn't checking
for that failure. Modify your code to look like this:

$result = mysql_query($sql)
or die("mysql_query() failed: " . htmlentities(mysql_error()));

Do what michael says here. Also:
echo the query to screen right before you run it. Read it to see if it's
right. Maybe copy it and paste it into phpmyadmin or whatever else you use
to interact with the dB. Might yield more specific info
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.