- 1

CONNECT TO SQL SERVER USING PHP??!?!!!

I installed xampp and hosted a php and sql server which were both running fine. I looked up how to connect to sql using php and it said put in the password and username? I never put a username and or password in and I don’t know the Hostname or anything. How would I connect to it? Plz keep in mind if using sublime text 3 as the editor and xampp as the php and sql server. What would the code be??

12th Apr 2018, 7:24 PM
Someone Else
Someone Else - avatar
5 Antworten
+ 1
I haven't used xampp, however this article suggests the MySQL root password is set to empty by default. I'd use PDO: https://stackoverflow.com/questions/45424337/php-with-pdo-using-xampp-and-workbench?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
12th Apr 2018, 7:35 PM
Emma
+ 1
It's best to create different users in MySQL, with low to high privileges. Always use the lowest privilege account during any data processing. e.g. if you're doing a search (based on a web visitor search), only use a MySQL user with the ability to only do a select on the specific tables you need! That means mistakes or hacks can be avoided and / or reduced. If a hacker accesses your database, via an SQL injection, then they won't be able to delete, insert or overwrite anything. They also won't be able to read tables you don't want them too!
12th Apr 2018, 7:39 PM
Emma
+ 1
It really sucks when I answer. Then someone repeats exactly what I said and they get an upvote and I don't. Sometimes SoloLearn is crap like that. Crappy behaviour of other users.
12th Apr 2018, 7:53 PM
Emma
+ 1
Toni Isotalo You seem to have a history of copying people's answers! Downvoting you Toni for that reason.
12th Apr 2018, 7:54 PM
Emma