Background…
Over the last year I’ve learning MySQL and recently trying to learn php.
I’d like to think I have a solid background in html and css but find learning php quite alien and confusing compared to html.
I’ve been reading Learning php, MySQL, JavaScript & CSS by Robin Nixon, which since I’ve found out is out of date on the php side of things, despite being published in 2012. But anyway I’ve put that to one side since I can still learn the basics of php and update to PDO later.
(I’ve skipped Javascript for now as php is confusing enough for me!)
On to my question…
I’ve got to the tutorials and how you have one php page that accesses the database via mysql_connect and then you include that on subsequent pages.
mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
I think it is saying that php needs to connect to the database with a username/password before you can do anything else? That kind of makes sense. However, when that tutorial goes on to creating usernames/passwords for each ‘user’ the user table is created within the database not in the MySQL.user table
That seems crazy to me since you can’t assign table permissions from a ‘user’ table within a database.
What I really want to do is have a login form on the php page which connects the user directly to my database using a username/password from the mysql user table not a ‘user’ table from within the database which is useless as permissions can’t be assigned to tables. (at least I think they can’t)
Ideally any queries sent back to the user will display data only they can see.
Such as “show tables from mydb;” will be unique to each user.
Is this possible in php?