kelloggs Posted July 27, 2006 Share Posted July 27, 2006 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 5The 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/15793-mysql_connect-not-working/ Share on other sites More sharing options...
wildteen88 Posted July 27, 2006 Share Posted July 27, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/15793-mysql_connect-not-working/#findComment-64577 Share on other sites More sharing options...
kelloggs Posted July 27, 2006 Author Share Posted July 27, 2006 ;DI was missing "extension=php_mysql.dll".Thx. for the help. Quote Link to comment https://forums.phpfreaks.com/topic/15793-mysql_connect-not-working/#findComment-64607 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.