Answer the question
In order to leave comments, you need to log in
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
The mysql_ functions have been removed from PHP since version 7.
Use mysqli or PDO.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question