mikeymizrahi Posted July 14, 2006 Share Posted July 14, 2006 I'm new to mysql and am kind of familiar with PHP.When trying to connect to mysql through php, i get the following error message:"Fatal error: Call to undefined function mysql_connect() in C:\www\s.php on line 6"line 6 reads"$db = mysql_connect("localhost","root","mypasswordhere");"i have tried different variations of this line like $con.i can connect to the db on the mysql command line (no php involved).where is my problem?site is: http://mizrahi.ath.cx:8080/php/s.phpthanks,mikey Quote Link to comment Share on other sites More sharing options...
brown2005 Posted July 14, 2006 Share Posted July 14, 2006 <?phpsession_start();$database_host = "localhost";$database_username = "";$database_password = "";$database_name = "";$connection = mysql_connect($database_host, $database_username, $database_password) or die(mysql_error());$db = mysql_select_db($database_name, $connection);?> Quote Link to comment Share on other sites More sharing options...
brown2005 Posted July 14, 2006 Share Posted July 14, 2006 i have this in connection.php and then i use include('connection.php'); in the files i need it in.hope this helps Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 14, 2006 Share Posted July 14, 2006 Please [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]read this thread[/url]. You need to enable the mysql extension for PHP5 Quote Link to comment Share on other sites More sharing options...
mikeymizrahi Posted July 14, 2006 Author Share Posted July 14, 2006 i get the same error- maybe i have my username, password, host or database name wrong? Quote Link to comment Share on other sites More sharing options...
brown2005 Posted July 14, 2006 Share Posted July 14, 2006 post the full code u are trying to run? Quote Link to comment Share on other sites More sharing options...
mikeymizrahi Posted July 14, 2006 Author Share Posted July 14, 2006 i tried both this one:[color=blue]<html><body><?php$con = mysql_connect("localhost","root","password");if (!$con) { die('Could not connect: ' . mysql_error()); }?></body></html>[/color]and this one as connection.php, like you suggested[color=red]<?phpsession_start();$database_host = "localhost";$database_username = "root";$database_password = "password";$database_name = "";$connection = mysql_connect($database_host, $database_username, $database_password) or die(mysql_error());$db = mysql_select_db($database_name, $connection);?>[/color]neither worked, both gave the same error message- where can i go to find my username, host and other info Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 14, 2006 Share Posted July 14, 2006 mikeymizrahi are you geting an undefined function error message for mysql_connect? If you are need to enable the mysql extension! The version of PHP which you are using is PHP5. PHP5 doesnt come with mysql support builtin, like PHP4 does. So in order you to use the mysql functions you need to enable the mysql extension. In order to enable the mysql extension please [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]click here[/url] Quote Link to comment Share on other sites More sharing options...
mikeymizrahi Posted July 14, 2006 Author Share Posted July 14, 2006 already did that! didnt work Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 14, 2006 Share Posted July 14, 2006 OKay did you restart your server. Also how is your server setup. There is nothing wrong with your code. The problem is to do with PHP not loading the mysql extension. Could you provide a phpinfo page so I can see your servers configuration. Quote Link to comment Share on other sites More sharing options...
mikeymizrahi Posted July 14, 2006 Author Share Posted July 14, 2006 yeah, the php info page is athttp://mizrahi.ath.cx:8080/php/php.php Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 14, 2006 Share Posted July 14, 2006 Okay. Looking at your php.ini. PHP appears to be using the correct ini file. Now the only possible reasons why PHP is unable to load the mysql extension is either of the following: - a file called libmysql.dll cannot be found, this file is required in order for the mysql extension to function correctyly. See if you can find libmysql.dll within your php folder. If it is, copy this file to your WINDOWS folder. Restart Apache. Is the mysql extension loaded?- PHP has found an older version of libmysql with is not compatible with your version of PHP. Replace this file with the one in your php folder. Quote Link to comment Share on other sites More sharing options...
mikeymizrahi Posted July 14, 2006 Author Share Posted July 14, 2006 Working!The libmysql.dll file was in the PHP folder. I copied it, and it worked!Thank you VERY much!--mikey Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 14, 2006 Share Posted July 14, 2006 No problem! Glad you got everything up an running. Quote Link to comment 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.