Jump to content

How do I create a database in phpmyadmin + Php form problem


Html

Recommended Posts

This is what loads after I turned on a setting in php config in the cpanel.

Warning: mysqli_connect(): (HY000/2002): Connection timed out in post.php on line 3
Not connected To Server
Warning: mysqli_select_db() expects parameter 1 to be mysqli, boolean given in post.php on line 11
Database Not selected
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in post.php on line 20

Edited by Html
Link to comment
Share on other sites

According to the free web host, there are no restrictions on the php7. I have also tried getting a Php Twitter API to work, but I get the error of an uncaught error, stack flow. Of course, there is no db or anything, so it should work, the index page is the only edited file, add connections to a consumer key and token key, and all that.

I don't know what is happening here. I may have to try another free web host that offers php/mysql.

Link to comment
Share on other sites

The 3 parameters to mysqli_connect are the host, username, and password.  You have a dot between the host and username instead of a comma, so you are concatenating those into 1 string and passing that as the host.  So you're passing "127.0.0.1root" as the host name.  That's wrong.  Then you're passing an empty username and no password, because you're only passing 2 values instead of 3.  You can also pass the database name as the 4th parameter instead of using mysqli_select_db.  The reason why PHP doesn't complain about that error is because all of the parameters to mysqli_connect are optional, so it doesn't care that you're only passing 2.  It looks up the default values in the PHP configuration if they aren't passed.

Link to comment
Share on other sites

Everything I did a few months ago when I began this was from a video. So I don't know, I just typed out what the narrator in the clip was saying and tried it, and obviously it didn't work, since I turned up here and got the advice you have given and corrections to the file.

 

Edited by Html
Link to comment
Share on other sites

You can look up any built-in PHP function or class in the manual:

http://php.net/manual/en/mysqli.construct.php

If you don't know the difference between what a period and comma do, then you should start with the basics of the language before trying to write code like this.  A tutorial that is just telling you what to type probably isn't teaching anything.

Link to comment
Share on other sites

From what I can remember that was what the vid narrator displayed, so as for trying an API, an error which doesn't require any actual code or mysql, that doesn't work either.

I actually did mentioned it on your profile, so profile doesn't accept messages. Something about stack over flow.

Link to comment
Share on other sites

I appreciate you now stating that.-_-

Flipping tutorials clips, may be the narrator was just out to generate some revenue. I once bought a python book last year, all I got was printouts, it was complete utter rubbish. So the example doesn't work at all?

Link to comment
Share on other sites

I'm saying that this line:

$con = mysqli_connect('mysql service db ip' . 'root', '');

Is telling it to connect to "mysql service db iproot" and send a blank username, and to use the default password as configured in php.ini.  If you replace it with an IP address, like 127.0.0.1, then you're telling it to connect to "127.0.0.1root".  Adding "root" to the end of it breaks the IP address.  Because you have a period there instead of a comma, and a period is a string concatenation operator.  You aren't passing 3 values to mysqli_connect, you're passing 2.  I'm not sure how else I can say that any clearer.  If you don't know what string concatenation is then you need to start with the PHP basics, it's one of the basic operators.  

Link to comment
Share on other sites

By default the mysql db host has always been IP

127.0.0.1 ( also ::1)

OR

'localhost' (which is user friendly way of pointing to 127.0.0.1)

The user mysql 'root' is the default username, which gives all privileges used for mysql db.

The mysql 'password' is what you should have setup.

The mysql 'database' is the database name you wish to connect to, which you should have created.

There is also an optional mysql 'port' and mysql 'socket' which would used if an alternative to default is used.

Its obvious the tutorial mistakenly placed a '.' Instead of ',' between mysql host and user parameters, whatever happened its wrong!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...