1

I tried running the 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 the following error:

Fatal error: Call to undefined function mysql_connect() in                                    
C:\Program Files (x86)\ApacheSoftware Foundation\Apache2.2\htdocs\read.php 
on line 5

2 Answers 2

0

Look at you phpinfo(). Most likely mysql extensions is not there.

And while you are at it, you could just drop the ancient mysql_* way ow doing thing and learn how to use PDO and prepared statements. It's an abstraction API for database connection and interaction.

1
  • Yes, I think I understand now. Investigating how to add the MySQL extension. Do not see anything in the phpinfo() that MySQL is active. Commented Apr 29, 2011 at 21:57
0

your mysql-extension for php is not loaded! check that in your php.ini.

1
  • ah, yes...I think I know what the problem is now!? Will let you know if I fix it. Thanks. Commented Apr 29, 2011 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.