3 Replies - 5984 Views - Last Post: 24 March 2009 - 05:14 PM Rate Topic: -----

#1 roscioa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-February 09

PHP Login Script

Posted 23 March 2009 - 09:00 PM

I have been trying to get a login script working on a site I have hosted at dreamhost.com. I am not sure if this is a problem with them not supporting my code or something in my code. This is the error I am receiving when I submit the login.


Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect to MySQL server on 'gz.com' (111) in /home/roscioa/gz.com/classes/Mysql.php on line 9

Warning: mysqli::prepare() [mysqli.prepare]: Couldn't fetch mysqli in /home/roscioa/gz.com/classes/Mysql.php on line 21

Here is the code:

   1.<?php
   2.
	   
   3.require_once 'includes/constants.php';
   4.
	   
   5.class Mysql {
   6.private $conn;
   7.
   8.function __construct() {
   9.$this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or
  10. die('There was a problem connecting to the database.');
  11.}
  12.
	   
  13.
  14.function verify_Username_and_Pass($un, $pwd) {
  15.
  16.$query = "SELECT *
  17.FROM users
  18.WHERE username = ? AND password = ?
  19.LIMIT 1";
  20.
  21.if($stmt = $this->conn->prepare($query)) {
  22.$stmt->bind_param('ss', $un, $pwd);
  23.$stmt->execute();
  24.
  25.if($stmt->fetch()) {
  26.$stmt->close();
  27.return true;
  28.}
  29.}
  30.
  31.}
  32.}



Thanks for the help.

This post has been edited by roscioa: 23 March 2009 - 09:00 PM


Is This A Good Question/Topic? 0
  • +

Replies To: PHP Login Script

#2 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5327
  • View blog
  • Posts: 27,246
  • Joined: 10-May 07

Re: PHP Login Script

Posted 23 March 2009 - 09:03 PM

View Postroscioa, on 23 Mar, 2009 - 10:00 PM, said:

Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect to MySQL server on 'gz.com' (111) in /home/roscioa/gz.com/classes/Mysql.php on line 9

Assuming that your credentials are correct, does gz.com allow for remote MySql connections?
Was This Post Helpful? 0
  • +
  • -

#3 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: PHP Login Script

Posted 23 March 2009 - 09:16 PM

Actually, if you're trying to connect to 'gz.com' from gz.com, you might consider just switching that to localhost.
Was This Post Helpful? 0
  • +
  • -

#4 roscioa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-February 09

Re: PHP Login Script

Posted 24 March 2009 - 05:14 PM

View Postno2pencil, on 23 Mar, 2009 - 08:03 PM, said:

View Postroscioa, on 23 Mar, 2009 - 10:00 PM, said:

Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2003): Can't connect to MySQL server on 'gz.com' (111) in /home/roscioa/gz.com/classes/Mysql.php on line 9

Assuming that your credentials are correct, does gz.com allow for remote MySql connections?


I will have to get with Dreamhost on this. I have another site running a Wordpress blog from this same account and I have no problems with it. I have tried adding this code to a local server at home that I am running another site and it does not seem to have errors with this code.

View PostValek, on 23 Mar, 2009 - 08:16 PM, said:

Actually, if you're trying to connect to 'gz.com' from gz.com, you might consider just switching that to localhost.


I tried adding localhost instead of the site name and still get the same result.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1