Jump to content

connect with password won't work


C32
 Share

Recommended Posts

hi scripters,I'm currently learning PHP and I'm having a problem with changing the default for connecting with my_sql for a custom username and password

<?php$con = mysql_connect("localhost","root","");if (!$con)  {  die('Could not connect: ' . mysql_error());}else{  echo "connection!";}// some code?>

this is the default which works, but when I change "root" with my own username and set a new password it won't work anymore.I am supposed to change some settings in the php.ini file or somethingI am using Easy PHP and I can't find that file, but I found "config.inc" file where I can change the username and password, like i said before it didnt work.anyone here know what my problem is?

Link to comment
Share on other sites

I've never used EasyPHP, but if you have the MySQL server running, you will need to make sure there is a user and password set up in there. PHP will authenticate with the MySQL server, but it could be doing something else with EasyPHP. Is the error that the username and password are not valid?

Link to comment
Share on other sites

I've never used EasyPHP, but if you have the MySQL server running, you will need to make sure there is a user and password set up in there.  PHP will authenticate with the MySQL server, but it could be doing something else with EasyPHP.  Is the error that the username and password are not valid?

when I use the default settings username="root"; password=""; it works. when i changed the config.inc.php file it doesnt seem to have effect.. so probably it's the wrong file :S? because with the config.inc.php file changed, and i am still using username=root etc. it works like nothing is changed at all..but when i change my login, i get error which is saying that i have no acces
Link to comment
Share on other sites

Like I said, I'm not sure about EasyPHP, but MySQL doesn't keep its user accounts in a configuration file, they are managed by the server software itself. If you have the MySQL control panel running, or, better yet, phpMyAdmin, use that to create a new account in MySQL with the username and password you want.

Link to comment
Share on other sites

how do u flush? I am only trying to connect, I have done nothing with sql yet.. I tried the restart of the server though.. nothinglike i said before.. somehow the change in the config.inc.php file have no effect on anything! i dont know why that is..

Link to comment
Share on other sites

how do u flush? I am only trying to connect, I have done nothing with sql yet.. I tried the restart of the server though.. nothinglike i said before.. somehow the change in the config.inc.php file have no effect on anything! i dont know why that is..

Oops sorry your not near that stage yet :) I thought you had already created a mysql account.
mysql_connect("localhost","root","");

To connect with another account you have to make it firstI don't know how though, never used easyphp, is there no documentation you can follow?

Link to comment
Share on other sites

I'll try to figure that out, making an account..but what do you recommend to use as PHP software/tools? What shall I use? I think easyphp is not that good, because it's different and the support of it is minimal..what do you use? what are popular software/tools/editors?

Link to comment
Share on other sites

but what do you recommend to use as PHP software/tools? What shall I use? I think easyphp is not that good, because it's different and the support of it is minimal..
I have read that XAMPP is good, i haven't used it though so can't comment.http://www.apachefriends.org/en/xampp.html
what do you use?
I downloaded php, apache and mysql seperately and linked them together. It's a tricky process, realy frustrating but great once you get it working. :) This way means you have to communicate with mysql through the command line (DOS).
Link to comment
Share on other sites

thx for the tip! can u also explain what the benefits are for installing those things seperatly instead of using XAMPP?

Link to comment
Share on other sites

thx for the tip! can u also explain what the benefits are for installing those things seperatly instead of using XAMPP?
I can't realy explain the benefits cause i've never used XAMPP. I followed the directions in a book i bought and it recommended installing these seperately. I'll check it out later and see why :)
Link to comment
Share on other sites

One benefit would be that your test setup would match a web server. Web servers don't use things like EasyPHP or XAMPP, the server admin downloads, installs, and configures PHP manually, or with a Linux package installation tool. Also, since we shouldn't have to deal with command lines anymore, you can use phpMyAdmin to administer your MySQL server through a browser, makes it much easier..

Link to comment
Share on other sites

One benefit would be that your test setup would match a web server.  Web servers don't use things like EasyPHP or XAMPP, the server admin downloads, installs, and configures PHP manually, or with a Linux package installation tool.  Also, since we shouldn't have to deal with command lines anymore, you can use phpMyAdmin to administer your MySQL server through a browser, makes it much easier..

I think I understand a little what you are saying.. You can test your pages like it's already online? And you can use MySQL via a browser? but I am using XAMPP now and I am accessing phpMyAdmin via a browser.. so is that the same?maybe I don't need to know all of this (yet) and see into it later :) 1 more question though: where can I find that php.ini file in XAMPP? it says it's in the directory: xampp\apache\bin but I don't see it? and is it a normal php file so I can change some settings? boy I got alot to learn :)
Link to comment
Share on other sites

For all intents and purposes you can basically use XAMPP like you would a manual setup, if all you want to do is test things out you're not going to gain much by going through the headaches of the manual setup. The version of phpMyAdmin that is included with XAMPP is most likely the same version you would use online. I just finished installing version 2.8.1 of phpMyAdmin, it seems to be the current version.php.ini is not a PHP script. It contains plenty of configuration options that look remarkably similar to this:

;;;;;;;;;;;;;;;;;;;;; Language Options ;;;;;;;;;;;;;;;;;;;;;; Enable the PHP scripting language engine under Apache.engine = On; Enable compatibility mode with Zend Engine 1 (PHP 4.x)zend.ze1_compatibility_mode = Off; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.; NOTE: Using short tags should be avoided when developing applications or; libraries that are meant for redistribution, or deployment on PHP; servers which are not under your control, because short tags may not; be supported on the target server. For portable, redistributable code,; be sure not to use short tags.short_open_tag = Off; Allow ASP-style <% %> tags.asp_tags = Off; The number of significant digits displayed in floating point numbers.precision    =  14; Enforce year 2000 compliance (will cause problems with non-compliant browsers)y2k_compliance = On; Output buffering allows you to send header lines (including cookies) even; after you send body content, at the price of slowing PHP's output layer a; bit.  You can enable output buffering during runtime by calling the output; buffering functions.  You can also enable output buffering for all files by; setting this directive to On.  If you wish to limit the size of the buffer; to a certain size - you can use a maximum number of bytes instead of 'On', as; a value for this directive (e.g., output_buffering=4096).output_buffering = 4096
The php.ini file we are using here is just under 50kb. Check in your windows folder for it also.
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
 Share

×
×
  • Create New...