Parse error: syntax error, Unexpected '='

Asked

Viewed 726 times

0

I am mounting a connection to the database, but it returns me this error: Parse error: syntax error, Unexpected '=' in C: wamp64 www login connected.php on line 2

Code:

<?php
@connect = mysql_connect("localhost","root","") or die ("Erro na conexão");
mysql_select_db("tcc")or die ("Base não encontrada")
?>

Any idea?

1 answer

5


PHP variables should be prefixed with $ and not with @. Just change the code to:

<?php
    $connect = mysql_connect("localhost","root","") or die ("Erro na conexão");
    mysql_select_db("tcc") or die ("Base não encontrada")
?>

The @ serves to suppress errors, if that was your intention, take a read on Why do they say using @arroba to suppress errors is a bad practice?


Observing:

As has been said many times here on the site, it is not advisable to use the functions mysql, they are obsolete, mysqli is used to replace them.

See more in Why should we not use mysql type functions_*?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.