When I want to generate a PDF with php and MySQL I get this error, which I don't know how to solve:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:\xampp\htdocs\codigoresponsive\codigonuevoappfish\opnpdf\reporte3_pdf.php:4 Stack trace: #0 {main} thrown in
Mysql_connect
is deprecated, you have to usemysqli
instead:And do the queries like this:
Using the Query method that the object has,
mysqli
you put the SQL string andfetch_object
you put the data of each row in a new object$f
to be able to access its columns in the way that I show in the example.All the best.
What happens is that you are using the extension
mysql_connect()
, it was deprecated inPHP 5.5.0
and removed inPHP 7.0.0
. And the extensionsMySQLi
or should be used insteadPDO_MySQL
.Example: