PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I have the following code in my php file:
$db_hostname = "localhost"; //usually "localhost be default"
$db_username = "myusername"; //your user name
$db_pass = "mypassword"; //the password for your user
$db_name = "mydbname"; //the name of the database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_name);
each time this code executes, i get an error "Fatal error: Call to undefined function mysql_connect() in E:\Website\testconnecttion.php on line 6"
ok i should be past the inability to do this too but i just installed php 5 and apache on my labtop today and i tried going through those instructions and it did nothing. anyone have a tutorial that works? maybe some pointers would be helpful.
i did that but now i'm getting "PHP Startup: Unable to load dynamic library 'c:\php\php_mysql.dll' - The specified procedure could not be found". I move the DLLs from the ext folder to the C:\PHP folder because i kept getting an error that access was denied when the dll's were in the ext subfolder (not sure why).
Still getting the same thing. i tried c:\windows, c:\windows\system, and c:\windows\system32. i also copied all dll under the c:\php folder to windows, system, and system32. PHP works, i can view PHP pages as long as there is no MySql code. Im doing everything on a stand alone machine. I.e. i'm not browsing accross a network to view the PHP pages.
Ok, I changed the extension_dir to point to the exact path c:\php\ext and now I’m getting an error for both MySQL DLL's "PHP Startup: Unable to load dynamic library 'C:\PHP\EXT\PHP_MYSQL.DLL" and "PHP Startup: Unable to load dynamic library 'C:\PHP\EXT\PHP_MYSQLI.DLL". I'm using IIS not Apache so I changed cgi.force_redirect = 0. The comments in the INI file say to turn it off for IIS. Should I use Apache? I just want to test a website on my local machine. I don't want to test on the live server so I was hoping to do all development on 1 machine which will require the machine to serve the web pages.
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
This sux.... I gave up on PHP 5 and went to an older version and i no longer get the DLL errors. however, when i attempt to connect to the DB, I get...
Client does not support authentication protocol requested by server; consider upgrading MySQL clientPHP Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in E:\Web Sites\phptest\testpage.php on line 19.
MySQL version is 4.1.15-nt and i can connect via MySQL Command Line Client.
here is the full source code for testpage.php:
<html>
<head>
<title>Test Page</title>
</head>
<body>
<h1>Test page</h1>
<p>Here is the content...</p>
<?php
//Please set the following variables for your mysql database:
$db_hostname = "localhost"; //usually "localhost be default"
$db_username = "root"; //your user name
$db_pass = "sa"; //the password for your user
$db_name = "phpdb"; //the name of the database
/*MYSQL DATABASE CONNECTION/ TRACKING FUNCTIONS
--------------------------------------*/
// connect to database
$dbh = mysql_connect ($db_hostname, $db_username, $db_pass) or die (mysql_error());
mysql_select_db ($db_name);
?>
</body>
</html>
i would go with apache instead of IIS, i used to use IIS but had alot of trouble but now that i installed apache it works perfectly, no problems and no maintence