944,216 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 2527
  • MySQL RSS
Mar 19th, 2005
0

Query Problem

Expand Post »
Okay, not new to MySQL, or PHP, but I'm really lost on this one. I have a query (simple one really) that is supposed to return the requested values from a database. I've tested the query with MySQL direct and it works fine, but when used via the web interface, it chokes and doesn't get a valid result resource.

I don't understand how a valid query can work with MySQL directly but not with the web interface. I've added the query below:

SELECT GUID, FirstName, LastName, Address, Address1, City, State, Zip, Phone, Email, Company, Remove FROM databasename WHERE GUID = '$id'

$id would of course be a POSTed variable. I've also tried this using "SELECT * from databasename" and it also fails for the same reason. Of course, my first thought was something simple so I pasted a working query from another function and it also failed. Nothing is any different for the connection as it's the only one used. And yes, all the column names are correct.

What am I missing?

thx,
Plenty
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pgroover is offline Offline
4 posts
since Mar 2005
Mar 20th, 2005
0

Re: Query Problem

perhaps you are not logged in with the correct username/password combination

if you do have a correct user name/password then...
maybe the one you have doesn't have access to SELECT statments on that database and/or table

try doing this...
MySQL Syntax (Toggle Plain Text)
  1. <?
  2. $server = "localhost";
  3. mysql_connect ($server, $user, $password) OR die ('I cannot connect to the database because: ' . mysql_error());
  4.  
  5. mysql_select_db ($database) OR die ("cannot connect to the datbase");
  6.  
  7. $result = mysql_query("SELECT * FROM databasename");
  8. if ($result == 0)
  9. {
  10. echo("<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>");
  11. }
  12. ELSE
  13. {
  14. echo "the query worked!";
  15. }

hopefully the error message generated gives you enough information to solve your problems. try usign localhost for your host name instead of your domain name.
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Mar 20th, 2005
0

Re: Query Problem

Actually, I use the same connection for all the queries so that rules out the incorrect login/password. Further, I've tried successfully used the query against the database directly, as well as taken other queries known to be good and tried them, but they all fail just in this block of code.

I had also tried as you suggested, but result is actually "1" afterwards, shouldn't it be "Resource ID#x"?? I'll still go back and try again, but I'm not to hopeful...

I know I'm missing something, but I just can't seem to get it.

Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pgroover is offline Offline
4 posts
since Mar 2005
Mar 24th, 2005
0

Re: Query Problem

Post your origional php code for the query.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Mar 30th, 2005
0

Re: Query Problem

Take a look at your apache error log, often you will get an insight there into how a query has failed. In most linux systems its under /var/logs/apache
Reputation Points: 11
Solved Threads: 0
Newbie Poster
synergz is offline Offline
2 posts
since Mar 2005
Apr 2nd, 2005
0

Re: Query Problem

Quote originally posted by DanceInstructor ...
Post your origional php code for the query.
Sorry, was on vacation, I'll post it tomorrow.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pgroover is offline Offline
4 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: Inserting special characters & superscript
Next Thread in MySQL Forum Timeline: Query Code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC