Sunday, April 29, 2007

Testing MySQL: Installing MySQL, configuring php.ini and removing deprecated tags.

Previously, I was testing MySQL and could not get a page to load at all. I was receiving the error message:
PHP Fatal error: Call to undefined function mysql_connect()

I added a couple extensions in php.ini and just now found a new error message appeared.
PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll'
- The specified module could not be found.\r\n in Unknown on line 0

It was not looking in the right directory, rather I never specified where to look. Now I have tried setting the extension directory with extension_dir = "c:\php\ext" in php.ini, I have received a new error message. (I'm getting somewhere!)
PHP Fatal error: Call to undefined function mysql_create_db() in
C:\\myserver\\test_mysql.php on line 33

I have a feeling I'll be doing a lot of php.ini configuring. After searching for the previous error in google I came across a list of emails in the archives of Neohapsis.com where someone mentioned that mysql_create_db() is deprecated. So much for using older tutorials. I searched for mysql_create-db() deprecated on Google and came across a comment on the manual that says mysql_query() should be used instead.

I went back into my test file and changed the two instances of mysql_create_db to mysql_query and finally something appears on the page. Unfortunately the variables are not appearing to be saved. Oh error looooog!,
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
result resource in C:\\myserver\\test_mysql.php on line 66

Fetch doesn't have anything to fetch so it is reporting an error. I think I'll find someone elses file to test MySQL with (ignores the little voice saying "Make one yourself you lazy oaf")

No comments: