and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I'm not seeing how to let php know about my mySQL database. I've just set up php5 and mySQL 5 on WinXP, but the phpinfo() test has no mySQL section and a quick test:
<?php
$user="me";
$password="secretbwah";
$database="scstore";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>
produces:
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\htdocs\phpstuff\test1.php on line 12
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
PHP 5 does not load the mysql extension automatically. It loads the mysqli extension instead. You can do one of two things. Either enable the mysql extension in your php.ini file (search these boards for how to do it, it has been described several times before here) or use the mysqli_* family of functions instead of mysql_* functions. I prefer the mysqli_* functions because of their OOP nature, but you can still go with a procedural coding system using them if you prefer. If your app is built with the mysql_* functions, you have no choice but to enable the extensions unless you want to recode the app.
Something's still amiss. I've got the extension uncommented in php.ini, the php_mysql.dll in a PATH-visible place. PHP and Apache2.0 are working, mySQL is working. Again, what am I missing here? I assume the phpinfo() test should contain a section on mySQL and that the test I posted (badly) should have run....
Did you change the appropriate php.ini? phpinfo() tells you which file is used.
Did you restart the apache process after changing that file?
Did you get an error because libmysql.dll wasn't found?
Everything I've read tells me NOT to put stuff in the C:\WINDOWS directory, but apparently (according the the phpinfo() output) it was expecting to see php.ini in C:\WINDOWS--and when I put it there, viola! it works. I'm using the php_mysqli.dll, but what exactly does it do more than php_mysql.dll?
phpinfo() displays the last location php was looking for a ini file.
C.\windows is the very last location on a win32 system + no php.ini -> c:\windows on phpinfo()
see http://de2.php.net/ini
Everything I've read tells me NOT to put stuff in the C:\WINDOWS directory, but apparently (according the the phpinfo() output) it was expecting to see php.ini in C:\WINDOWS--and when I put it there, viola! it works. I'm using the php_mysqli.dll, but what exactly does it do more than php_mysql.dll?
msqli functions are object oriented functions. They are still undocumented in the PHP manual. mysql functions are what PHP4 used (and are still usable by PHP5) but are not object oriented at all.