Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,207,201 members, 7,998,180 topics. Date: Saturday, 09 November 2024 at 09:14 AM

Mysql: I Find This Silly...pls Help Me Out - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Mysql: I Find This Silly...pls Help Me Out (1349 Views)

PHP And Mysql: Absolute Beginner. / Free Online Training For Html/css, Javascript, Jquery, Mysql, Php, Java, Android / Lets Start A Real Web-deveopment Course Here Html+css+javascript+php+mysql (2) (3) (4)

(1) (Reply) (Go Down)

Mysql: I Find This Silly...pls Help Me Out by logicalhumour: 11:38pm On Aug 29, 2016
I want to log my user in on my site... the username and password are in a table of my site's database

Now I'll have to login with root (for instance ) because it has enough permission to carry out the operation. ie
mysqli_connect ('host', 'username', 'password')
to check this table and retrieve data …but that would appear in my source code. Help me out please. Thanks
Re: Mysql: I Find This Silly...pls Help Me Out by losprince(m): 11:50pm On Aug 29, 2016
you still need to choose the database you wish to connect to

try mysqli_select_db(“database_name“);
Re: Mysql: I Find This Silly...pls Help Me Out by tr3y(m): 1:54am On Aug 30, 2016
Your question is not clear.
Re: Mysql: I Find This Silly...pls Help Me Out by yunglary(m): 1:55am On Aug 30, 2016
losprince:
you still need to choose the database you wish to connect to

try mysqli_select_db(“database_name“);

you can also add the database name to it, that's what i use every time.
mysqli_connect ('host', 'username', 'password','database_name');
Re: Mysql: I Find This Silly...pls Help Me Out by heywhy824(m): 8:14am On Aug 30, 2016
You can use the oop style,
e.g. $db = new mysqli('host', 'user', 'pass', 'db');
$result = db->query('select * from rubbish"wink;
$rows = $result->num_rows;
$data = $result->fetch_assoc();

You can try it out, and also search more about the oop mysqli
Re: Mysql: I Find This Silly...pls Help Me Out by logicalhumour: 8:27am On Aug 30, 2016
losprince:
you still need to choose the database you wish to connect to

try mysqli_select_db(“database_name“);
No... my point is not how to connect
Re: Mysql: I Find This Silly...pls Help Me Out by logicalhumour: 8:29am On Aug 30, 2016
tr3y:
Your question is not clear.
What iam trying to say is... can't someone get my connection password by viewing sourcecode?
Re: Mysql: I Find This Silly...pls Help Me Out by tr3y(m): 10:29am On Aug 30, 2016
logicalhumour:
What iam trying to say is... can't someone get my connection password by viewing sourcecode?
Nope under normal condition, it's not possible. Your code is evaluated at the backend.
Maybe if they find a way to stop PHP engine from parsing your source code.
Re: Mysql: I Find This Silly...pls Help Me Out by foldl: 11:03am On Aug 30, 2016
logicalhumour:
I want to log my user in on my site... the username and password are in a table of my site's database

Now I'll have to login with root (for instance ) because it has enough permission to carry out the operation. ie
mysqli_connect ('host', 'username', 'password')
to check this table and retrieve data …but that would appear in my source code. Help me out please. Thanks

1. Store your connection parameters as environment variables and read them in with the getenv function.
2. Store your connection parameters in a php file outside your server's webroot (not in www or any sub folder inside www), i.e. the file containing the parameters should not be accessible to anyone visiting your site in the browser. Require this file in the source file where you need to use the parameters.
Re: Mysql: I Find This Silly...pls Help Me Out by logicalhumour: 8:26pm On Aug 30, 2016
but if I do this, am I not ...like allowing port 80 to access my computer?. If its hosted, wouldn't port 80 have to communicate with something outside the server which is my physical computer?
Re: Mysql: I Find This Silly...pls Help Me Out by logicalhumour: 9:04pm On Aug 30, 2016
foldl:


1. Store your connection parameters as environment variables and read them in with the getenv function.
2. Store your connection parameters in a php file outside your server's webroot (not in www or any sub folder inside www), i.e. the file containing the parameters should not be accessible to anyone visiting your site in the browser. Require this file in the source file where you need to use the parameters.
but if I do this, am I not ...like allowing port 80 to access my computer?. If its hosted, wouldn't port 80 have to communicate with something outside the server which is my physical computer?
Re: Mysql: I Find This Silly...pls Help Me Out by logicalhumour: 9:22pm On Aug 30, 2016
Thanks everyone. I'm no longer bordered. @tr3y - this link php.about.com/od/troubleshooting/qt/view_source.htm.added to What u said
Re: Mysql: I Find This Silly...pls Help Me Out by foldl: 9:25pm On Aug 31, 2016
logicalhumour:
but if I do this, am I not ...like allowing port 80 to access my computer?. If its hosted, wouldn't port 80 have to communicate with something outside the server which is my physical computer?


Depending on your server configuration (Apache, NginX, lighttpd, iis) only files in your webroot or the document root specified in you virtual host configuration are served on port 80 (or any port that your web server has been configured to use). If your site's config file is located outside those locations it can still be accessed (ie required or included) by your php scripts.

(1) (Reply)

Please How Do I Convert My Power Bi Visual Dashboards To Images For Power Point / Assistance Needed With Oracle 10g Xe / Front-end And Back-end Web Developer

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.