0

many time i try to connect PHP forms with MySQL Database but every time i got one message connection is not available.

so my question is that if some one have a knowledge of good tutorial websites then please tell me as i can learn from their

2
  • 1
    While it wasnt me whos marked you down. You show no code.. its hard to help you when we have nothing to work from. Show some code, if necessary make a test bit of code (mask out username + password credentials) Commented Jul 4, 2011 at 9:35
  • I didn't down vote either but the answer is simple, SO is meant for solving actual programming problems while you encounter them. Commented Jul 4, 2011 at 9:36

3 Answers 3

2

You have to do something like this:

$user="username";
$password="password";
$con=mysql_connect('10.10.10.10',$user,$password);
$db_selected = mysql_select_db("database_name", $con) or die("DB connecting problem");

Sign up to request clarification or add additional context in comments.

Comments

1
<?php
$user="uname";
$pwd="pwd";

$con = mysql_connect("localhost",$user,$pwd);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
 {
 echo "Database created";
 }
else
 {
  echo "Error creating database: " . mysql_error();
 }


 $selectdb = mysql_select_db("my_db", $con);
  if (!$selectdb)
  {
     die('Database Not selected.');
  }

 mysql_close($con);
?>

Comments

0

Katty, you could head to the official PHP function reference page for MySQL which is:

http://php.net/manual/en/ref.mysql.php

initially focus on mysql_connect(). There's also some community submitted content, which could come handy for testing.

Also if you could provide the code u are using and error thrown, that would help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.