V
V
Valeria_Rayshite2016-04-14 20:01:19
PHP
Valeria_Rayshite, 2016-04-14 20:01:19

How to fix Fatal error: Call to undefined function mysql_connect()?

Tell me, please, what could be the problem? Did a video tutorial.
<?php
$connection = mysql_connect("localhost", "my user", "123");
$db = mysql_select_db("my db");
mysql_set_chrset("utf8");
if(!connection || !db){
exit(mysql_error());
}
$result = mysql_query(" SELECT * FROM news ");
mysql_close();
$row = mysql_fetch_array($result);
echo $row['title'];
?>
Throws Fatal error: Call to undefined function mysql_connect() in C:\xampp\htdocs\php.loc\index.php on line 11

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2016-04-14
@Valeria_Rayshite

The mysql_ functions have been removed from PHP since version 7.
Use mysqli or PDO.

L
lubezniy, 2016-04-14
@lubezniy

If you do not want to rewrite, then install the mysql extension for php5.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question