Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

MySQL Connection

mysql connection mysql_connect

  • Please log in to reply
6 replies to this topic

#1 Bioshox

Bioshox

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 210 posts

Posted 14 April 2010 - 09:23 AM

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());

  • 0

#2 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 14 April 2010 - 09:38 AM

What error does it throw? :closedeyes:
  • 0

#3 Bioshox

Bioshox

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 210 posts

Posted 14 April 2010 - 09:54 AM

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)

  • 0

#4 webcodez

webcodez

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 143 posts

Posted 14 April 2010 - 11:28 PM

works fine for me... but try:

EDIT: nvm, thought you were having trouble on the mysql_select_db part.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#5 Bioshox

Bioshox

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 210 posts

Posted 15 April 2010 - 12:03 AM

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 :)
  • 0

#6 webcodez

webcodez

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 143 posts

Posted 15 April 2010 - 12:05 AM

Sure, always in for new projects of web applications :)

Pmed.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#7 banker

banker

    CC Newcomer

  • Just Joined
  • PipPip
  • 18 posts

Posted 20 April 2010 - 01:17 PM

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.
  • 0





Also tagged with one or more of these keywords: mysql, connection, mysql_connect

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download