Jump to content

MySQL Connection

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Hey Guy's

Another questions about my installer, I just can't get this bit working.

I have an input section so user's can add there MySQL details and it creates a config.php file for connecting ect, but when I use variables for the database name and database username it throws out a connection error, but when I don't it connects fine

here's the code im using when it connects


$host = $_POST['host'];

$user = $_POST['user'];

$name = $_POST['name'];

$password = $_POST['password'];


		//Host | Database User | Database Password

		mysql_connect($host, "game", $password) or die(mysql_error());

		

		//Database Name

		mysql_select_db("game") or die(mysql_error());


and when it doesnt


$host = $_POST['host'];

$user = $_POST['user'];

$name = $_POST['name'];

$password = $_POST['password'];


		//Host | Database User | Database Password

		mysql_connect($host, $user, $password) or die(mysql_error());

		

		//Database Name

		mysql_select_db($name) or die(mysql_error());



#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
What error does it throw? :closedeyes:

#3
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Oop's, my bad!

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'game'@'10.**.0.**' (using password: YES) in /install/mysql.php on line 31


Access denied for user 'game'@'10.**.0.**' (using password: YES)


#4
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
works fine for me... but try:

EDIT: nvm, thought you were having trouble on the mysql_select_db part.

#5
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Weird, I'll get someone to try it on there own host.

But WebCodez, would you be interested in helping me develop the piece of software I am currently working on, if so PM me :)

#6
webcodez

webcodez

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Sure, always in for new projects of web applications :)

Pmed.

#7
banker

banker

    Newbie

  • Members
  • PipPip
  • 24 posts
Just curious, but isn't this a harder way to connect to your database vs. using a simple include() statement?

Define the connection details in the include() file. Since its php, the data is not visible, even if accessed directly.
You will also remove the headache of having to sanitize inputs that came from your form.