Feenix Posted April 17, 2007 Share Posted April 17, 2007 hi, have a problem with this.... Connection to db is ok (with no mysql errors), but server sent error: "SELECT command denied to user ''@'localhost' for table ...". In another application running under another user on that server I haven't this problem. I have also granted privileges for that user on database. Could help sb?? Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/ Share on other sites More sharing options...
artacus Posted April 17, 2007 Share Posted April 17, 2007 It doesn't look like you've defined a username to connect to mysql. Go back and look at your connection string. Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-231478 Share on other sites More sharing options...
bubblegum.anarchy Posted April 18, 2007 Share Posted April 18, 2007 Check the grant permissions for the username. Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-231787 Share on other sites More sharing options...
Feenix Posted April 18, 2007 Author Share Posted April 18, 2007 It doesn't look like you've defined a username to connect to mysql. Go back and look at your connection string. As I wrote, I can connect to the mysql server with no problems, so conn string is correct (otherwise i couldn't connect to it). Check the grant permissions for the username. username HAS permissions for select, update and delete too, but problem is that serv returns that damned error ( I sent it EXACT - there is no user between those quotation marks before @ !!! ) Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-231952 Share on other sites More sharing options...
bubblegum.anarchy Posted April 18, 2007 Share Posted April 18, 2007 are you sure you are not connecting as an anonymous user that has no permissions? create a basic connection file on the server for testing like this, straight out of the php manual, to verify the connection settings: <?php // Connecting, selecting database $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password') or die('Could not connect: ' . mysql_error()); echo 'Connected successfully'; mysql_select_db('my_database') or die('Could not select database'); // Performing SQL query $query = 'SELECT * FROM my_table'; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); // Printing results in HTML echo "<table>\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t<tr>\n"; foreach ($line as $col_value) { echo "\t\t<td>$col_value</td>\n"; } echo "\t</tr>\n"; } echo "</table>\n"; // Free resultset mysql_free_result($result); // Closing connection mysql_close($link); ?> Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-231962 Share on other sites More sharing options...
Feenix Posted April 18, 2007 Author Share Posted April 18, 2007 yes i am sure, because a made similar test file with non-anonymous user on the server to test connection and it passed. It looks like user somewhere lost in session ??? Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-231985 Share on other sites More sharing options...
bubblegum.anarchy Posted April 18, 2007 Share Posted April 18, 2007 if the test connection was succesful then you can be assured there is an issue with the connection string that is responsible for the connection used by the page producing the error... like artacus initially deduced. Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-232000 Share on other sites More sharing options...
artacus Posted April 18, 2007 Share Posted April 18, 2007 If you were connecting as a valid user your error message would have read: 'myValidUser'@'localhost' Quote Link to comment https://forums.phpfreaks.com/topic/47414-select-command-denied-to-user-localhost-for-table/#findComment-232244 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.