Reputation: 1
What does this error mean?
"Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\Myren\Connections\localhost.php on line"?
Upvotes: 0
Views: 597
Reputation: 74217
"What does this error mean?"
"Deprecated: mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\wamp\www\Myren\Connections\localhost.php on line"?
When installing Wampserver, it presently comes with PHP version 5.5.12, which that version of PHP will throw that notice if using mysql_
based code.
You will need to change all instances of mysql_
to mysqli_
(or use PDO).
Sidenote: mysqli_
requires DB connection parameter to be passed.
I know this because I myself have recently installed Wampserver on one of my PC's, and got the same error message running their test SQL script included with the installation. Already knowing what the error was about, was quickly able to rectify the problem.
Therefore and for example: (change the following)...
<?php
// Connecting, selecting database
$link = mysql_connect('localhost', 'username', 'password_if_any')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('your_database') or die('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
would need to be changed to:
<?php
// Connecting, selecting database
$link = mysqli_connect('localhost', 'username', 'password_if_any', 'your_DB')
or die('Could not connect: ' . mysqli_error($link));
echo 'Connected successfully';
// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysqli_query($link, $query)
or die('Query failed: ' . mysqli_error($link));
// Printing results in HTML
echo "<table>\n";
while ($line = mysqli_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysqli_free_result($result);
// Closing connection
mysqli_close($link);
?>
Upvotes: 1
Reputation: 1562
It means the MySQL extension in PHP is deprecated and might be removed in the future. It suggests you use an other extension instead, like PDO or MySQLi
Upvotes: 0
Reputation: 1519
It means the functions being used to connect and use MySQL in PHP are old (deprecated). You should switch to functions like mysqli_connect or PDO instead like the error message says.
Upvotes: 0