Parse error: syntax error, unexpected 'if' (T_IF) in C: \ xampp \ htdocs \ Web System \ conexion.php on line 17

0

This error is indicated to me, but I can not make it work. I attach the connection code.php

class Conexion
{

    public function __construct($server, $nameBD , $user , $pass)
    {
        $con = mysql_connect($server, $user , $pass);


        if (!$con) {
            die("Error al conectar:".mysql_error());
        }


        $selBD = mysql_select_db($nameBD);

        if (!$selBD) {
            die("Error al seleccionar la BD:".mysql_error());
        }
    }



    public function ejecutar ($query){

        return mysql_query($query);
    }
}
    
asked by Steven Andrade 19.04.2018 в 19:25
source

2 answers

0

Your problem is in this line:

$selBD = mysql_select_db($nameBD);

It should be:

$selBD = mysql_select_db($nameBD, $con);

By the way, the mysql functions have been depreciated. You should use msqli better.

    
answered by 19.04.2018 в 19:31
0

The solution to my problem was made more grounded, what I did is delete the php files from the project folder, then paste them into a "new folder", restart the server and go.

Thank you all.

    
answered by 19.04.2018 в 21:44