MySQL Forums
Forum List  »  Newbie

Re: Simple Query
Posted by: Russell Dyer
Date: July 09, 2005 10:11PM

If you're getting a value of 0, then your SQL statement is failing. If you have copied and pasted it into the mysql client and it works, then there may be a problem with your connection to MySQL or your user/host combination. Log into the mysql client with the same user and password from the same host and then run the SQL statement. It could be that you have the user name misspelled or the password wrong in your PHP script. It may be that that user from the host where it's being run doesn't have access to the MySQL server. It could also be that that user/host account doesn't have SELECT privileges--very unlikely, though.

You could check the end of your logs for Apache (e.g., /var/log/httpd/error_log) right after you attempt to run the PHP script. This will probably give you an indication of what's wrong. Another method of getting feedback is to test your script from the command-line. Just add the path to the PHP interpreter so that you can run it Put the following first line at the top of your script and then run it from the command-line:

#!/usr/bin/perl -q
<?php
....

This line goes before the first <?php as shown here. When you run it, you should see some error messages at the top of the display in addition to all of you HTML code and so forth.

If you don't figure out the problem on your own based on this research, post here the related error messages from your logs or the output of the script.

Russell Dyer

Author of "MySQL in a Nutshell" (O'Reilly 2005).

Options: ReplyQuote


Subject
Written By
Posted
July 08, 2005 11:15PM
Re: Simple Query
July 09, 2005 10:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.