Re: can't access mysql from a php script
| From: | php at karsites dot net | Date: | Wed, 22 Mar 2006 23:49:59 +0000 |
| Subject: | Re: can't access mysql from a php script | ||
| References: | 1 2 3 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-17226@lists.php.net to get a copy of this message | ||
OK, forget the last mail - lets start again.
Does the output from phpinfo() say you have the mysql module
loaded?
If yes, you may need to tell php to speak to mysql on the
socket that mysql is listening on, so php can connect to the
mysql database.
You may need to alter the following directive in your
php.ini file.
; Default socket name for local MySQL connects. If empty,
; uses the built-in MySQL defaults.
mysql.default_socket = /var/lib/mysql/mysql.sock
set the above value to the same path and filename that mysql
is using. That should get things working ok.
Keith
On Thu, 23 Mar 2006, Jahislove wrote:
> To: php-install@lists.php.net
> From: Jahislove <jahislove@wanadoo.fr>
> Subject: Re: [PHP-INSTALL] can't access mysql from a php script
>
> Sorry , i don't understand what you mean :
>
> i installed php with a NetBSD package:
> # cd /usr/pkgsrc/www/ap-php
> # ls -l
> drwxr-xr-x 2 root wheel 512 Mar 2 19:08 CVS
> -rw-r--r-- 1 root wheel 368 Nov 4 2004 DESCR
> -rw-r--r-- 1 root wheel 821 Mar 30 2005 MESSAGE
> -rw-r--r-- 1 root wheel 909 Feb 5 23:11 Makefile
> -rw-r--r-- 1 root wheel 108 Nov 4 2004 PLIST
> # make install clean
>
> and i have no idea where to remove --without-mysql and where to add the
> ./configure...
>
> php@karsites.net a écrit :
> > remove --without-mysql:
> >
> > You need to explicitly enable mysql like this:
> >
> > ./configure
> > --with-apxs2=/usr/local/apache-2.2.0/bin/apxs'
> > --prefix=/usr/local/php-5.1.2'
> > --with-mysql=shared,/downloads/mysql/bin/mysql-standard-5.0.18-linux-i686'
> >
> > --with-mysqli=shared,/downloads/mysql/bin/mysql-standard-5.0.18-linux-i686/bin/mysql_config'
> > --with-mysql-sock=/var/lib/mysql/mysql.sock'
> > --with-mhash'
> > --enable-shared=yes'
> > --enable-all=shared'
> >
> > and anything else you want to compile php with.
> >
> > Alter the paths to suite your environment.
> >
> > Keith
> >
> >
> > In theory, theory and practice are the same;
> > in practice they are not.
> >
> > To unsubscribe from this list, please see detailed instructions
> > already posted at:
> >
> >
> > http://marc.theaimsgroup.com/?l=php-install&m=114138567814319&w=2
> >
> > On Wed, 22 Mar 2006, Jahislove wrote:
> >
> > > To: php-install@lists.php.net
> > > From: Jahislove <jahislove@wanadoo.fr>
> > > Subject: [PHP-INSTALL] can't access mysql from a php script
> > >
> > > hello all ,
> > >
> > > i am under NetBSD 3.0
> > > and i have installed apache/php/mysql as described on this wiki
> > >
> > > http://wiki.onetbsd.org/index.php/How_to_install_a_LAMP_Server
> > >
> > > /usr/pkgsrc/www/apache2
> > > /usr/pkgsrc/databases/mysql5-server
> > > /usr/pkgsrc/www/ap-php (Installing the PHP Module for
> > > Apache)
> > >
> > > apache work fine
> > > php work fine
> > > mysql work fine
> > >
> > > but it seem that i can't access database from a php script
> > >
> > > this little script (test.php) return only "test1" and not "test2"
> > > without any error
> > >
> > > <?php
> > > $host = "localhost";
> > > $login = "compteur";
> > > $password = "xxxxxx";
> > > $database = "compteur";
> > > $table = "nb_connect";
> > >
> > > echo "test1";
> > >
> > > $db = mysql_connect($host, $login, $password)
> > > or die("Impossible de se connecter : ".mysql_error());
> > >
> > > echo "test2";
> > >
> > > mysql_select_db($database,$db);
> > >
> > > mysql_query("INSERT INTO $table
> > > VALUES('','blabla','30')")
> > > or die("error : ".mysql_error());
> > >
> > > $update = mysql_insert_id();
> > > mysql_close($db);
> > > ?>
> > >
> > >
> > > a phpinfo() return :
> > > Configure Command './configure' '--without-mysql'
> > > '--without-iconv'
> > > '--disable-posix' '--with-config-file-path=/usr/pkg/etc'
> > > '--with-exec-dir=/usr/pkg/libexec/php4' '--with-regex=system'
> > > '--enable-memory-limit' '--enable-track-vars'
> > > '--enable-ipv6'
> > > '--with-openssl=/usr' '--with-apxs2=/usr/pkg/sbin/apxs'
> > > '--prefix=/usr/pkg' '--host=mipsel--netbsd'
> > > '--mandir=/usr/pkg/man'
> > >
> > > any idea of the problem?
> > > is it possible that the problem come from '--without-mysql' ?
> > > and so how can i install that?
> >
>
>