Regarding error #2:Sorry, I was going to create a new db.class.php class and call it object but the class already does that and names it $db so I fixed that error, it should be $db not $obj, but are you all saying that I shouldn't use this class because it uses mysql_connect() function which is old. I should scrap this whole class and just use mysqli instead? I think that makes sense.
About the connection error: It does work with a regular connection without using the db.class.php. This connection works:
$dbname= "taskos";
$link = mysql_connect('127.0.0.1:3306', 'xxx', 'xxxx');
mysql_select_db($dbname);
So it is strange I get this error and it changes it to 127.0.0.7 using this class.
Is it because it is calculating the port number as a string? I need the port to connect using TCP that is why I put the port number. I use this server as a test server for remote connections to demo files to clients. I have it on the outside IP outside the firewall. It is not secure but it only has test data. I'm going to scrap it and use mysqli
tnx,
class mysql {
public $dbname, $dbuser, $dbpass, $dbhost, $dbcon;
public $auto_slashes;
public $sql_error;
public $row_count;
public function __construct($dbn, $dbh, $dbu, $dbp) {
$this->dbhost=$dbh;
$this->dbname=$dbn;
$this->dbpass=$dbp;
$this->dbuser=$dbu;
$this->auto_slashes = true;
$this->doconnect();
}
public function doconnect()
{
$this->dbcon=mysql_connect($this->dbhost,$this->dbuser, $this->dbpass);
mysql_select_db($this->dbname);
}
public function runquery($sql)
{
$result=mysql_query($sql);
return $result;
}