Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-30-2005, 06:23 AM   #1
Member (7 bit)
 
Join Date: Sep 2004
Posts: 109
MySQL-PHP Connection

I can't get PHP to connect to MySQL no matter what I do. I have followed all the instructions on the PHP - MySQL page, but it doesn't work. I'm using Apache 2, PHP 5, MySQL 5.
Kulag is offline   Reply With Quote
Old 10-30-2005, 08:19 AM   #2
Member (9 bit)
 
Jimmy0's Avatar
 
Join Date: Sep 2005
Location: UK
Posts: 278
How are you trying to connect? Running a php script with mysql_connect? What kind of errors are you getting. Did you place the libmysql.dll in the appropriate folder?

We need a little more info to be able to help you out.
Jimmy0 is offline   Reply With Quote
Old 10-30-2005, 12:42 PM   #3
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally Posted by Jimmy0
How are you trying to connect? Running a php script with mysql_connect? What kind of errors are you getting. Did you place the libmysql.dll in the appropriate folder?

We need a little more info to be able to help you out.
Ditto to the above questions as well as what OS you are running?
__________________

Want to Make $$$$ with your Computer? No Risk! Simply press shift-4 four times in a row
mairving is offline   Reply With Quote
Old 10-30-2005, 12:58 PM   #4
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Make sure you have the MySql module enabled in the PHP ini file. For Windows, uncomment the php_mysql.dll line, for Linux, php_mysql.so. You can find this under the [Extensions]. Save your changes and restart Apache.
faulkner132 is offline   Reply With Quote
Old 10-30-2005, 03:31 PM   #5
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally Posted by faulkner132
for Linux, php_mysql.so. You can find this under the [Extensions]. Save your changes and restart Apache.
I prefer to use the term 'nix since there are others BSD, Solaris, OSX that that would apply to.
mairving is offline   Reply With Quote
Old 11-01-2005, 06:10 AM   #6
Member (7 bit)
 
Join Date: Sep 2004
Posts: 109
I'm running WinXP Pro. libmysql.dll is in the C:\php folder, along with php itself. I belive the instructions say that it's ok to leave it there. As far as I know, mysql_connect is the only way to connect to MySQL.

@faulkner, the correct module is mysqli.dll. This is the advanced module that enables use of the new features in MySQL 5. I've tried mysql.dll as well, but it doesn't work. The .so extention is used for Apache modules.

As for errors, I've never gotten any from PHP or any of the apps I've written. Rather, I get a blank page. However, phpmyadmin and phpBB have given me errors.
phpBB: Your PHP server configuration doesn't support the data base type you chose.
phpmyadmin: Cannot connect to MySQL, check your PHP configuration.
Or something like that...

Last edited by Kulag; 11-01-2005 at 06:20 AM.
Kulag is offline   Reply With Quote
Old 11-01-2005, 07:31 AM   #7
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Kulag,

You need to have both mysql and mysqli enabled if you want to use the "improved" interface. Whatever path you have your extensions set to, make sure it is also in your Window's PATH variable (will have to reboot after doing this). Also make sure your php.ini file is in the C:\Windows directory.

If you want to use the mysqli functionality, it has a different set of function calls (i.e. mysqli_connect, mysqli_query, etc.)
faulkner132 is offline   Reply With Quote
Old 11-02-2005, 08:23 AM   #8
Member (7 bit)
 
Join Date: Sep 2004
Posts: 109
@faulkner, how then does this work with scripts that use mysql_connect, etc?

Also, should I use \ or / and should I have a trailing slash or not. It can be fussy about these kind of things.
Kulag is offline   Reply With Quote
Old 11-02-2005, 08:43 AM   #9
Chop Chop
 
catacon's Avatar
 
Join Date: Jan 2005
Location: St. Louis, MO
Posts: 1,035
Send a message via AIM to catacon Send a message via Yahoo to catacon
Are you sure that Apache is running? There should be a feather or something by the clock if it's running. Otherwise you might need to go to Start>Programs>Apache>Run or however you have it setup.
catacon is offline   Reply With Quote
Old 11-02-2005, 09:09 AM   #10
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Quote:
Originally Posted by Kulag
@faulkner, how then does this work with scripts that use mysql_connect, etc?
If you are using mysqli, here is your function list: http://www.php.net/manual/en/ref.mysqli.php
Most functions are just like the standard mysql interface, just with an i on the end.

Quote:
Originally Posted by Kulag
Also, should I use \ or / and should I have a trailing slash or not. It can be fussy about these kind of things.
On Windows, I always use \, but I don't think it matters. Using PHP 5.0.5, I do not include the trailing \ in the path variables.
faulkner132 is offline   Reply With Quote
Old 11-02-2005, 09:57 AM   #11
Member (7 bit)
 
Join Date: Sep 2004
Posts: 109
What I mean is, will scripts like phpBB which are designed for PHP/MySQL 4, work properly?
Kulag is offline   Reply With Quote
Old 11-02-2005, 10:34 AM   #12
Staff
Premium Member
 
mairving's Avatar
 
Join Date: Jul 1999
Location: Arlington, TN
Posts: 5,538
Quote:
Originally Posted by Kulag
What I mean is, will scripts like phpBB which are designed for PHP/MySQL 4, work properly?
Iffy.

Quote:
from phpbb
With the recent release of the official version of PHP 5, people and hosts may be switching to the latest PHP version. At this moment, the phpBB Team does not officially support running phpBB on PHP 5, as phpBB2.0.x was not written with PHP 5 in mind. However, many users have reported using it sucessfully on PHP 5 having made a configuration change in PHP to enable support for the deprecated HTTP_*_VARS arrays which is turned off by default in new PHP 5 installations. The relevant configuration option is register_long_arrays and it is decribed in the PHP Manual. phpBB 2.0.x makes use of these arrays in order to maintain backwards compatibility with early versions of PHP 4.x which is part of the original specification.
For this reason we do not support PHP 5 as platform for phpBB. It has been reported working, so you can try it. It's a risk you will be taking though.
mairving is offline   Reply With Quote
Old 11-02-2005, 11:12 AM   #13
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
There is a mod on SourceForge for PHP 5.

http://sourceforge.net/projects/phpbb-php5mod/
faulkner132 is offline   Reply With Quote
Old 11-02-2005, 12:51 PM   #14
Member (7 bit)
 
Join Date: Sep 2004
Posts: 109
Erhem, I guess I wasn't clear on that point. I mean the MySQL side of it. My question is that will using the old "mysql_" instead of "mysqli_" for the methods still work, as I'm sure that phpBB and other code is written with the former, and I have code using the former as well.
Kulag is offline   Reply With Quote
Old 11-02-2005, 01:14 PM   #15
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Yes it will still work. Make sure you have both the mysql and mysqli extensions enabled.
faulkner132 is offline   Reply With Quote
Old 11-02-2005, 07:36 PM   #16
Member (7 bit)
 
Join Date: Sep 2004
Posts: 109
Ok all, thanks for the help, it's working now! I was nearly into pulling hair there, it's been 2-3 weeks I've been working on it.

Side Question: The default MySQL database seems to be InnoDB. How do I change the default to MyISAM?
Kulag is offline   Reply With Quote
Old 11-02-2005, 07:39 PM   #17
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
When you do a create table query, add the following to the end of the query:
ENGINE=MyISAM
faulkner132 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 04:59 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2