Jump to content

mysql_connect not working


kelloggs

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:
[pre]<?
$user="root";
$password="pass";
$database="phpbase";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="select * from phptabel";
mysql_query($query);
mysql_close();
?>[/pre]

If I do this it works:

[pre]<?

$mysqli = new mysqli('localhost','root','pass');
$mysqli->select_db('phpbase');

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

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

$result->close();

?>[/pre]
Why can I not use mysql_connect ?
Link to comment
https://forums.phpfreaks.com/topic/15793-mysql_connect-not-working/
Share on other sites

Archived

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

×
×
  • Create New...

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.