justsomeguy Posted August 7, 2017 Share Posted August 7, 2017 You can use php_value or php_flag to set the various options: http://php.net/manual/en/configuration.changes.php Link to comment Share on other sites More sharing options...
Html Posted August 12, 2017 Author Share Posted August 12, 2017 (edited) 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 3Not connected To ServerWarning: mysqli_select_db() expects parameter 1 to be mysqli, boolean given in post.php on line 11Database Not selectedWarning: mysqli_query() expects parameter 1 to be mysqli, boolean given in post.php on line 20 Edited August 12, 2017 by Html Link to comment Share on other sites More sharing options...
justsomeguy Posted August 14, 2017 Share Posted August 14, 2017 When it says the connection timed out, that usually means it can't reach the database server. Maybe it's a firewall issue, maybe you're just not using the right name. Link to comment Share on other sites More sharing options...
Html Posted August 15, 2017 Author Share Posted August 15, 2017 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 More sharing options...
justsomeguy Posted August 15, 2017 Share Posted August 15, 2017 Are you sure your code isn't the problem? $con = mysqli_connect('mysql service db ip' . 'root', ''); You're concatenating the IP address with the username? Link to comment Share on other sites More sharing options...
Html Posted August 15, 2017 Author Share Posted August 15, 2017 The ip address is added in the actual file. The folder is root, I believe so. As for the Not selected, I don't know about all of this. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 15, 2017 Share Posted August 15, 2017 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 More sharing options...
Html Posted August 16, 2017 Author Share Posted August 16, 2017 (edited) 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 August 16, 2017 by Html Link to comment Share on other sites More sharing options...
justsomeguy Posted August 16, 2017 Share Posted August 16, 2017 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 More sharing options...
Html Posted August 16, 2017 Author Share Posted August 16, 2017 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 More sharing options...
justsomeguy Posted August 16, 2017 Share Posted August 16, 2017 Well, unless you really do want to append "root" to the end of the hostname (which would never work if you're using an IP address for the host) and use a blank username, the code you have is wrong. Link to comment Share on other sites More sharing options...
Html Posted August 16, 2017 Author Share Posted August 16, 2017 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 More sharing options...
justsomeguy Posted August 16, 2017 Share Posted August 16, 2017 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 More sharing options...
dsonesuk Posted August 17, 2017 Share Posted August 17, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now