Using PHP to connect to MySQL: ERROR? -
i tried running following code: (http://localhost/read.php)
<html> <body> <?php $link = mysql_connect('localhost', 'root', 'password'); if (!$link) { die('could not connect: ' . mysql_error()); } echo 'connected successfully'; if (mysql_query("create database testphp",$link)) { echo "database created"; } else { echo "error creating database: " . mysql_error(); } ?> </body> </html>
and got following error:
fatal error: call undefined function mysql_connect() in c:\program files (x86)\apachesoftware foundation\apache2.2\htdocs\read.php on line 5
look @ phpinfo()
. mysql extensions not there.
and while @ it, drop ancient mysql_*
way ow doing thing , learn how use pdo , prepared statements. it's abstraction api database connection , interaction.
Comments
Post a Comment