leranjun Posted June 4, 2019 Share Posted June 4, 2019 Hi,I have been trying to connect to my MySQL database added through cPanel with PHP.It turned out that the connection was successful, but it cannot execute any commands.I tried to execute the command in my local IDE (I am using PhpStorm), and it succeeded. I used the same configuration with mysqli, but it doesn't work. In connect.php: <?php $dbServername = "ricky.heliohost.org:3306"; $dbUsername = "username"; $dbPassword = "password"; $dbName = "test"; $conn = new mysqli($dbServername, $dbUsername, $dbPassword, $dbName); if ($conn->connect_error) { die("Connection Error: " . $conn->connect_error); } echo "Connection successful"; $stmt = $conn->prepare("SELECT * FROM test"); $stmt->execute(); The output is just "Connection successful"; it does not execute the SELECT statement.Can anyone please help me?Thank you very much! Link to comment Share on other sites More sharing options...
Krydos Posted June 4, 2019 Share Posted June 4, 2019 Did you give $dbUsername select access on the database $dbName? Link to comment Share on other sites More sharing options...
leranjun Posted June 4, 2019 Author Share Posted June 4, 2019 Did you give $dbUsername select access on the database $dbName? Yes, the user has access to all the commands.Thank you! Link to comment Share on other sites More sharing options...
Krydos Posted June 4, 2019 Share Posted June 4, 2019 Are you saying "Thank you!" that solved the issue or "Thank you!" for trying to help, but it's still not working? Link to comment Share on other sites More sharing options...
Sn1F3rt Posted June 4, 2019 Share Posted June 4, 2019 Link to comment Share on other sites More sharing options...
Sn1F3rt Posted June 4, 2019 Share Posted June 4, 2019 Krydos I had sent u a PM. Kindly check. Link to comment Share on other sites More sharing options...
leranjun Posted June 4, 2019 Author Share Posted June 4, 2019 Are you saying "Thank you!" that solved the issue or "Thank you!" for trying to help, but it's still not working?Aha, sorry for the confusion. I'm just saying thank you for politeness Anyway, I don't think that is the problem. Is there any chance that there are other parts that might have gone wrong? Link to comment Share on other sites More sharing options...
Krydos Posted June 4, 2019 Share Posted June 4, 2019 Since your code sample has all of the useful information edited out I looked around on your account. I don't even see a select statement in the beta directory. Are you selecting from the table test like you posted or tea which actually exists? Link to comment Share on other sites More sharing options...
leranjun Posted June 5, 2019 Author Share Posted June 5, 2019 Since your code sample has all of the useful information edited out I looked around on your account. I don't even see a select statement in the beta directory. Are you selecting from the table test like you posted or tea which actually exists?Well I'm just using test for security purposes. The actual database is tea. Link to comment Share on other sites More sharing options...
leranjun Posted June 8, 2019 Author Share Posted June 8, 2019 I have the least idea why, but it seems to be working now.Thanks for the help anyway! Link to comment Share on other sites More sharing options...
Krydos Posted June 9, 2019 Share Posted June 9, 2019 I'm glad it's working for you now. Link to comment Share on other sites More sharing options...
Recommended Posts