Board index   FAQ   Search  
Register  Login
Board index php forum :: Database MySQL Installation

test Database Connection

Installation and configuration iussues

Moderators: macek, egami, gesf

test Database Connection

Postby kiwi » Sat Mar 20, 2004 10:42 am

i already set the server and install MySQL. How do i know whether the connection is right or not? what command to use to check everything is right or not? thanks
kiwi
New php-forum User
New php-forum User
 
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Postby swirlee » Sat Mar 20, 2004 1:39 pm

If you're just trying to see if it's working, just use any old MySQL client to log in and do a simple query.

If you're trying to see if PHP can access it, write a simple script to run a simple query (see the documentation).

Code: Select all
SELECT 1 + 1 AS sum;
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

test

Postby kiwi » Sun Mar 21, 2004 2:49 am

i'm using dreamweaver mx 2004 as the editor, i already install the mysql software, so what i need to do, where should i put the code? can u show me one by one, please? thanks for ur help :-D
kiwi
New php-forum User
New php-forum User
 
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Postby gesf » Sun Mar 21, 2004 5:45 am

Well i think swirlee answered your question!!
Just run that query using your mysql client!

Anyway...i think you wanna test it with php, right!?
I´ll assume that, so first use this next code to connect to your mysql database:[php]<?php
$localhost ="localhost";
$dbuser="your_db_name";
$dbpass= "your_db_pass";
$dbname = "your_db_name";

mysql_connect($localhost, $dbuser, $dbpass) or die
(mysql_error());
@mysql_select_db ("$dbname") or die(mysql_error());
?>[/php]And to run that query, use:
Example:[php]<?php
$result = mysql_query("SELECT 1 + 1 AS sum");
$row = mysql_fetch_assoc($result);
echo $row[sum];
?>[/php]Check this for more information: MySQL Functions
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby kiwi » Mon Mar 22, 2004 7:22 am

i already try the command u gave me above but the following message show in the browser

Warning: mysql_connect(): Access denied for user: 'your_db_name@localhost' (Using password: YES) in c:\inetpub\wwwroot\Untitled-1.php on line 15
Access denied for user: 'your_db_name@localhost' (Using password: YES)

how do i correct it? thanks
kiwi
New php-forum User
New php-forum User
 
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Postby swirlee » Mon Mar 22, 2004 11:08 am

You fill in the name of your database and username and password for $dbname and $dbuser and $dbpass.
User avatar
swirlee
Moderator
Moderator
 
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back

Postby kiwi » Tue Mar 23, 2004 7:53 am

i already install WAMP and MySQL software in my computer, are there crash? where should it find out those database name , use and etc? from where ? can u show please|?
kiwi
New php-forum User
New php-forum User
 
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Postby gesf » Tue Mar 23, 2004 9:08 am

kiwi wrote:Warning: mysql_connect(): Access denied for user: 'your_db_name@localhost' (Using password: YES) in c:\inetpub\wwwroot\Untitled-1.php on line 15
Access denied for user: 'your_db_name@localhost' (Using password: YES)
Like swirlee said, it seems you didn´t filled in the database name, username and password for $dbname and $dbuser and $dbpass![php]<?
$dbuser="your database username here";
$dbpass= "your database password here";
$dbname = "your database name here";
?>[/php]Just look at the error!!
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby kiwi » Tue Mar 23, 2004 9:29 pm

really sorry to ask so much, i'm know nothing in PHP and MySQL, actually from where i should get the password, database name, and the user name? please, thanks a lot :eek:
kiwi
New php-forum User
New php-forum User
 
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Postby gesf » Wed Mar 24, 2004 4:35 am

MySQL is in your machine!?
Hunnn... to say the truth... i really don´t know!
I think it must be something like:[php]$localhost ="localhost";
$dbuser="root";
$dbpass= ""; // There´s no password
$dbname = "your_db_name"; // Your DB name here[/php]I´m not sure about this, but you can try it anyway!
Don´t worry... a better solution will fall soon...!
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby kiwi » Wed Mar 24, 2004 7:29 am

i already mention above, i already install WAMP5 and i found out i'm using WinMySQLAdmin 1.4. If i want to edit or create some php file and to test those databse connection, where should i save the file and how to test the connection, should i need to configure the server in control panel? :)
kiwi
New php-forum User
New php-forum User
 
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Postby someonelost » Wed Apr 06, 2005 8:13 am

kiwi wrote:i already mention above, i already install WAMP5 and i found out i'm using WinMySQLAdmin 1.4. If i want to edit or create some php file and to test those databse connection, where should i save the file and how to test the connection, should i need to configure the server in control panel? :)


You should put all your php files you want to test in the 'htdocs folder' and then type http://localhost/FILENAME.php in your brwosers address bar. Make sure the server is running first.
someonelost
New php-forum User
New php-forum User
 
Posts: 2
Joined: Wed Apr 06, 2005 5:28 am
Location: UK


Return to MySQL Installation

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.