Connecting Tech Pros Worldwide Forums | Help | Site Map

Connect to MySQL Database using PHP

christopher_board@yahoo.co.uk
Guest
 
Posts: n/a
#1: May 7 '07
Hi all. I am trying to connect to a MySQL Database using PHP on a
local machine using locahost. I am using the following code

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
die ('Error connecting to mysql');

$dbname = 'pmoneytest';
mysql_select_db($dbname);
?>

When I view the page it then comes up with an error that says
PHP Fatal error: Call to undefined function mysql_connect() in C:
\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
the problem is as I got the code from the Internet and it seems to be
the same on all the different website that I look at.

Thanks very much for your help and I look forward to hearing from you
in the near future.


ZeldorBlat
Guest
 
Posts: n/a
#2: May 7 '07

re: Connect to MySQL Database using PHP


On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
Quote:
Hi all. I am trying to connect to a MySQL Database using PHP on a
local machine using locahost. I am using the following code
>
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
>
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
die ('Error connecting to mysql');
>
$dbname = 'pmoneytest';
mysql_select_db($dbname);
?>
>
When I view the page it then comes up with an error that says
PHP Fatal error: Call to undefined function mysql_connect() in C:
\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
the problem is as I got the code from the Internet and it seems to be
the same on all the different website that I look at.
>
Thanks very much for your help and I look forward to hearing from you
in the near future.
Make sure that you've enabled the MySQL extension in php.ini. You can
check this by running the following script and examining the output:

<?php
phpinfo();
?>

christopher_board@yahoo.co.uk
Guest
 
Posts: n/a
#3: May 7 '07

re: Connect to MySQL Database using PHP


On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
Quote:
On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>
>
>
>
>
Quote:
Hi all. I am trying to connect to a MySQL Database using PHP on a
local machine using locahost. I am using the following code
>
Quote:
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
>
Quote:
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
die ('Error connecting to mysql');
>
Quote:
$dbname = 'pmoneytest';
mysql_select_db($dbname);
?>
>
Quote:
When I view the page it then comes up with an error that says
PHP Fatal error: Call to undefined function mysql_connect() in C:
\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
the problem is as I got the code from the Internet and it seems to be
the same on all the different website that I look at.
>
Quote:
Thanks very much for your help and I look forward to hearing from you
in the near future.
>
Make sure that you've enabled the MySQL extension in php.ini. You can
check this by running the following script and examining the output:
>
<?php
phpinfo();
?>- Hide quoted text -
>
- Show quoted text -
Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
pointing to where the server is installed. But the internet page still
doesn't work. Is there anything else that I can try.

Jerry Stuckle
Guest
 
Posts: n/a
#4: May 7 '07

re: Connect to MySQL Database using PHP


christopher_board@yahoo.co.uk wrote:
Quote:
On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
Quote:
>On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>>
>>
>>
>>
>>
Quote:
>>Hi all. I am trying to connect to a MySQL Database using PHP on a
>>local machine using locahost. I am using the following code
>><?php
>>$dbhost = 'localhost';
>>$dbuser = 'root';
>>$dbpass = 'password';
>>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>>die ('Error connecting to mysql');
>>$dbname = 'pmoneytest';
>>mysql_select_db($dbname);
>>?>
>>When I view the page it then comes up with an error that says
>>PHP Fatal error: Call to undefined function mysql_connect() in C:
>>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>>the problem is as I got the code from the Internet and it seems to be
>>the same on all the different website that I look at.
>>Thanks very much for your help and I look forward to hearing from you
>>in the near future.
>Make sure that you've enabled the MySQL extension in php.ini. You can
>check this by running the following script and examining the output:
>>
><?php
>phpinfo();
>?>- Hide quoted text -
>>
>- Show quoted text -
>
Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
pointing to where the server is installed. But the internet page still
doesn't work. Is there anything else that I can try.
>
Christopher,

Does phpinfo() have a mysql section? It will have items like:

Active Persistent Links 0
Active Links 0
Client API version 5.0.32
MYSQL_MODULE_TYPE external

and so on.

Your symptom is indicates that the mysql extension is not loaded in php.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
christopher_board@yahoo.co.uk
Guest
 
Posts: n/a
#5: May 7 '07

re: Connect to MySQL Database using PHP


On 7 May, 23:14, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
christopher_bo...@yahoo.co.uk wrote:
Quote:
On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
Quote:
On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>
Quote:
Quote:
>Hi all. I am trying to connect to a MySQL Database using PHP on a
>local machine using locahost. I am using the following code
><?php
>$dbhost = 'localhost';
>$dbuser = 'root';
>$dbpass = 'password';
>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>die ('Error connecting to mysql');
>$dbname = 'pmoneytest';
>mysql_select_db($dbname);
>?>
>When I view the page it then comes up with an error that says
>PHP Fatal error: Call to undefined function mysql_connect() in C:
>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>the problem is as I got the code from the Internet and it seems to be
>the same on all the different website that I look at.
>Thanks very much for your help and I look forward to hearing from you
>in the near future.
Make sure that you've enabled the MySQL extension in php.ini. You can
check this by running the following script and examining the output:
>
Quote:
Quote:
<?php
phpinfo();
?>- Hide quoted text -
>
Quote:
Quote:
- Show quoted text -
>
Quote:
Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
pointing to where the server is installed. But the internet page still
doesn't work. Is there anything else that I can try.
>
Christopher,
>
Does phpinfo() have a mysql section? It will have items like:
>
Active Persistent Links 0
Active Links 0
Client API version 5.0.32
MYSQL_MODULE_TYPE external
>
and so on.
>
Your symptom is indicates that the mysql extension is not loaded in php.
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
>
- Show quoted text -
Hi. There isn't actually heading called MySQL but it does have Active
Persistent Links 0. The things that you mentioned are not
shown in phpinfo();.

Thanks very much for your help in this matter

Daniele
Guest
 
Posts: n/a
#6: May 7 '07

re: Connect to MySQL Database using PHP


christopher_board@yahoo.co.uk wrote:
Quote:
On 7 May, 23:14, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>christopher_bo...@yahoo.co.uk wrote:
Quote:
>>On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
>>>On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>>>>Hi all. I am trying to connect to a MySQL Database using PHP on a
>>>>local machine using locahost. I am using the following code
>>>><?php
>>>>$dbhost = 'localhost';
>>>>$dbuser = 'root';
>>>>$dbpass = 'password';
>>>>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>>>>die ('Error connecting to mysql');
>>>>$dbname = 'pmoneytest';
>>>>mysql_select_db($dbname);
>>>>?>
>>>>When I view the page it then comes up with an error that says
>>>>PHP Fatal error: Call to undefined function mysql_connect() in C:
>>>>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>>>>the problem is as I got the code from the Internet and it seems to be
>>>>the same on all the different website that I look at.
>>>>Thanks very much for your help and I look forward to hearing from you
>>>>in the near future.
>>>Make sure that you've enabled the MySQL extension in php.ini. You can
>>>check this by running the following script and examining the output:
>>><?php
>>>phpinfo();
>>>?>- Hide quoted text -
>>>- Show quoted text -
>>Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
>>pointing to where the server is installed. But the internet page still
>>doesn't work. Is there anything else that I can try.
>Christopher,
>>
>Does phpinfo() have a mysql section? It will have items like:
>>
>Active Persistent Links 0
>Active Links 0
>Client API version 5.0.32
>MYSQL_MODULE_TYPE external
>>
>and so on.
>>
>Your symptom is indicates that the mysql extension is not loaded in php.
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================- Hide quoted text -
>>
>- Show quoted text -
>
Hi. There isn't actually heading called MySQL but it does have Active
Persistent Links 0. The things that you mentioned are not
shown in phpinfo();.
>
Thanks very much for your help in this matter
>
Check the php.ini( find path with phpinfo()
find and replace for php_mysql.dll
make sure it is enable

example:
with ";" in front of the extention is disable
;extension=php_msql.dll ( disable)
extension=php_mysql.dll ( enable )


hope it work
Jerry Stuckle
Guest
 
Posts: n/a
#7: May 8 '07

re: Connect to MySQL Database using PHP


christopher_board@yahoo.co.uk wrote:
Quote:
On 7 May, 23:14, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
>christopher_bo...@yahoo.co.uk wrote:
Quote:
>>On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
>>>On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>>>>Hi all. I am trying to connect to a MySQL Database using PHP on a
>>>>local machine using locahost. I am using the following code
>>>><?php
>>>>$dbhost = 'localhost';
>>>>$dbuser = 'root';
>>>>$dbpass = 'password';
>>>>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>>>>die ('Error connecting to mysql');
>>>>$dbname = 'pmoneytest';
>>>>mysql_select_db($dbname);
>>>>?>
>>>>When I view the page it then comes up with an error that says
>>>>PHP Fatal error: Call to undefined function mysql_connect() in C:
>>>>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>>>>the problem is as I got the code from the Internet and it seems to be
>>>>the same on all the different website that I look at.
>>>>Thanks very much for your help and I look forward to hearing from you
>>>>in the near future.
>>>Make sure that you've enabled the MySQL extension in php.ini. You can
>>>check this by running the following script and examining the output:
>>><?php
>>>phpinfo();
>>>?>- Hide quoted text -
>>>- Show quoted text -
>>Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
>>pointing to where the server is installed. But the internet page still
>>doesn't work. Is there anything else that I can try.
>Christopher,
>>
>Does phpinfo() have a mysql section? It will have items like:
>>
>Active Persistent Links 0
>Active Links 0
>Client API version 5.0.32
>MYSQL_MODULE_TYPE external
>>
>and so on.
>>
>Your symptom is indicates that the mysql extension is not loaded in php.
>>
>--
>==================
>Remove the "x" from my email address
>Jerry Stuckle
>JDS Computer Training Corp.
>jstuck...@attglobal.net
>==================- Hide quoted text -
>>
>- Show quoted text -
>
Hi. There isn't actually heading called MySQL but it does have Active
Persistent Links 0. The things that you mentioned are not
shown in phpinfo();.
>
Thanks very much for your help in this matter
>
OK, then the MySQL extension is not loaded. You need to add it in your
php.ini file.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
christopher_board@yahoo.co.uk
Guest
 
Posts: n/a
#8: May 9 '07

re: Connect to MySQL Database using PHP


On 7 May, 23:38, Daniele <"dankan775{["@]}yahoo.itwrote:
Quote:
christopher_bo...@yahoo.co.uk wrote:
Quote:
On 7 May, 23:14, Jerry Stuckle <jstuck...@attglobal.netwrote:
Quote:
christopher_bo...@yahoo.co.uk wrote:
>On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
>>On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>>>Hi all. I am trying to connect to a MySQL Database using PHP on a
>>>local machine using locahost. I am using the following code
>>><?php
>>>$dbhost = 'localhost';
>>>$dbuser = 'root';
>>>$dbpass = 'password';
>>>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>>>die ('Error connecting to mysql');
>>>$dbname = 'pmoneytest';
>>>mysql_select_db($dbname);
>>>?>
>>>When I view the page it then comes up with an error that says
>>>PHP Fatal error: Call to undefined function mysql_connect() in C:
>>>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>>>the problem is as I got the code from the Internet and it seems to be
>>>the same on all the different website that I look at.
>>>Thanks very much for your help and I look forward to hearing from you
>>>in the near future.
>>Make sure that you've enabled the MySQL extension in php.ini. You can
>>check this by running the following script and examining the output:
>><?php
>>phpinfo();
>>?>- Hide quoted text -
>>- Show quoted text -
>Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
>pointing to where the server is installed. But the internet page still
>doesn't work. Is there anything else that I can try.
Christopher,
>
Quote:
Quote:
Does phpinfo() have a mysql section? It will have items like:
>
Quote:
Quote:
Active Persistent Links 0
Active Links 0
Client API version 5.0.32
MYSQL_MODULE_TYPE external
>
Quote:
Quote:
and so on.
>
Quote:
Quote:
Your symptom is indicates that the mysql extension is not loaded in php.
>
Quote:
Quote:
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================- Hide quoted text -
>
Quote:
Quote:
- Show quoted text -
>
Quote:
Hi. There isn't actually heading called MySQL but it does have Active
Persistent Links 0. The things that you mentioned are not
shown in phpinfo();.
>
Quote:
Thanks very much for your help in this matter
>
Check the php.ini( find path with phpinfo()
find and replace for php_mysql.dll
make sure it is enable
>
example:
with ";" in front of the extention is disable
;extension=php_msql.dll ( disable)
extension=php_mysql.dll ( enable )
>
hope it work- Hide quoted text -
>
- Show quoted text -
Hi. I have enabled extension=php_mysql.dll and when I go onto
phpinfo(); it then comes up with an error that says

PHP Warning: PHP Startup: Unable to load dynamic library './
php_msql.dll' - The specified module could not be found. in Unknown on
line 0 PHP Warning: PHP Startup: Unable to load dynamic library './
php_mysql.dll' - The specified module could not be found. in Unknown
on line 0.

What can I try now

Jerry Stuckle
Guest
 
Posts: n/a
#9: May 9 '07

re: Connect to MySQL Database using PHP


christopher_board@yahoo.co.uk wrote:
Quote:
On 7 May, 23:38, Daniele <"dankan775{["@]}yahoo.itwrote:
Quote:
>christopher_bo...@yahoo.co.uk wrote:
Quote:
>>On 7 May, 23:14, Jerry Stuckle <jstuck...@attglobal.netwrote:
>>>christopher_bo...@yahoo.co.uk wrote:
>>>>On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
>>>>>On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>>>>>>Hi all. I am trying to connect to a MySQL Database using PHP on a
>>>>>>local machine using locahost. I am using the following code
>>>>>><?php
>>>>>>$dbhost = 'localhost';
>>>>>>$dbuser = 'root';
>>>>>>$dbpass = 'password';
>>>>>>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>>>>>>die ('Error connecting to mysql');
>>>>>>$dbname = 'pmoneytest';
>>>>>>mysql_select_db($dbname);
>>>>>>?>
>>>>>>When I view the page it then comes up with an error that says
>>>>>>PHP Fatal error: Call to undefined function mysql_connect() in C:
>>>>>>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>>>>>>the problem is as I got the code from the Internet and it seems to be
>>>>>>the same on all the different website that I look at.
>>>>>>Thanks very much for your help and I look forward to hearing from you
>>>>>>in the near future.
>>>>>Make sure that you've enabled the MySQL extension in php.ini. You can
>>>>>check this by running the following script and examining the output:
>>>>><?php
>>>>>phpinfo();
>>>>>?>- Hide quoted text -
>>>>>- Show quoted text -
>>>>Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
>>>>pointing to where the server is installed. But the internet page still
>>>>doesn't work. Is there anything else that I can try.
>>>Christopher,
>>>Does phpinfo() have a mysql section? It will have items like:
>>>Active Persistent Links 0
>>>Active Links 0
>>>Client API version 5.0.32
>>>MYSQL_MODULE_TYPE external
>>>and so on.
>>>Your symptom is indicates that the mysql extension is not loaded in php.
>>>--
>>>==================
>>>Remove the "x" from my email address
>>>Jerry Stuckle
>>>JDS Computer Training Corp.
>>>jstuck...@attglobal.net
>>>==================- Hide quoted text -
>>>- Show quoted text -
>>Hi. There isn't actually heading called MySQL but it does have Active
>>Persistent Links 0. The things that you mentioned are not
>>shown in phpinfo();.
>>Thanks very much for your help in this matter
>Check the php.ini( find path with phpinfo()
>find and replace for php_mysql.dll
>make sure it is enable
>>
>example:
>with ";" in front of the extention is disable
>;extension=php_msql.dll ( disable)
>extension=php_mysql.dll ( enable )
>>
>hope it work- Hide quoted text -
>>
>- Show quoted text -
>
Hi. I have enabled extension=php_mysql.dll and when I go onto
phpinfo(); it then comes up with an error that says
>
PHP Warning: PHP Startup: Unable to load dynamic library './
php_msql.dll' - The specified module could not be found. in Unknown on
line 0 PHP Warning: PHP Startup: Unable to load dynamic library './
php_mysql.dll' - The specified module could not be found. in Unknown
on line 0.
>
What can I try now
>
Do you have the libmysql.dll installed in a directory in your PATH
statement?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
christopher_board@yahoo.co.uk
Guest
 
Posts: n/a
#10: May 9 '07

re: Connect to MySQL Database using PHP



Jerry Stuckle wrote:
Quote:
christopher_board@yahoo.co.uk wrote:
Quote:
On 7 May, 23:38, Daniele <"dankan775{["@]}yahoo.itwrote:
Quote:
christopher_bo...@yahoo.co.uk wrote:
>On 7 May, 23:14, Jerry Stuckle <jstuck...@attglobal.netwrote:
>>christopher_bo...@yahoo.co.uk wrote:
>>>On 7 May, 21:11, ZeldorBlat <zeldorb...@gmail.comwrote:
>>>>On May 7, 3:59 pm, christopher_bo...@yahoo.co.uk wrote:
>>>>>Hi all. I am trying to connect to a MySQL Database using PHP on a
>>>>>local machine using locahost. I am using the following code
>>>>><?php
>>>>>$dbhost = 'localhost';
>>>>>$dbuser = 'root';
>>>>>$dbpass = 'password';
>>>>>$conn = mysql_connect($dbhost, $dbuser, $dbpass) or
>>>>>die ('Error connecting to mysql');
>>>>>$dbname = 'pmoneytest';
>>>>>mysql_select_db($dbname);
>>>>>?>
>>>>>When I view the page it then comes up with an error that says
>>>>>PHP Fatal error: Call to undefined function mysql_connect() in C:
>>>>>\Inetpub\wwwroot\PHPTest\connection.php on line 6. I can't see what
>>>>>the problem is as I got the code from the Internet and it seems to be
>>>>>the same on all the different website that I look at.
>>>>>Thanks very much for your help and I look forward to hearing from you
>>>>>in the near future.
>>>>Make sure that you've enabled the MySQL extension in php.ini. You can
>>>>check this by running the following script and examining the output:
>>>><?php
>>>>phpinfo();
>>>>?>- Hide quoted text -
>>>>- Show quoted text -
>>>Hi. I have checked the phpinfo(); and MySQL seems to be ok as it is
>>>pointing to where the server is installed. But the internet page still
>>>doesn't work. Is there anything else that I can try.
>>Christopher,
>>Does phpinfo() have a mysql section? It will have items like:
>>Active Persistent Links 0
>>Active Links 0
>>Client API version 5.0.32
>>MYSQL_MODULE_TYPE external
>>and so on.
>>Your symptom is indicates that the mysql extension is not loaded in php.
>>--
>>==================
>>Remove the "x" from my email address
>>Jerry Stuckle
>>JDS Computer Training Corp.
>>jstuck...@attglobal.net
>>==================- Hide quoted text -
>>- Show quoted text -
>Hi. There isn't actually heading called MySQL but it does have Active
>Persistent Links 0. The things that you mentioned are not
>shown in phpinfo();.
>Thanks very much for your help in this matter
Check the php.ini( find path with phpinfo()
find and replace for php_mysql.dll
make sure it is enable
>
example:
with ";" in front of the extention is disable
;extension=php_msql.dll ( disable)
extension=php_mysql.dll ( enable )
>
hope it work- Hide quoted text -
>
- Show quoted text -
Hi. I have enabled extension=php_mysql.dll and when I go onto
phpinfo(); it then comes up with an error that says

PHP Warning: PHP Startup: Unable to load dynamic library './
php_msql.dll' - The specified module could not be found. in Unknown on
line 0 PHP Warning: PHP Startup: Unable to load dynamic library './
php_mysql.dll' - The specified module could not be found. in Unknown
on line 0.

What can I try now
>
Do you have the libmysql.dll installed in a directory in your PATH
statement?
>
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Hi. I have managed to get it working. The problem was that I had to
copy the dll files that were in a zip file to the root of the php
program folder.

Closed Thread