No tengo nada de conocimiento en este tipo de temas (PHP y SQL) sin embargo quiero probar un proyecto de GitHub en mi localhost (XAMPP) y obtengo el siguiente error:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ruta/installer.php:29 Stack trace: #0 {main} thrown in ruta\installer.php on line 29
Uso PHP 7 en XAMPP y por ahí leí que mysql_connect está desactualizado, el problema es cuando lo cambio a mysqli tampoco funciona. Pues me da error tras error, el archivo en teoría debería importar de db.sql a mi base de datos, es todo lo que sé.
<?php
// Name of the file
$filename = 'database/db.sql';
// MySQL host
$mysql_host = 'mysql_host';
// MySQL username
$mysql_username = 'mysql_username';
// MySQL password
$mysql_password = 'mysql_password';
// Database name
$mysql_database = 'mysql_database';
// Connect to MySQL server
mysql_connect($mysql_host, $mysql_username, $mysql_password) or die('Error connecting to MySQL server: ' . mysql_error());
// Select database
mysql_select_db($mysql_database) or die('Error selecting MySQL database: ' . mysql_error());
// Temporary variable, used to store current query
$templine = '';
// Read in entire file
$lines = file($filename);
// Loop through each line
foreach ($lines as $line)
{
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
continue;
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';')
{
// Perform the query
mysql_query($templine) or print('Error performing query \'<strong>' . $templine . '\': ' . mysql_error() . '<br /><br />');
// Reset temp variable to empty
$templine = '';
}
}
echo "Tables imported successfully";
?>
No solo es en XAMPP, pobré en mi hosting y el error persiste, al parecer todo el código está obsoleto, podían ayudarme a repararlo?:( Muchas gracias de antemano.