Jump to content


This topic is now archived and is closed to further replies.


mysql_connect not working

Recommended Posts

I have installed Apache 2.058, PHP 5.1.4 and MySQL 5.0.22 on my windows server and everything seems to be running as it should, but there is one problem, when I use mysql_connect I get the error:

Fatal error: Call to undefined function mysql_connect() in C:\web\test2.php on line 5

The code:
@mysql_select_db($database) or die( "Unable to select database");
$query="select * from phptabel";

If I do this it works:


$mysqli = new mysqli('localhost','root','pass');

$result = $mysqli->query("SELECT * from phptabel");

while($row = $result->fetch_assoc()) {
print $row['fornavn'] . ' ' . $row['efternavn'] . '<br/>';


Why can I not use mysql_connect ?

Share this post

Link to post
Share on other sites
This becuase PHP5 doesnt come with built in support for MySQL as PHP4 does. Instead you'll need to enable the mysql extension. Please read this [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]tread[/url]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.