MySQL and PHP5
am 05.09.2008 19:03:19 von Tim
OK, so I see quite a few people having this problem, but I don't yet see a
solution that worked for someone else be something I haven't already tried
or have configured.
I'm getting a Fatal Error when I try to connect to MySQL through PHP.
Fatal error: Call to undefined function mysql_connect()
1.) I have PHP 5.2.6 installed at: C:\php\
2.) I have edited my php.ini so that the extensions_dir is set:
extension_dir = "c:\php\ext"
3.) I have edited my php.ini so that the line for the php_mysql.dll
extension is not commented:
extension=php_mysql.dll
(The only other extension that is enabled is: extension=php_dbg.dll-5.2.1)
4.) I am able to use PHP in Apache 2.2, and I am able to start and use MySQL
through the MySQL CLI.
5.) My php_mysql.dll file is in c:\php\ext
6.) My libmysql.dll is in c:\php
5.) My path statement is:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbe m;C:\Program
Files\Network Associates\PGPNT;C:\MySQL\bin;c:\php\;c:\php\ext\;C:\Program
Files\Microsoft SQL
Server\90\Tools\binn\
However, the results of my phpinfo() do not show a MySQL section (I don't
know if there should be one, I'm new to this). The only place MySQL shows up
is in path variables for the various sections (ie, Apache Environment --
Path variable). And I get the above error message when I try to connect to
my database. Here is the syntax:
$connect = mysql_connect("localhost", "root", "password") or die ("Error
message text.");
Is there something I am missing? I had heard that you need to compile php
yourself if you want MySQL. Is this true, and is this why I don't see a
MySQL section to the phpinfo() output?
PHP 5.2.6 (simple file extract from download into c:\php directory)
Apache 2.2.9
MySQL 5.0.67 (from Windows Install version)
Thanks in advance,
Tim R.
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL and PHP5
am 05.09.2008 19:18:58 von Elizabeth M Smith
> However, the results of my phpinfo() do not show a MySQL section (I don't
> know if there should be one, I'm new to this).
Mysql should show up - one piece of information that I DON'T see that is
probably the most important - is your php.ini being loaded? You should
see a section in the top of your phpinfo() page telling you where it's
looking for php.ini, and which one is being loaded.
If you're using apache the easiest way to MAKE SURE you're getting the
right php.ini discovered and used is to place the following in your
httpd.conf file
PHPIniDir "C:\php\"
and restart your server - if you've altered your PATH recently might be
smart to reboot your machine - windows can be a bit flakey.
> Is there something I am missing? I had heard that you need to compile php
> yourself if you want MySQL.
Only on *nix machines - PHP provides binaries for windows so you don't
have to compile anything.
Thanks,
Elizabeth
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL and PHP5
am 05.09.2008 21:16:07 von Tim
That was it! Thank you so much!
I'm working through a tutorial/book, and the text didn't even mention this!
Wow, good tip for newbies!
Thanks again!
Tim R.
"Elizabeth M Smith" wrote in message
news:DF.42.27431.9E961C84@pb1.pair.com...
>
>> However, the results of my phpinfo() do not show a MySQL section (I don't
>> know if there should be one, I'm new to this).
>
> Mysql should show up - one piece of information that I DON'T see that is
> probably the most important - is your php.ini being loaded? You should
> see a section in the top of your phpinfo() page telling you where it's
> looking for php.ini, and which one is being loaded.
>
> If you're using apache the easiest way to MAKE SURE you're getting the
> right php.ini discovered and used is to place the following in your
> httpd.conf file
>
> PHPIniDir "C:\php\"
>
> and restart your server - if you've altered your PATH recently might be
> smart to reboot your machine - windows can be a bit flakey.
>
>> Is there something I am missing? I had heard that you need to compile php
>> yourself if you want MySQL.
>
> Only on *nix machines - PHP provides binaries for windows so you don't
> have to compile anything.
>
> Thanks,
> Elizabeth
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL and PHP5
am 06.09.2008 06:46:46 von Tim
I spoke to soon. Your tip did manage to get the MySQL section to show up in
the output of phpinfo(), and the connect command doesn't throw an error
anymore, but now I get the same Undefined Function error on the line to
create a db:
mysql_create_db("dbName") or die(mysql_error());
Why would it be letting my connect command pass without an error, but this
line generate the error?
""Tim"" wrote in message
news:57.D3.23120.27581C84@pb1.pair.com...
> That was it! Thank you so much!
>
> I'm working through a tutorial/book, and the text didn't even mention
> this!
>
> Wow, good tip for newbies!
>
> Thanks again!
>
> Tim R.
> "Elizabeth M Smith" wrote in message
> news:DF.42.27431.9E961C84@pb1.pair.com...
>>
>>> However, the results of my phpinfo() do not show a MySQL section (I
>>> don't
>>> know if there should be one, I'm new to this).
>>
>> Mysql should show up - one piece of information that I DON'T see that is
>> probably the most important - is your php.ini being loaded? You should
>> see a section in the top of your phpinfo() page telling you where it's
>> looking for php.ini, and which one is being loaded.
>>
>> If you're using apache the easiest way to MAKE SURE you're getting the
>> right php.ini discovered and used is to place the following in your
>> httpd.conf file
>>
>> PHPIniDir "C:\php\"
>>
>> and restart your server - if you've altered your PATH recently might be
>> smart to reboot your machine - windows can be a bit flakey.
>>
>>> Is there something I am missing? I had heard that you need to compile
>>> php
>>> yourself if you want MySQL.
>>
>> Only on *nix machines - PHP provides binaries for windows so you don't
>> have to compile anything.
>>
>> Thanks,
>> Elizabeth
>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL and PHP5
am 06.09.2008 15:35:04 von Elizabeth M Smith
Tim wrote:
> I spoke to soon. Your tip did manage to get the MySQL section to show up in
> the output of phpinfo(), and the connect command doesn't throw an error
> anymore, but now I get the same Undefined Function error on the line to
> create a db:
>
> mysql_create_db("dbName") or die(mysql_error());
>
> Why would it be letting my connect command pass without an error, but this
> line generate the error?
>
Because mysql_create_db doesn't exist for mysql client libs above 4.0 -
read the documentation at php.net please
If you want to create a db, do a CREATE DATABASE query
Thanks,
Elizabeth Smith
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL and PHP5
am 07.09.2008 04:54:35 von Tim
Thanks, again, Elizabeth! Makes sense. I hadn't started the documentation
yet because I was trying to get a working understanding of things first by
going through a tutorial. I realize now that my tutorial was for an earlier
version of PHP and MySQL, so things like this are going to be a problem.
Anyway, thanks for setting me straight.
Tim R.
"Elizabeth M Smith" wrote in message
news:2E.F5.12247.EE682C84@pb1.pair.com...
> Tim wrote:
>> I spoke to soon. Your tip did manage to get the MySQL section to show up
>> in
>> the output of phpinfo(), and the connect command doesn't throw an error
>> anymore, but now I get the same Undefined Function error on the line to
>> create a db:
>>
>> mysql_create_db("dbName") or die(mysql_error());
>>
>> Why would it be letting my connect command pass without an error, but
>> this
>> line generate the error?
>>
>
> Because mysql_create_db doesn't exist for mysql client libs above 4.0 -
> read the documentation at php.net please
>
> If you want to create a db, do a CREATE DATABASE query
>
> Thanks,
> Elizabeth Smith
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php