How do I get my PHP program to connect with MySQL?
SYSV1RUS asked the question:
In datasource I use myodbc.dll in another language to connect to MySQL, I just don’t know how in PHP. The username is ODBC. I currently have PHP running successfully with Xitami. I know MySQL is installed correctly because I’m using it with another programming language.
Related posts:
- PHP programming problem? how to use mysql? wayiran asked the question: I have installed: 1- Windows XP...
- What is HTTPs and do I need to change my PHP program to work with it? mesh2005 asked the question: I have a PHP program that...
- How can i setup SSL on my local machine? im programming in php with mysql as db. on a windows machine? sarmenhbb asked the question: i dont have iis installed so...
- How can I make sure that my customers don’t remove my copyright from my PHP program? havenomercy3 asked the question: I wrote a PHP program and...
- How to fetch a existing rss feed from a website using php. The input for the program must be the website url? karthik mk asked the question: The(php) program input must the...
Filed Under Programming & Design |
Tagged With Datasource, Php Program, Running
Comments
2 Responses to “How do I get my PHP program to connect with MySQL?”
Use the mysql_pconnect function. You can read about it on php.net website.
You need to use the mysql_connect function to connect to the database
here is a sample Php script
$DBhost = “Your-MySQL-servers-IP-or-domainname”;
$DBuser = “your user name”;
$DBpass = “Your Password”;
$DBName = “The Name of the Database”;
$table = “Your Table”;
mysql_connect($DBhost,$DBuser,$DBpass) or die(”Unable toconnect to database”);
@mysql_select_db(”$DBName”) or die(”Unable to select database $DBName”); $sqlquery = “SELECT * FROM $table’”;
$result = mysql_query($sqlquery);
$number = mysql_numrows($result);
where the $result would have your records and the $number has the count of the number of rows returned…