0

Ok so this has me a little stumped. I have a WHERE clause that produces results in phpmyadmin but not on the web page. Here is what I have

$sqlCur = mysql_query("SELECT * FROM currency WHERE  airframe = '$acft'");

This produces a blank result on the webpage. $acft has been echo and has data. When I run the same query in phpmyadmin the row is produced as it should.

Now here is the kicker this code

$sqlCur = mysql_query("SELECT * FROM currency WHERE  username = '$user'");

Works fine on the website. When I search with this and echo the table colum it will show a value of 0 or what ever is in there.

So even if I use this

$sqlCur = mysql_query("SELECT * FROM currency WHERE  username = '$user' && airframe = '$acft'");

there is a blank return. I echo all varibles and it has data, i.e. $user = John SMith and $acft = C32 and when I plug those varibles in phpmyadmin i get a result. Now to really throw a wrench in it, this only effects 1 user. Checking others user everything produces just fine. Am I missing something obvious or just being a derp

5
Contributors
8
Replies
17
Views
3 Years
Discussion Span
Last Post by diafol
0

PHP has deprecated the mysql apis in favor of the mysqli classes and apis. Try that instead. FWIW, what version of PHP are you using?

0

Rubberman, I am aware of the change to mysqli and I will invoke it at a later date with this website. I at first thought that may be the issue but when it only happens with 1 particular name I knew that could not be the cause. As a last resort I was going to delete the user and have them re sign up but thought Id see what suggestions came across here in case I overlooked something. I may see about switching this part to mysqli just to see, as you just never know.

0

You code for line one looks valid, of course I can only assume you are escaping the value $acft, otherwise it is prone to sql injection.

But what exactly is the value of $acft for that particular user. You haven't told us?

0
$sqlCur = mysql_query("SELECT * FROM currency WHERE  username = '$user' AND airframe = '$acft'");

Assumptions
1. currency is a valid tablename in your DB
2. you have a valid connection
3. username and airframe are valid fieldnames in your table
4. $user and $acft are escaped

Try running the queery with hard-coded values. If that works, it's your variables.
If not, then it may be table names, run the query just username/$user and then just airframe/$acft to see if you get success both times. If you do, then your query should be ok.

I understand that it works in phpmyadmin, so this suggests a problem with the connection. Is it possible that you've got a valid connection, but that you're connected to a different DB?

0

iamthwee indeed im escaping the value. The value is something along the lines of C40 or C32 or B1 the list goes on with different types of aircraft.

So as I typed this and thought of your response I decided to look for blank spaces as in the PHPMYADMIN I was hand typing in the values and not on the website so I went in and physically checked the values in the database and low and behold the values for his user in $acft have blanks on each side, so I removed those blanks found the root caseu where it was getting inputted and works fine.

So thank you for all of your respones.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.