MySQL Forums
Forum List  »  PHP

Re: DB Connection error! Please help me
Posted by: Jonathan Stephens
Date: May 08, 2005 03:22AM

Assuming that you've got MySQL running on your PC, the correct hostname is "localhost":

<?php
$host = 'localhost';
$user = 'my_username';
$pass = 'my_password';
$db = 'students';

$link = mysql_connect($host, $user, $pass)
or die("Couldn't connect to MySQL server on $host: " . mysql_error());

mysql_select_db($db, $link)
or die("Couldn't access database $db on MySQL server $host: ".mysql_error());

// etc.
?>

BTW, I really hope that you didn't just post your username and password here.

Jon Stephens
MySQL Documentation Team @ Oracle

MySQL Dev Zone
MySQL Server Documentation
Oracle



Edited 1 time(s). Last edit at 05/08/2005 03:23AM by Jon Stephens.

Options: ReplyQuote


Subject
Written By
Posted
Re: DB Connection error! Please help me
May 08, 2005 03:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.