FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


SQL problem, not returning any result





Gregoric
Why does such query doesn't return anything?
Code:
SELECT `steamavatar` FROM `gregoric_sghoj`.`peopledb` WHERE `steamid`=76561198025687424


When in my database, I have such row.


I have chosen right database and table, that is sure as works in other queries.
Bondings
Why do you include the database name? Usually only the tablename (I guess peopledb) is needed?
Code:
`gregoric_sghoj`.

I would try it with:
Code:
SELECT `steamavatar` FROM `peopledb` WHERE `steamid`=76561198025687424


Also, try to run it in phpMyAdmin, maybe you get more feedback. And start with a basic query and see when it goes wrong.
Gregoric
I do not use mysql_select_db so I add the database name into the query. It doesn't cause any problems for other queries so that's not the reason. I've tried executing the query using PHP or through phpMyAdmin - it didn't produce any errors just empty result.

Ah, I forgot to check if it produces any errors with PHP. I wouldn't think that it would as it doesn't with phpMyAdmin (above).

I have no idea what is wrong... If it would change anything, steamavatar is varchar while steamid is bigint (yeah, that's the one which I've asked in one of previous topics Smile).

I won't have time to test any suggestions until monday; I will only visit forums using my phone.
sonam
What is steamavatar? Is this image name (I don't see image extension), or what? If you haven't error in php code and this is binary code of avatar then maybe you need to define longblob instead of varchar.

Sonam
Gregoric
Steamavatar is middle part of a link to the image. Rest of the URL is always the same for every avatar so I am storing only this part in database and rest is generated with PHP.
Bondings
I copy-pasted the query you posted in phpMyAdmin and it returns the correct result. I also tried it with a simpler query without the table name and that returned the whole row.
Gregoric
Hmm, it works as manually SQLing from phpMyAdmin

Look at this code. Returns Resource id #5
Code:
            echo $steamid;
            global $db_server, $db_user, $db_pass;
            $dbload = mysql_connect( $db_server, $db_user, $db_pass ); //Conenction is surely okay
            mysql_select_db("gregoric_sghoj", $dbload);
            echo "Hello again, ".$_SESSION['username']."!"; //Doesn't matter
            echo " <a href='./php/logout.php'>Log out</a>"; //Same
           
            $avatarurl = mysql_query("SELECT `steamavatar` FROM `peopledb` WHERE `steamid`='$steamid'", $dbload);
            echo $avatarurl;


Echoing Steamid goes okay. Correct number is being displayed. But query doesn't work... What's the cause? I have no idea ;(
sonam
Hmm, maybe you can try to remove $dbload from query. I never use db connect in query. Or maybe move double quotes after $dbload. Confused

Code:
$avatarurl = mysql_query("SELECT `steamavatar` FROM `peopledb` WHERE `steamid`='$steamid'", $dbload);


Sonam
Gregoric
Never mind. I just forgot to fetch_row the result Smile. I've been too tired that day and my brain didn't work properly, it seems. Well, thanks, problem's gone.

close_thread_please();
Bondings
Gregoric wrote:
Never mind. I just forgot to fetch_row the result Smile. I've been too tired that day and my brain didn't work properly, it seems. Well, thanks, problem's gone.

close_thread_please();

I was going to post that you forgot to do that (before reading your last post), but you already found it yourself. Very Happy

-close-
Related topics
An Example to mySQL class
.sql problem
how did you learn about html, php or other languages???
Microsoft ACCESS 2003
SQL problem!!!
sql problem
SQL problem for solving :)
Help with PHP + SQL problem.
Frihost blog post bug
SQL Problem Help
MySQL - Session error?
Creating safe persistent login system
php execute sql problem
Server 4 Down
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.