problem in connecting to mysql from php

problem in connecting to mysql from php

am 13.06.2011 14:08:08 von C0mf0rtably Numb

--0016364275e3be53d304a596c552
Content-Type: text/plain; charset=ISO-8859-1

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 :

$db = new MySQLi('localhost', 'root', 'Password123', 'test');
$sql = 'SELECT * FROM a123';
$result = $db->query($sql);

while($row = $result->fetch_object()) {
echo '

' . $row->name . '
';
}

$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

--0016364275e3be53d304a596c552--

Re: problem in connecting to mysql from php

am 13.06.2011 14:26:13 von C0mf0rtably Numb

--002354470e8471817b04a597063a
Content-Type: text/plain; charset=ISO-8859-1

Okay. I tried using that too. If I run this:
$link = mysql_connect('localhost', 'root',

'Password123');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

I get the error: *Fatal error*: Call to undefined function mysql_connect()
in *C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\a.php* on
line *2

*I think there is something wrong with my configuration.

On Mon, Jun 13, 2011 at 6:00 PM, mrfroasty wrote:

> Your error message is about class not found.That means there is no class
> named "MySQLi".Please use a textbook with online manual
> http://www.php.net/manual/en/ref.mysql.php
>
> On 06/13/2011 02:08 PM, C0mf0rtably Numb 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 :
> >
> > > > $db = new MySQLi('localhost', 'root', 'Password123', 'test');
> > $sql = 'SELECT * FROM a123';
> > $result = $db->query($sql);
> >
> > while($row = $result->fetch_object()) {
> > echo '

' . $row->name . '
';
> > }
> >
> > $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
> >
>
>
> --
> Extra details:
> OSS:Gentoo Linux
> profile:x86
> Hardware:msi geforce 8600GT asus p5k-se
> location:/home/muhsin
> language(s):C/C++,PHP,SQL,HTML
> Typo:40WPM
> url:http://www.mzalendo.net
> url:http://www.zanbytes.com
>
>
>
>

--002354470e8471817b04a597063a--

Re: problem in connecting to mysql from php

am 13.06.2011 14:30:29 von muhsin

Your error message is about class not found.That means there is no class
named "MySQLi".Please use a textbook with online manual
http://www.php.net/manual/en/ref.mysql.php

On 06/13/2011 02:08 PM, C0mf0rtably Numb 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 :
>
> > $db = new MySQLi('localhost', 'root', 'Password123', 'test');
> $sql = 'SELECT * FROM a123';
> $result = $db->query($sql);
>
> while($row = $result->fetch_object()) {
> echo '

' . $row->name . '
';
> }
>
> $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
>


--
Extra details:
OSS:Gentoo Linux
profile:x86
Hardware:msi geforce 8600GT asus p5k-se
location:/home/muhsin
language(s):C/C++,PHP,SQL,HTML
Typo:40WPM
url:http://www.mzalendo.net
url:http://www.zanbytes.com




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

Re: problem in connecting to mysql from php

am 13.06.2011 14:35:40 von Richard Quadling

On 13 June 2011 13:26, C0mf0rtably Numb <08.kushal@gmail.com> wrote:
> Okay. I tried using that too. If I run this:
> > $link =3D mysql_connect('localhost', 'root',
>
> 'Password123');
> if (!$link) {
>    die('Could not connect: ' . mysql_error());
> }
> echo 'Connected successfully';
> mysql_close($link);
> ?>
>
> I get the error: *Fatal error*: Call to undefined function mysql_connect(=
)
> in *C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\a.php* o=
n
> line *2
>
> *I think there is something wrong with my configuration.
>
> On Mon, Jun 13, 2011 at 6:00 PM, mrfroasty wrote:
>
>> Your error message is about class not found.That means there is no class
>> named "MySQLi".Please use a textbook with online manual
>> http://www.php.net/manual/en/ref.mysql.php
>>
>> On 06/13/2011 02:08 PM, C0mf0rtably Numb 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=3Dphp_mysqli.dll
>> >
>> > In spite of doing the above when I try to run the following :
>> >
>> > >> > $db =3D new MySQLi('localhost', 'root', 'Password123', 'test');
>> > $sql =3D 'SELECT * FROM a123';
>> > $result =3D $db->query($sql);
>> >
>> > while($row =3D $result->fetch_object()) {
>> >     echo '

' . $row->name . '
';
>> > }
>> >
>> > $db->close();
>> > ?>
>> >
>> > I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Progra=
m
>> > 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
>> >
>>
>>
>> --
>> Extra details:
>> OSS:Gentoo Linux
>> profile:x86
>> Hardware:msi geforce 8600GT asus p5k-se
>> location:/home/muhsin
>> language(s):C/C++,PHP,SQL,HTML
>> Typo:40WPM
>> url:http://www.mzalendo.net
>> url:http://www.zanbytes.com
>>
>>
>>
>>
>

Copying the files to windows\system ... what files? Where were you
told to do this?

Normally the extension files you need for PHP are in C:\PHP5\ext (or PHPx).

I've never copied a single file into my Windows folder for PHP.



--=20
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

Re: problem in connecting to mysql from php

am 13.06.2011 15:12:54 von C0mf0rtably Numb

--002354470e84639a2104a597adde
Content-Type: text/plain; charset=ISO-8859-1

Any help?

On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb <08.kushal@gmail.com>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 :
>
> > $db = new MySQLi('localhost', 'root', 'Password123', 'test');
> $sql = 'SELECT * FROM a123';
> $result = $db->query($sql);
>
> while($row = $result->fetch_object()) {
> echo '

' . $row->name . '
';
> }
>
> $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
>

--002354470e84639a2104a597adde--

Re: Re: problem in connecting to mysql from php

am 13.06.2011 16:06:43 von Richard Quadling

On 13 June 2011 14:12, C0mf0rtably Numb <08.kushal@gmail.com> wrote:
> Any help?
>
> On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb <08.kushal@gmail.com>wr=
ote:
>
>> Hello everyone,
>>
>> I am in the process of learning php and I was trying to connect to a mys=
ql
>> database on my own computer(localhost). I have done the following as
>> prerequisites:
>>
>> copied the dll files in system32
>> removed the semicolon(;) from extension=3Dphp_mysqli.dll
>>
>> In spite of doing the above when I try to run the following :
>>
>> >> $db =3D new MySQLi('localhost', 'root', 'Password123', 'test');
>> $sql =3D 'SELECT * FROM a123';
>> $result =3D $db->query($sql);
>>
>> while($row =3D $result->fetch_object()) {
>>     echo '

' . $row->name . '
';
>> }
>>
>> $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.

--=20
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

Re: Re: problem in connecting to mysql from php

am 13.06.2011 16:55:57 von Richard Quadling

On 13 June 2011 15:28, C0mf0rtably Numb <08.kushal@gmail.com> wrote:
> My php and apache are working fine together. I was doing good with php an=
d
> 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
> wrote:
>>
>> On 13 June 2011 14:12, C0mf0rtably Numb <08.kushal@gmail.com> wrote:
>> > Any help?
>> >
>> > On Mon, Jun 13, 2011 at 5:38 PM, C0mf0rtably Numb
>> > <08.kushal@gmail.com>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=3Dphp_mysqli.dll
>> >>
>> >> In spite of doing the above when I try to run the following :
>> >>
>> >> >> >> $db =3D new MySQLi('localhost', 'root', 'Password123', 'test');
>> >> $sql =3D 'SELECT * FROM a123';
>> >> $result =3D $db->query($sql);
>> >>
>> >> while($row =3D $result->fetch_object()) {
>> >>     echo '

' . $row->name . '
';
>> >> }
>> >>
>> >> $db->close();
>> >> ?>
>> >>
>> >> I get the error: *Fatal error*: Class 'MySQLi' not found in *C:\Progr=
am
>> >> 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.


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=3D

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=3Dphp_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


--=20
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

Re: problem in connecting to mysql from php

am 14.06.2011 13:07:41 von Niel Archer

> 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

You should NOT need to move the .dll at all. There is a
setting in the ini which tells PHP where to look for extensions and that
should have pointed to the original location. Hence, removing the
semicolon should be the only part necessary.

> In spite of doing the above when I try to run the following :
>
> > $db = new MySQLi('localhost', 'root', 'Password123', 'test');
> $sql = 'SELECT * FROM a123';
> $result = $db->query($sql);
>
> while($row = $result->fetch_object()) {
> echo '

' . $row->name . '
';
> }
>
> $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



--
Niel Archer
niel.archer (at) blueyonder.co.uk


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

Re: problem in connecting to mysql from php

am 14.06.2011 13:09:59 von joefazee

--00504502f53ea59b5004a5aa13e4
Content-Type: text/plain; charset=ISO-8859-1

create a file with phpinfo() and make sure mysqli is listed in the loaded
modules

On Tue, Jun 14, 2011 at 12:07 PM, Niel Archer 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
>
> You should NOT need to move the .dll at all. There is a
> setting in the ini which tells PHP where to look for extensions and that
> should have pointed to the original location. Hence, removing the
> semicolon should be the only part necessary.
>
> > In spite of doing the above when I try to run the following :
> >
> > > > $db = new MySQLi('localhost', 'root', 'Password123', 'test');
> > $sql = 'SELECT * FROM a123';
> > $result = $db->query($sql);
> >
> > while($row = $result->fetch_object()) {
> > echo '

' . $row->name . '
';
> > }
> >
> > $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
>
>
>
> --
> Niel Archer
> niel.archer (at) blueyonder.co.uk
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
*Share with free mind!*
Join I.T professionals on http://www.tuwana.com
For Web development and design http://abahjoseph.com
Follow me on Twitter http://twitter.com/freefazee
Mobile: *+2348066100671*

--00504502f53ea59b5004a5aa13e4--