Hello guys,

I had to change the host of my web page , now I'm having trouble accessing the page because of problems in the connection string with the base.

Error that occurs : Warning : mysql_select_db ( ) expects parameter 2 to be resource , null given in /var/www/web/Classes/AcessDatabase.php online 9
The selected database

Source AccessDatabase.php file:

<?php 
 class Acesso {

 public function Conexao () {
$this->cnx= mysql_connect('AAAAAAAAAA','BBBBBBB','CCCCCCC') or print (mysql_error());
 mysql_select_db('AAAAAAAAAA',$cnx);
 public function ConexaoStoreProcedure () {
 $this->cnxSP= mysql_connect('AAAAAAAAAA','BBBBBBB','CCCCCCC') or print (mysql_error());
 mysql_select_db($this->cnxSP,'');
 }
 public function Query($sql){
 $this->result=mysql_query($sql) or die (mysql_error());
}
 public function StoreProcedure($SP,$cnxSP){
 $this->resultSP=mysql_query($cnxSP,$SP) or die (mysql_error($this->cnxSP));
 }
 public function __destruct(){
  @mysql_close($this->cnx);
 }
 }

?> 

what the holy shit it is?
- first of all there is 6 of opening curly brackets and 5 of closing curly brackets!
- in function Conexao you use $cnx, what it is?

The PHP manual has this to say about the mysql_select_db method's second parameter (called the link identifier):
Link Identifer:
The MySQL connection. If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.
It loks more, like you have your parameters in incorrect order in that line, In the previous musql_select_db you have a string and then the connection.
And kulcsarb has a point, you refer to $this->cnx and $this->cnxSP. That's not a typo?

The mysql api's in PHP have been deprecated in favor of the mysqli api's. You seriously need to change your code if you are running PHP 5.0 or later. If you are running earlier versions of PHP then you are operating out of the Dark Ages!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.