PHP version: 5.2.6
MySQL version: 5
----------------------
I'm just learning php and decided to try to make my own version of a tinyurl.com like service. I have a form that collects the url to link to and the name to use for the shortened url then tries to write to a database. This is the code:
echo "Creating new URL ...<BR><BR>";
$query = "INSERT INTO URLs (owner, sourceurl, tagname) VALUES (1, '" . $_REQUEST["sourceurl"] . "', '" . $_REQUEST["newtag"] . "')";
$db = mysql_connect(localhost,"username","password");
mysql_select_db("urls") or die( "Unable to select database");
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
echo "New record inserted with ID ".mysql_insert_id();
mysql_free_result($result);
mysql_close($db);
When I run it, I get:
Fatal error: Call to undefined function mysql_connect() in D:\sites\url\index.php on line 22
Now I did see the post here talking about how to fix it. I followed all the steps... I set the following things in my d:\apps\php\php.ini:
extension_dir = "d:\apps\php"
extension=php_mysqli.dll
I made sure there weren't extra copies of the DLLs floating around. I copied libmysql.dll from d:\apps\mysql\bin to c:\windows\system32. I stopped and restarted IIS, but still no dice. In my PHP folder (d:\apps\php) I have the following files:
install.txt
license.txt
news.txt
php.exe
php.gif
php.ini
php_mbstring.dll
php_mysqli.dll
php5embed.lib
php5isapi.dll
php5ts.dll
When I installed php and mysql, it didn't give me any mysql stuff so I had to download that separately. However, I couldn't find php_mysql.dll. If I understood what I read (and that's not alltogether likely I guess hehe), php_mysqli.dll is the newer version of that so I downloaded it. Do I still need php_mysql.dll as well? When I went to the mysql download link and searched for "php", the only thing I could find was that mysqli. I did a Google for php_mysql.dll and found a dll download site with it, but not coming from mysql or php themselves I am kinda distrustful of it.
PS, phpMyAdmin works fine which really perplexes me because to me, that indicates php and mysql are talking just fine. Ugh!
Thanks!