Here is the code that used but return the 500 error in php version 7 and I totally screwed what to do with and could not find any documentation to do so.
<?php
// Create a new MySQL database connection
if (!$con = mysql_connect('localhost', 'root', 'password')) {
die('An error occurred while connecting to the MySQL server!<br><br>' . mysql_error());
}
if (!mysql_select_db(sample)) {
die('An error occurred while connecting to the database!<br><br>' . mysql_error());
}
// Create an array of MySQL queries to run
$sql = array(
'DROP TABLE IF EXISTS content;',
'CREATE TABLE content SELECT * FROM sample1.content'
);
// Run the MySQL queries
if (sizeof($sql) > 0) {
foreach ($sql as $query) {
if (!mysql_query($query)) {
die('A MySQL error has occurred!<br><br>' . mysql_error());
}
}
}
mysql_close($con);
?>
You are using an deprecated implementation of mysql that have been removed in php7.
please check http://php.net/manual/en/function.mysql-query.php
Here's a good tutorial about converting deprecated
mysql_*
PHP code to newmysqli_*
code:http://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
In many cases, you simply need to change "mysql" to "mysqli" for each function call.
Remember to change them all!