Results 1 to 2 of 2

Thread: Check mysql database connection

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved Check mysql database connection

    I'm running an installation script but before I create any tables I check to make sure the user can connect to their MySQL database. Below is the code I'm using which displays my error message if the user can not connect to their MySQL database but it also shows the "php" error mesage.

    "Warning: mysql_connect(): Access denied for user: 'root2@localhost' (Using password: YES) in C:\Apache Group\Apache2\htdocs\poll\installation.php on line 81
    "

    How can I get rid of the "php" error message so only mine is displayed?

    PHP Code:
    $db=mysql_connect($_POST['host'], $_POST['username'], $_POST['password']) // connecting to the database
    or 
    die(
    "Couldn't connect to MySQL"); 
    If I had @ in front of my mysql_connect it works!!
    Last edited by lintz; Jan 15th, 2005 at 02:32 AM.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Check mysql database connection

    Put an AT (@) symbol before the function call.

    Code:
    @mysql_pconnect(user,pass,host) or die("Could not establish a connection!");
    whoops, I didn't notice you solved your own problem..
    Like Archer? Check out some Sterling Archer quotes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width