Page 1 of 1

Newbie php-mySQL setup prob

Posted: Fri Aug 25, 2006 1:22 pm
by Olwe
Everah | Please use

Code: Select all

,

Code: Select all

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:

Code: Select all

<?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

I know I'm missing something very basic here....


Everah | Please use

Code: Select all

,

Code: Select all

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]

Posted: Fri Aug 25, 2006 1:49 pm
by volka
Probably yes ;)

http://de2.php.net/mysql might help.
Installation on Windows Systems...
PHP 5+

Posted: Fri Aug 25, 2006 2:01 pm
by RobertGonzalez
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.

Posted: Fri Aug 25, 2006 3:11 pm
by Olwe
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....

Posted: Fri Aug 25, 2006 3:13 pm
by volka
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?

Posted: Fri Aug 25, 2006 3:18 pm
by RobertGonzalez
Do you have the right MySQL Client API? Can you run phpMyAdmin?

Posted: Fri Aug 25, 2006 3:39 pm
by Olwe
Det jeht doch nischt!

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?

Posted: Fri Aug 25, 2006 4:10 pm
by volka
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

i have this problem, too

Posted: Sun Aug 27, 2006 10:56 pm
by crispgm
and i did as http://de2.php.net/mysql
but it doesn‘t work

Posted: Sun Aug 27, 2006 11:38 pm
by RobertGonzalez
Olwe wrote:Det jeht doch nischt!

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.

Posted: Mon Aug 28, 2006 12:44 am
by volka
Everah wrote:They are still undocumented in the PHP manual.
uh? 8O

Posted: Mon Aug 28, 2006 9:02 am
by RobertGonzalez
Sorry, that was retarded of me. Versioning is not documented in the manual. My mistake. Please disregard that last, doofus level comment.