devarmagan Posted October 15, 2006 Share Posted October 15, 2006 iam inserting a new record in php and iam gertting a error while connecting to mysql the error msg is "Fatal error: Call to undefined function mysql_connect() in C:\webs\test\insert.php on line 2"while iam configuring the the mysql i9 have given username and password admin and adminis that the wayplease help me[code]<?php$con = mysql_connect('localhost','admin','admin');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con);$sql="INSERT INTO person (FirstName, LastName, Age)VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con)?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/ Share on other sites More sharing options...
wildteen88 Posted October 15, 2006 Share Posted October 15, 2006 Please read this [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]thread[/url]You need to enable the mysql extension in the php.ini in order to use the mysql functions for PHP. Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109017 Share on other sites More sharing options...
devarmagan Posted October 15, 2006 Author Share Posted October 15, 2006 i refer that thred still iam having that problem Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109028 Share on other sites More sharing options...
fenway Posted October 15, 2006 Share Posted October 15, 2006 Well, the extension is not properly installed, then. Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109064 Share on other sites More sharing options...
devarmagan Posted October 15, 2006 Author Share Posted October 15, 2006 how can i fix that Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109071 Share on other sites More sharing options...
wildteen88 Posted October 15, 2006 Share Posted October 15, 2006 Run the following functoin in a script:[code]<?phpphpinfo();?>[/code]Do you get a mysql or a mysqli section? If you dont make sure PHP is using the correct php.ini by checking the line that starts with [b]Configuration File (php.ini) Path[/b]. Also turn on the [b]display_startup_errors[/b] too in the php.ini to see if PHP is loading up okay.Also make sure that you restart your server whenever you make any changes to the php.ini! Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109072 Share on other sites More sharing options...
devarmagan Posted October 15, 2006 Author Share Posted October 15, 2006 the configuration php.ini path is C:\PHP\php.ini Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109075 Share on other sites More sharing options...
wildteen88 Posted October 15, 2006 Share Posted October 15, 2006 Is that the correct path (C:\PHP\) to php.ini? and did you turn on display_startup_errors too? Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109078 Share on other sites More sharing options...
devarmagan Posted October 15, 2006 Author Share Posted October 15, 2006 yes . did i have to restart my pc? Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109087 Share on other sites More sharing options...
wildteen88 Posted October 15, 2006 Share Posted October 15, 2006 No the server, as in the server software (not hardware). Restart IIS, Apache or whatever you server software is. Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109092 Share on other sites More sharing options...
devarmagan Posted October 15, 2006 Author Share Posted October 15, 2006 no still iam getting the error Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109097 Share on other sites More sharing options...
devarmagan Posted October 15, 2006 Author Share Posted October 15, 2006 did i have to change the path of php.ini if then where can i change it? Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-109099 Share on other sites More sharing options...
devarmagan Posted October 18, 2006 Author Share Posted October 18, 2006 hello help me to fix my problem Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-110511 Share on other sites More sharing options...
fenway Posted October 19, 2006 Share Posted October 19, 2006 Why don't you post the output of phpinfo()? Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-111373 Share on other sites More sharing options...
devarmagan Posted October 27, 2006 Author Share Posted October 27, 2006 how can i post the output Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-115305 Share on other sites More sharing options...
devarmagan Posted October 27, 2006 Author Share Posted October 27, 2006 ok view my local pc php configurations here http://www.ggeye.com/phpinfo.htm Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-115309 Share on other sites More sharing options...
fenway Posted October 28, 2006 Share Posted October 28, 2006 wildteen88 suggested that you dump phpinfo() to see how the configuration variables were defined; just cut & paste. Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-115878 Share on other sites More sharing options...
devarmagan Posted October 29, 2006 Author Share Posted October 29, 2006 iam not clear sir from where and what i have to cut and past. please help me Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-116187 Share on other sites More sharing options...
fenway Posted October 29, 2006 Share Posted October 29, 2006 I believe that your link above contains the necessary configuration details; however, I'm not a PHP expert, nor do I know how it should "look". Wildteen? Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-116405 Share on other sites More sharing options...
Ting Posted October 30, 2006 Share Posted October 30, 2006 Here's the phpinfo code - just put this into a template foo.php in your webroot and then browse to it. You'll get several pages of information.<?php phpinfo();?>In php.ini do you have the following WITHOUT ; in front of them?display_errors = Ondisplay_startup_errors = Ondoc_root = c:\inetpub\wwwroot (or whatever it is)extension_dir = "C:\PHP\ext" (or whatever it is)extension=php_mysql.dllextension=php_mysqli.dll - (one or both, depending on which type of MySQL you want to use)If you're running IIS, you'll also need the Windows versions of php_mysql.dll or php_mysqli.dll (which go into your "extentions" directory, as above) and libmysql.dll, which goes into your PHP directory. You can get them from php.net.Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-116515 Share on other sites More sharing options...
devarmagan Posted October 31, 2006 Author Share Posted October 31, 2006 yes now connecting but again iam getting an errorthis is the code iam runing[code]<?php$con = mysql_connect('localhost','root','admin');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("my_db", $con);$sql="INSERT INTO person (FirstName, LastName, Age)VALUES('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";mysql_close($con)?>[/code]"error msg"Error: No database selected Quote Link to comment https://forums.phpfreaks.com/topic/23993-need-help-in-connecting-mysql-using-php/#findComment-117135 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.