Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

help me!!!!

Featured Replies

ok im trying to learn some PHP and i has problem

if i change the db password to something else than it is it will give me an error, but it still wont connect with the right details pls help plox

my connection class

class connection {
  protected $db_connect;
  public $db_username = 'root';
  public $db_hostname = 'localhost';
  public $db_database = 'test';
  public $db_password = '';

  function db_connection() {
    try {
      $this->connection = new PDO("mysql:host=$this->db_hostname;$this->db_database", $this->db_username, $this->db_password);
      $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      return $this->connection;
    } catch(PDOException $error) {
      echo $error->getMessage();
    }
  }
  function debug_Connection() {
    if($this->db_connect == true) {
      echo 'Connection debugged.';
    }
  }
}
$test = new connection;
$test->db_connection();

pls help im stuck

Which localhosting service are you using?
MAMP?

8 minutes ago, Facial said:

ok im trying to learn some PHP and i has problem

if i change the db password to something else than it is it will give me an error, but it still wont connect with the right details pls help plox

my connection class


class connection {
  protected $db_connect;
  public $db_username = 'root';
  public $db_hostname = 'localhost';
  public $db_database = 'test';
  public $db_password = '';

  function db_connection() {
    try {
      $this->connection = new PDO("mysql:host=$this->db_hostname;$this->db_database", $this->db_username, $this->db_password);
      $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      return $this->connection;
    } catch(PDOException $error) {
      echo $error->getMessage();
    }
  }
  function debug_Connection() {
    if($this->db_connect == true) {
      echo 'Connection debugged.';
    }
  }
}
$test = new connection;
$test->db_connection();

pls help im stuck

Try changing 

class connection {
  protected $db_connect;
  public $db_username = 'root';
  public $db_hostname = 'localhost';
  public $db_database = 'test';
  public $db_password = '';

to


class connection {
  protected $db_connect;
  public $db_username = "root";
  public $db_hostname = "localhost";
  public $db_database = "test";
  public $db_password = "";

Also, I usually work via DAO

class DAO {
	private static $dbHost = "localhost";
	private static $dbName = "kcart";
	private static $dbUser = "kcartTest";
	private static $dbPass = "";
	private static $sharedPDO;

	protected $pdo;

	function __construct() {
		if(empty(self::$sharedPDO)) {
			self::$sharedPDO = new PDO("mysql:host=" . self::$dbHost . ";dbname=" . self::$dbName, self::$dbUser, self::$dbPass);
			self::$sharedPDO->exec("SET CHARACTER SET utf8");
			self::$sharedPDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
			self::$sharedPDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
		}
		$this->pdo =& self::$sharedPDO;
	}

 

Edited by Howest

If you're using MAMP you need to connect via socket, if not please give more info.

Edited by harrypotter

Also I believe this:

$this->connection = new PDO("mysql:host=$this->db_hostname;$this->db_database", $this->db_username, $this->db_password);

Is invalid, you need to specify that 

$this->db_datebase

is the database name:

$this->connection = new PDO("mysql:host=$this->db_hostname;dbname=$this->db_database", $this->db_username, $this->db_password);

Might be wrong though

Edited by harrypotter

  • Author

Yes, but it still wont print the debug_Connection() function..

I missed the dbname= in the PDO(), now it also gives me error IF the DB wont exists, but doesnt give me a connection succeed message when I try to print it.

 

13 minutes ago, Facial said:

Yes, but it still wont print the debug_Connection() function..

I missed the dbname= in the PDO(), now it also gives me error IF the DB wont exists, but doesnt give me a connection succeed message when I try to print it.

 

I'm not really sure what you mean, if should return an error if the database table doesn't exist. Why would it give a connection success message when it didn't successfully connect?

If you're getting an error stating that the db table doesn't exist then double check your table name is correct

  • Author
6 minutes ago, harrypotter said:

I'm not really sure what you mean, if should return an error if the database table doesn't exist. Why would it give a connection success message when it didn't successfully connect?

If you're getting an error stating that the db table doesn't exist then double check your table name is correct

No, no and no.

First I was unable to get the error even with false details, now it gives me the error I want when false details.

But still wont print my debug function.

3 minutes ago, Facial said:

No, no and no.

First I was unable to get the error even with false details, now it gives me the error I want when false details.

But still wont print my debug function.

From the snippet you've shown you're not even calling the 

debug_Connection()

function?

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.