-2

It says that one of these lines are wrong but I used mysqli not mysqli. Can someone help?

<?php
$servername = "localhost";
$usernam = "id13913676_admin";
$password = "Benya12152003!";
$dbname = "id13913676_langswap";
$conn = mysqli_connect($servername, $usernam, $password, $dbname);
$query = "SELECT * FROM register";
$result = mysqli_query($query);

?>
  • If you're just getting started with PHP and want to build applications, I'd strongly recommend looking at various [development frameworks](https://www.cloudways.com/blog/best-php-frameworks/) to see if you can find one that fits your style and needs. They come in various flavors from lightweight like [Fat-Free Framework](https://fatfreeframework.com/) to far more comprehensive like [Laravel](http://laravel.com/). These give you concrete examples to work from and guidance on how to write your code and organize your project's files. – tadman Jun 11 '20 at 20:09
  • 2
    mysqli_query($conn, $query) do this way – Avinash Dalvi Jun 11 '20 at 20:09
  • 1
    You're going to need to read the [`mysqli` documentation](https://www.php.net/manual/en/book.mysqli.php) and pay careful attention to the arguments used. That being said, PDO is much better if you're just getting started, and if you'd rather approach this using modern tools, find an ORM you like and use that instead. – tadman Jun 11 '20 at 20:10
  • 4
    I strongly disagree with you @tadman, if someone is just getting started with PHP, one should do a lot of vanilla PHP before stepping into frameworks. The basics of PHP would be way stronger – Cid Jun 11 '20 at 20:10
  • @Cid The best way to learn PHP is from good examples, and frameworks have the best examples. Learning PHP from core functions is like learning to drive by building a car first. It teaches you a lot about being a mechanic, but nothing about driving safely. PHP has an unusually rich framework ecosystem that should be taken advantage of. You can *always* learn fundamentals as you go. – tadman Jun 11 '20 at 20:11
  • @tadman IMHO, that would be way harder to maintain an application developped with a *"ready to use"* MVC framework if one misses the basics of a language. Good examples are indeed a good way to learn, but mistakes teach a lot more – Cid Jun 11 '20 at 20:15
  • @cid Using a first-class framework like Laravel, which has spectacular documentation, training material, and a huge community for support, will teach you way more about how to do PHP properly than fussing around with the PHP documentation and some awful YouTube videos on how to make a login system. I learned Ruby from Rails, I learned C++ from MFC. I learned (real) JavaScript from Ember. I learned Python from Django. I learned Swift for iOS. Frameworks do not, in any way, impede learning. Only stubbornness does that. – tadman Jun 11 '20 at 20:17
  • @Cid You also don't need to *master* PHP to be *effective* in it. You can get stuff done and learn as you go. A framework will do a lot of heavy lifting for you, and when you're ready to dig deeper and understand more about the language, about SQL, about other fundamentals, you'll be a more effective and capable programmer. You'll also have gotten a lot done where the ground-up *ex nihilo* approach will have you flailing for years to get to the same point you can get to in months with the right resources. – tadman Jun 11 '20 at 20:20

1 Answers1

3

Change it to $result = mysqli_query($conn, $query); add the connection variable

katwekibs
  • 1,342
  • 14
  • 17
  • 2
    Questions that are obvious duplicates should not be answered. They should be closed/flagged as a duplicate only. If you want to point out their mistake, just post a comment. See: [Should one advise on off topic questions?](//meta.stackoverflow.com/q/276572/1768232). Off-topic questions can be closed and deleted, which could nullify your contribution anyway. – John Conde Jun 11 '20 at 20:14