Page 1 of 1

mysql_connect() and php admin

PostPosted: 10. July 2009 22:42
by tavoqc
The instruction mysql_connect("localhost","root","z80") is to be used to connect to a database, where do i get the password from or how to set it and what to use to actually use that instruction to make the connection from php to a database.
Can multiple users be assign to a username at the same time? or how do i do for the users in my website to all connect to the database at the same time?

Re: mysql_connect() and php admin

PostPosted: 10. July 2009 23:18
by glitzi85
In a default XAMPP installation the root password for MySQL is empty:
Code: Select all
mysql_connect('localhost', 'root', '');

You normally set up one user for every project with permissions to only one Database, not the complete server. You can administrate the MySQL Server with the phpMyAdmin Webinterface, reachable via http://localhost/phpmyadmin
Then you just use this user in your Script. This has nothing to do with the users on your Website. Every MySQL-User can have multiple connections at the same time.

glitzi

Re: mysql_connect() and php admin

PostPosted: 11. July 2009 01:33
by tavoqc
Thanks so much for your comment, now the error is:
Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\Archivos de programa\xampp\htdocs\registrocliente2.php on line 14

Line 14 is: mysql_select_db('proyecto',$conexion)
but 'proyecto' is the database I'm trying to use, how can i solve that problem?

Re: mysql_connect() and php admin

PostPosted: 12. July 2009 19:20
by glitzi85
Put
Code: Select all
echo mysql_error();

directly after your mysql_connect-Command. The error message means, that your $conexion-Variable does not contain an MySQL-Link. That mostly happens when the connect fails or you mistyped the variable.

glitzi