Re: [PHP] Connecting to MySql with PHP

Re: [PHP] Connecting to MySql with PHP

am 04.10.2010 23:21:23 von Ashley Sheridan

------=_Part_3_1286227283857
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: base64
Content-Disposition: inline

SGF2ZSB5b3UgaW5zdGFsbGVkIHRoZSBwaHAgbXlzcWwgbW9kdWxlPyBCYXNp Y2FsbHksIGl0IHRl
bGxzIHBocCBob3cgdG8gY29ubmVjdCB0byBteXNxbC4KClRoaXMgcXVlc3Rp b24gaGFzIGNvbWUg
dXAgYSBmZXcgdGltZXMgdGhpcyB3ZWVrLCBoYXZlIHlvdSB0cmllZCBpbnN0 YWxsaW5nIHNvbWV0
aGluZyBsaWtlIHhhbXBwIG9yIGVhc3lwaHAgcmF0aGVyIHRoYW4gdGhlIGlu ZGl2aWR1YWwgc29m
dHdhcmUgY29tcG9uZW50czogQXBhY2hlLCBwaHAgJiBteXNxbC4KClRoYW5r cywKQXNoCmh0dHA6
Ly93d3cuYXNobGV5c2hlcmlkYW4uY28udWsKCi0tLS0tIFJlcGx5IG1lc3Nh Z2UgLS0tLS0KRnJv
bTogInN1ZWFuZGFudCIgPGhvbGxhbmRzYXRob21lQHRpc2NhbGkuY28udWs+ CkRhdGU6IE1vbiwg
T2N0IDQsIDIwMTAgMjI6MDgKU3ViamVjdDogW1BIUF0gQ29ubmVjdGluZyB0 byBNeVNxbCB3aXRo
IFBIUApUbzogPHBocC1nZW5lcmFsQGxpc3RzLnBocC5uZXQ+CgpJIGFtIHJ1 bm5pbmcgUEhQIDUu
My4zLCB3aXRoIEFwYWNoZSAyLjAgSGFuZGxlciBhbmQgTXlTcWwgU2VydmVy IDUuMS4gICBNeSBP
UyBpcyBWaXN0YSBIb21lIFByZW1pdW0gMzIgYml0IHdpdGggU1AyLgoKTXlT cWwgd29ya3MgZmlu
ZSBmcm9tIHRoZSBjb21tYW5kIHByb21wdCwgQXBhY2hlIGlzIHJ1bm5pbmcg YW5kIFBIUCB3b3Jr
cy4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04 von muhsin

The code execute fine on my LAMP server, but I am wondering does
localhost really works on Windows ?As this on MAC you need to actually
tell a complete path.On MAC with Zend-Server I had to mention something
like /var/tmp/mysql ....

Anyways, by looking on the error it might be mysql server is not
accessed...Can you actually access the myql server with anything else
like phpmyadmin or cli ?

Gr
mrfroasty




On 10/04/2010 11:21 PM, ash@ashleysheridan.co.uk wrote:
> Have you installed the php mysql module? Basically, it tells php how to connect to mysql.
>
> This question has come up a few times this week, have you tried installing something like xampp or easyphp rather than the individual software components: Apache, php & mysql.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
> ----- Reply message -----
> From: "sueandant"
> Date: Mon, Oct 4, 2010 22:08
> Subject: [PHP] Connecting to MySql with PHP
> To:
>
> I am running PHP 5.3.3, with Apache 2.0 Handler and MySql Server 5.1. My OS is Vista Home Premium 32 bit with SP2.
>
> MySql works fine from the command prompt, Apache is running and PHP works. But I cannot access the mysqli classes. This simple program:
>
> >
> $mysqli = new mysqli("localhost", "root", "######", "testDB"); #I've deliberately obliterated the password
>
> if (mysqli_connect_errno()) {
> printf("Connect failed: %s\n", mysqli_connect_error());
> exit();
> } else {
> printf("Host information: %s\n", mysqli_get_host_info($mysqli));
> }
> ?>
>
> produces this error message:
>
> Warning: mysqli::mysqli() [mysqli.mysqli]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Apache\htdocs\mysqlconnect.php on line 3
>
> Warning: mysqli::mysqli() [mysqli.mysqli]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Apache\htdocs\mysqlconnect.php on line 3
>
> Fatal error: Maximum execution time of 30 seconds exceeded in C:\Apache\htdocs\mysqlconnect.php on line 3
>
> I guess PHP cannot find the mysqli classes. I've checked the phpinfo() output and discovered :
>
> Configuration File (php.ini) Path C:\Windows
> Loaded Configuration File C:\PHP\php.ini
>
>
> I don't know if this ok. I've tried changing the location of the loaded file to C:\Windows\php.ini, but to no avail, and I don't know how to change the location of the config file.
>
> I am obviously doing something wrong, but I don't know what. Can anyone help?
>
> Ironically, everything worked perfectly before I upgraded to PHP 5.3.3!


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




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