Connect to database with mysqli

Hi, I’m trying to make a working search bar where you can search for products, but I can’t get it to work.
Any ideas on how to do it?

Thanks!

Let me look at your PHP version, code and website.
Send me the link through my social network. I’ll be the “System” guy there, send me it.

ggclouds.66ghz.com

It should be pretty straight forward: write your code and use the right credentials.

If it doesn’t work, it would help a lot if you could explain a bit more about what exactly you’re trying to do and where you get stuck.

Ok,

so I’ve made a normal javascript search bar, which sends you to search.php when you click on the submit button.

SEARCH.PHP

<?php require_once 'connect.php'; if(isset($_GET['keywords'])){ echo $keywords = $_GET['keywords']; } ?>

CONNECT.PHP

<?php $db = new mysqli('oilspec.ml', 'root', 'root', 'sql109.epizy.com'); Now, something should get displayed from the database (don't know what :smile: ). My website URL is **www.oilspec.ml**. Thanks!

For starters, the correct order of parameters for the MySQLi contructor is:

$db = new MySQLi($hostname, $username, $password, $database);

Please make sure you are using the right hostname, username, password and database name. All values except for the password (which is your account password, you can find it in the client area) are listed in the MySQL Databases section in your control panel.

Thanks,
I’m pretty new to mysql :smile: .

But I do still not get any result.
Thanks!

Nothing works inside this if inside search.php:

<?php require_once 'connect.php'; if(isset($_GET['keywords'])){ echo $keywords = $_GET['keywords']; } ?>

Did you check the mysqli_error output to see if there were any connection errors?

@Admin said:
Did you check the mysqli_error output to see if there were any connection errors?

No, where do you see that?

@Freeranger said:

@Admin said:
Did you check the mysqli_error output to see if there were any connection errors?

No, where do you see that?

I haven’t checked, but you should! If there was an issue with the connection or the query, you’ll get a nice error message telling you exactly what went wrong, which is a great start to fixing it.

Thanks,

But I’m not getting anything that I can see (Due to the fact I can’t figure out where the error bat is).

I also checked the over all error log, where I can’t find anything. :cry:

@Freeranger said:
Thanks,

But I’m not getting anything that I can see (Due to the fact I can’t figure out where the error bat is).

By default, no error is logged. You need to use the mysqli_error function to get the error message.

I’ve checked that, and figured out that the problem is here:

if(isset($_GET['keywords'])){ echo $keywords = $_GET['keywords']; }

Can you find anything wrong with this code?
Thanks!

@Freeranger said:
I’ve checked that, and figured out that the problem is here:

if(isset($_GET['keywords'])){ echo $keywords = $_GET['keywords']; }

Can you find anything wrong with this code?
Thanks!

The code is syntactically valid. What is it supposed to do? How are you trying to call this code?

INDEX.PHP

SEARCH.PHP
>! <?php

! require_once ‘connect.php’;
!
! if(isset($_GET[‘keywords’])){
! echo $keywords = $_GET[‘keywords’];
! }else echo “DANG NOT WORKING”;
! ?>

CONNECT.PHP
<?php $hostname = 'sql109.epizy.com'; $username = 'epiz_21490173'; $password = '(hidden)'; $database = 'epiz_21490173_oil'; $db = new MySQLi($hostname, $username, $password, $database);

Sorry for the thing over, here is all of it:

https://goo.gl/RR2ADH

Nice new forum design BTW!

OK, it looks like a lot of posts were lost here due to the database corruption. If I remember correctly, the issue is this form:

 <form action="search.php" method="post">
         <input type="text" id="searchbar" placeholder="" value="Search..." maxlength="25" autocomplete="off" onMouseDown="active();" onBlur="inactive();"/><input type="submit" id="searchbtn" value="GO!"/>   
      </form>

The issue is that method="post" should be method="get" and the search bar should have the attribute name="keywords". The receiving PHP code looks fine.

I do just have to recreate the code, some parts dissappeared… :cry:

I have one more question too:

If I want to upload for example a minecraft mod, the file size is over 200mb, is there any way I can still make the downloadable?

Thanks