Re: Re: problem in connecting to mysql from php

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 13 June 2011 15:28, C0mf0rtably Numb <08.kushal@xxxxxxxxx> wrote:
> My php and apache are working fine together. I was doing good with php and
> apache until I decided to work with mysql. I will have a look at all the
> links you provided and see if gives me a solution. Thanks.
>
> On Mon, Jun 13, 2011 at 7:36 PM, Richard Quadling <rquadling@xxxxxxxxx>
> wrote:
>>
>> On 13 June 2011 14:12, C0mf0rtably Numb <08.kushal@xxxxxxxxx> wrote:
>> > Any help?
>> >
>> > On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb
>> > <08.kushal@xxxxxxxxx>wrote:
>> >
>> >> Hello everyone,
>> >>
>> >> I am in the process of learning php and I was trying to connect to a
>> >> mysql
>> >> database on my own computer(localhost). I have done the following as
>> >> prerequisites:
>> >>
>> >> copied the dll files in system32
>> >> removed the semicolon(;) from extension=php_mysqli.dll
>> >>
>> >> In spite of doing the above when I try to run the following :
>> >>
>> >> <?php
>> >> $db = new MySQLi('localhost', 'root', 'Password123', 'test');
>> >> $sql = 'SELECT * FROM a123';
>> >> $result = $db->query($sql);
>> >>
>> >> while($row = $result->fetch_object()) {
>> >> Â Â echo '<div>' . $row->name . '</div>';
>> >> }
>> >>
>> >> $db->close();
>> >> ?>
>> >>
>> >> I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Program
>> >> Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on line *2
>> >>
>> >> *Please guide me as to how can I get rid of this error?
>> >>
>> >> Regards,
>> >> Kushal
>> >>
>> >
>>
>> If you are able to reset your system and then read through the manual
>> Windows installation documentation at
>> http://uk.php.net/manual/en/install.windows.manual.php
>>
>> Personally, I'd change the path to C:\PHP5,x,y, where the x and y are
>> the complete version numbers (PHP5.3.6) , but that's me. I then use
>> Junction to create C:\PHP5 which maps to C:\PHP5.3.6.
>>
>> Junction is like a link at least in terms of how I use it.
>>
>> I'd also take a good look at
>> http://uk.php.net/manual/en/install.windows.commandline.php and
>> http://uk.php.net/manual/en/install.windows.apache2.php
>>
>> One covers making better use of PHP from the command line and the
>> other deals with getting things working with Apache.
>>
>> And an issue. Please make sure you use the right version of PHP for
>> the version of Apache you are using. If you are using a VC9 build
>> Apache (say from ApacheLounge or something like that), then you can
>> use a VC9 build of PHP.
>>
>> If you are using an VC6 build, then you must use a VC6 build of PHP
>> and that limits you to PHP5.2 (PHP5.2.17 is the latest there). I use
>> IIS with FastCGI so I use a NTS (non thread safe) build. I don't know
>> which sort of threading model you need for Apache (hopefully it is
>> mentioned in one of the Apache related pages).
>>
>> And with regard to the php.ini file, you can make it available by many
>> different means.
>>
>> I use the registry. This is documented at
>> http://uk.php.net/manual/en/configuration.file.php
>>
>> Look at ...
>>
>> "As of PHP 5.2.0, the location of the php.ini file can be set for
>> different versions of PHP. The following registry keys are examined in
>> order: [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y.z],
>> [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x.y] and
>> [HKEY_LOCAL_MACHINE\SOFTWARE\PHP\x], where x, y and z mean the PHP
>> major, minor and release versions. If there is a value for IniFilePath
>> in these keys, then the first one found will be used as the location
>> of the php.ini (Windows only).
>>
>> [HKEY_LOCAL_MACHINE\SOFTWARE\PHP], value of IniFilePath (Windows only)."
>>
>> And, I think finally, if you need different php.ini files for apache
>> and the command line, ...
>>
>> "If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
>> e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.
>> SAPI name can be determined by php_sapi_name()."
>>
>> Richard.
>>
>> --
>> Richard Quadling
>> Twitter : EE : Zend : PHPDoc
>> @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
>
>

If you have PHP working, then create the following file and save it as
info.php in the docroot of your website.


<?php
phpinfo();
?>


When you load this, you'll see a list of settings being reported. The
important one in this instance is the value for the loaded
configuration file near the top of the page.

That's the INI file you are needing to edit.

Open it in your favourite text editor and look for the lines starting with ...

extension=

You need to choose which mysql driver you need - there are several.

mysql
myslqi
pdo_mysql


If you are using a modern mysql, then mysqli is the one to use. So,
add a line to the INI file that looks like ...

extension=php_mysqli.dll

It may already exist with a ; in front of it. Remove the ;

Save the ini.

Restart Apache.

You MAY need to reboot Windows.

Now load up the phpinfo() page again.

Do you see mysqli content?

If you do, then at that stage, the mysqli extension is loaded and you
can start using it : http://uk.php.net/manual/en/book.mysqli.php


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux