0

I wanted to transfer my website, which I have been dealing with on localhost for 5 days, to a real hosting yesterday.

The site works fine on my localhost, but when I transfer it to my host it gives the error.

Call to undefined method mysqli_result::fetch_column()

I'm aware that the problem is fetch_column() on line 62 but I couldn't find the solution.

$users = $_POST["usernameInput"];
$control = $baglanti->query("SELECT * FROM users WHERE username = '$users' ");
$sonuc = $control->fetch_column();
if($sonuc==0) {
    $username = $_POST["usernameInput"];
} else {
    $username_err = "This username has been used before!";
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Ferb
  • 13
  • 1
  • it might be that you need to enable mysqli on your hosting provider. talk to them if you don't have access to the server or google how to install php-mysql for your server's environment. the most common environment is linux and the command should be `sudo apt install php-mysql` `NOTICE: I CAN SEE A SQL INJECTION VULNERABILITY IN THE CODE YOU PROVIDED`. you are directly doing a query using a user-supplied parameter `$_POST['usernameInput']`. please read: https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php – Michael Yousrie Dec 12 '22 at 17:06
  • **Warning:** You are wide open to [SQL Injections](https://php.net/manual/en/security.database.sql-injection.php) and should use parameterized **prepared statements** instead of manually building your queries. They are provided by [PDO](https://php.net/manual/pdo.prepared-statements.php) or by [MySQLi](https://php.net/manual/mysqli.quickstart.prepared-statements.php). Never trust any kind of input! Even when your queries are executed only by trusted users, [you are still in risk of corrupting your data](http://bobby-tables.com/). [Escaping is not enough!](https://stackoverflow.com/q/32391315) – Dharman Dec 12 '22 at 17:10
  • Please update the code in question to remove SQL injection. – Dharman Dec 12 '22 at 17:15

1 Answers1

2

This method is only available as of PHP 8.1. You must be using an outdated PHP version. Please check and upgrade.

Dharman
  • 30,962
  • 25
  • 85
  • 135