connect to mysql
am 13.10.2007 23:00:42 von Evan Jou
Hi there,
I have a simple question for you experts here that I've installed
Apache, PHP and MySQL on my Windows machine and set up a test
script(test.php) like what is listed in a book. It's like
@mysql_connect("localhost","root","password")
or die("Could not connect to MySQL server!);
@mysql_select_db("mysql")
or die("Could not select database!);
echo "You're connected to a MySQL database!";
mysql_close();
?>
After I opened the browser and selected the test.php, nothing happened.
I look in the php.ini file and uncomment the line
extension=php_mysql.dll
and change extension_dir = ".\" to extension_dir = "c:\php\ext\"
I also make sure libmysql.dll resides on the Windows system path as
told in the book. Then I restart the computer and open the browser again and
select test.php. Still nothing happens. What did I miss? :(
Thank you in advance for your help.
Evan Jou
Re: connect to mysql
am 13.10.2007 23:05:58 von luiheidsgoeroe
On Sat, 13 Oct 2007 23:00:42 +0200, Evan Jou wrote:
> Hi there,
>
> I have a simple question for you experts here that I've installed
> Apache, PHP and MySQL on my Windows machine and set up a test
> script(test.php) like what is listed in a book. It's like
>
>
> @mysql_connect("localhost","root","password")
> or die("Could not connect to MySQL server!);
> @mysql_select_db("mysql")
> or die("Could not select database!);
> echo "You're connected to a MySQL database!";
> mysql_close();
> ?>
>
> After I opened the browser and selected the test.php, nothing =
> happened.
> I look in the php.ini file and uncomment the line
>
> extension=3Dphp_mysql.dll
>
> and change extension_dir =3D ".\" to extension_dir =3D "c:\php\ext\"
>
> I also make sure libmysql.dll resides on the Windows system path =
as
> told in the book. Then I restart the computer and open the browser aga=
in =
> and
> select test.php. Still nothing happens. What did I miss? :(
>
> Thank you in advance for your help.
First rule of debugging: show, don't supress errors. So remove the @ and=
=
tell us what it sais.
Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have=
=
you edited the php.ini it uses or perhaps another one?
-- =
Rik Wasmus
Re: connect to mysql
am 14.10.2007 00:21:52 von Evan Jou
"Rik Wasmus" wrote in message
news:op.tz5l78hm5bnjuv@metallium.lan...
>First rule of debugging: show, don't supress errors. So remove the @ and
>tell us what it sais.
>
>Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
>you edited the php.ini it uses or perhaps another one?
>--
>Rik Wasmus
remove the @ didn't change it, still nothing shown in the browser.
Oh! phpinfo() show that mysql.default_host, mysql.default_password,
mysql.default_port, mysql.default_socket, mysql.default_user all "no value",
is that the reason for what happened? My php.ini file is located in c:\php\,
it should be the one in use. So what should I do next? Thank you!
Evan Jou
Re: connect to mysql
am 14.10.2007 00:31:52 von luiheidsgoeroe
On Sun, 14 Oct 2007 00:21:52 +0200, Evan Jou wrote:
>
> "Rik Wasmus" wrote in message
> news:op.tz5l78hm5bnjuv@metallium.lan...
>
>> First rule of debugging: show, don't supress errors. So remove the @ and
>> tell us what it sais.
>>
>> Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
>> you edited the php.ini it uses or perhaps another one?
>> --
>> Rik Wasmus
>
> remove the @ didn't change it, still nothing shown in the browser.
>
> Oh! phpinfo() show that mysql.default_host, mysql.default_password,
> mysql.default_port, mysql.default_socket, mysql.default_user all "no
> value",
> is that the reason for what happened? My php.ini file is located in
> c:\php\,
> it should be the one in use. So what should I do next? Thank you!
Hmmmz, enable error_reporting & display_errors in php.ini for your
development server. Most likely it will report a parse error. Use an
editor with syntax highlighting: much easier to spot the missing closing
quotes on line 3:
or die("Could not connect to MySQL server!);
--
Rik Wasmus
Re: connect to mysql
am 14.10.2007 00:53:37 von Evan Jou
"Rik Wasmus" wrote in message
news:op.tz5p7edu5bnjuv@metallium.lan...
> On Sun, 14 Oct 2007 00:21:52 +0200, Evan Jou wrote:
>
>>
>> "Rik Wasmus" wrote in message
>> news:op.tz5l78hm5bnjuv@metallium.lan...
>>
>>> First rule of debugging: show, don't supress errors. So remove the @ and
>>> tell us what it sais.
>>>
>>> Also: what does phpinfo(); tell you? Is the mysql extention loaded? Have
>>> you edited the php.ini it uses or perhaps another one?
>>> --
>>> Rik Wasmus
>>
>> remove the @ didn't change it, still nothing shown in the browser.
>>
>> Oh! phpinfo() show that mysql.default_host, mysql.default_password,
>> mysql.default_port, mysql.default_socket, mysql.default_user all "no
>> value",
>> is that the reason for what happened? My php.ini file is located in
>> c:\php\,
>> it should be the one in use. So what should I do next? Thank you!
>
> Hmmmz, enable error_reporting & display_errors in php.ini for your
> development server. Most likely it will report a parse error. Use an
> editor with syntax highlighting: much easier to spot the missing closing
> quotes on line 3:
> or die("Could not connect to MySQL server!);
> --
> Rik Wasmus
Oh! Thank you! It is a parse error. Now I get the right result. Thank you!
Evan Jou
Re: connect to mysql
am 15.10.2007 00:25:59 von henri
On Sat, 13 Oct 2007 21:00:42 +0000, Evan Jou wrote:
> Hi there,
>
> I have a simple question for you experts here that I've installed
> Apache, PHP and MySQL on my Windows machine and set up a test
> script(test.php) like what is listed in a book. It's like
>
>
> @mysql_connect("localhost","root","password")
> or die("Could not connect to MySQL server!);
> @mysql_select_db("mysql")
> or die("Could not select database!);
> echo "You're connected to a MySQL database!"; mysql_close();
> ?>
>
> After I opened the browser and selected the test.php, nothing
> happened.
> I look in the php.ini file and uncomment the line
>
> extension=php_mysql.dll
>
> and change extension_dir = ".\" to extension_dir = "c:\php\ext\"
>
> I also make sure libmysql.dll resides on the Windows system path as
> told in the book. Then I restart the computer and open the browser again
> and select test.php. Still nothing happens. What did I miss? :(
>
> Thank you in advance for your help.
>
> Evan Jou
your die messages lack the closing quotes.