RE: [PHP-INSTALL] Using MySQL with PHP
| From: | Blanton, Bob | Date: | Sat, 27 May 2006 10:21:45 +0000 |
| Subject: | RE: [PHP-INSTALL] Using MySQL with PHP | ||
| Groups: | php.install | ||
| Request: | Send a blank email to php-install+get-17443@lists.php.net to get a copy of this message | ||
Donatas,
When running the phpinfo() I get this below for the mysql section.
I copied the libmysql.dll to the windows directory as some of the
instructions had said. This is the library that is lets php talk to
mysql.
I am running php 5, mysql 5, and apache 1.3. I am successfully using
mysql with the administrator and workbench modules of mysql. I am
trying to perform
a db connection from one of the on-line tutorials and I can't get a db
connection. See my code below
mysql
MySQL Support
enabled
Active Persistent Links
0
Active Links
0
Client API version
5.0.20
Directive
Local Value
Master Value
mysql.allow_persistent
On
On
mysql.connect_timeout
60
60
mysql.default_host
localhost
localhost
mysql.default_password
mysql
mysql
mysql.default_port
3306
3306
mysql.default_socket
no value
no value
mysql.default_user
root
root
mysql.max_links
Unlimited
Unlimited
mysql.max_persistent
Unlimited
Unlimited
mysql.trace_mode
Off
Off
//this works fine
<?php
phpinfo();
?>
//this does not work
<?php
// Connecting, selecting database
echo 'Trying to Connect...'; //last
line executed
$link = mysql_connect('flms', 'userid', 'password') //appears to stop
here
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('flms') or die('Could not select database');
// Performing SQL query
$query = 'SELECT * FROM allow';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
?>
_____
From: Donatas Vyzas [mailto:donatas@viesulas.ktu.lt]
Sent: Saturday, May 27, 2006 2:32 PM
To: php-install@lists.php.net
Subject: Re: [PHP-INSTALL] Using MySQL with PHP
Hi,
MySQL support might be already available in your PHP. You can check that
using phpinfo ( http://www.php.net/manual/en/function.phpinfo.php
). If
you see MySQL section in the output of phpinfo() - you already have
MySQL support, if no - you have to recompile PHP with the following
parameters to your configure script:
--with-mysql[=DIR] Include MySQL support. DIR is the MySQL base
directory
--with-mysql-sock[=DIR] MySQL: Location of the MySQL unix socket
pointer.
If unspecified, the default locations are
searched
Donatas Vyzas
Blanton, Bob wrote:
Hi,
If I want to use MySQL with PHP do I need to re-compile PHP or can I
just adjust the php.ini file to use MySQL?
Thanks in advance.
Bob