Jump to content


Photo

need help in connecting mysql using php


  • Please log in to reply
20 replies to this topic

#1 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 09:25 AM

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 admin
is that the way
please help me

<?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)
?>



#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 October 2006 - 10:48 AM

Please read this thread

You need to enable the mysql extension in the php.ini in order to use the mysql functions for PHP.

#3 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 12:44 PM

i refer that thred still iam having that problem

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 15 October 2006 - 03:51 PM

Well, the extension is not properly installed, then.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 04:30 PM

how can i fix that

#6 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 October 2006 - 04:34 PM

Run the following functoin in a script:
<?php
phpinfo();
?>

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 Configuration File (php.ini) Path. Also turn on the display_startup_errors 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!

#7 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 04:41 PM

the configuration php.ini path is  C:\PHP\php.ini   

#8 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 October 2006 - 04:51 PM

Is that the correct path (C:\PHP\) to php.ini? and did you turn on display_startup_errors too?

#9 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 05:27 PM

yes . did i have to restart my pc?

#10 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 15 October 2006 - 05:32 PM

No the server, as in the server software (not hardware). Restart IIS, Apache or whatever you server software is.

#11 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 05:38 PM

no still iam getting the error

#12 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 October 2006 - 05:41 PM

did i have to change the path of php.ini if then where can i change it?

#13 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 18 October 2006 - 07:32 AM

hello help me to fix my problem

#14 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 19 October 2006 - 04:14 PM

Why don't you post the output of phpinfo()?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#15 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 27 October 2006 - 10:56 AM

how can i post  the output

#16 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 27 October 2006 - 11:06 AM

ok view my local pc php configurations here http://www.ggeye.com/phpinfo.htm

#17 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 28 October 2006 - 03:57 PM

wildteen88 suggested that you dump phpinfo() to see how the configuration variables were defined; just cut & paste.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#18 devarmagan

devarmagan
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 29 October 2006 - 08:47 AM

iam not clear sir from where and what i have to cut and past. please help me

#19 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 29 October 2006 - 07:27 PM

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?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#20 Ting

Ting
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 30 October 2006 - 12:40 AM

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 = On
display_startup_errors = On
doc_root = c:\inetpub\wwwroot  (or whatever it is)
extension_dir = "C:\PHP\ext" (or whatever it is)
extension=php_mysql.dll
extension=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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users