Current location: Hot Scripts Forums » Programming Languages » PHP » Connect to MySQL with PHP


Connect to MySQL with PHP

Reply
  #1 (permalink)  
Old 01-11-04, 04:17 AM
demiann demiann is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question Connect to MySQL with PHP - Undefined Function Call

Hello everybody,

I am a newbie first time posting...

I use PHP 5 beta & MySQL 4 on WinXP for local development. While I have no troubles connecting and creating databases thru command line, I cannot connect from PHP page.

Here is the simple code:

<?php

$host="localhost";
$username="root";
$password="";

$link = mysql_connect($host,$username,$password) or die("Unable to connect to database");
echo "Connected successfully";

?>

Which gives me this error in IE:

Fatal error: Call to undefined function mysql_connect() in C:\Documents and Settings\...(path to the root folder here)...\webs\tryout\dbconnect.php on line 10

Line 10 is the line with call to mysql_function

I actually enabled extension php_mysql.dll in php.ini and copied libMysql.dll into system root (system32) folder and still same thing...

Thank you,
Demainn

Last edited by demiann; 01-11-04 at 04:43 AM.
Reply With Quote
  #2 (permalink)  
Old 01-11-04, 04:50 AM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there,

It is probably because of the PHP version you are using. According to PHP.net, they took away the bundled MySQL client library from version 5 for good reasons:

http://ca.php.net/manual/en/faq.data...ses.mysql.php5

I strongly recommend that you go through the rest of change logs if you continue using PHP 5 beta, as there are many more changes since PHP 4.

HTH. Good night.
__________________
Blavv =|
Reply With Quote
  #3 (permalink)  
Old 01-11-04, 02:12 PM
demiann demiann is offline
Newbie Coder
 
Join Date: Jan 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Yes, I went thru it. I guess I will just install PHP 4 for right now until 5 goes stable.


Thanks.
Reply With Quote
  #4 (permalink)  
Old 01-11-04, 02:24 PM
blaw's Avatar
blaw blaw is offline
Junior Code Guru
 
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
Hi again,

Quote:
Yes, I went thru it. I guess I will just install PHP 4 for right now until 5 goes stable.
It's probably better for you that way, if you call yourself a "newbie". Betas are meant for developers who could contribute bug reports, etc, to the PHP team.

Happy coding. =)
__________________
Blavv =|
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error when trying to create MySQL table via PHP HasansWeb PHP 5 05-19-11 06:59 AM
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
Need Epinions-lite system in PHP & MYSQL wali001 Job Offers & Assistance 4 01-12-04 06:02 AM
Pulling data from MySQl Database w/ PHP? dayzeday PHP 6 10-07-03 07:01 AM
MySQL with PHP question. HELP for a newbie kenfused PHP 3 08-02-03 12:53 AM


All times are GMT -5. The time now is 08:26 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.