| | |
configure PHP to work with Mysql
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2006
Posts: 12
Reputation:
Solved Threads: 0
Hello everyone,
I have a little bit problem here.I have installed PHP version 4.4.1 and it's working well. I want to connect PHP with MySQl . I have also installed MySQL and it installed successfully.
Inorder to configure PHP to work with Mysql, I did the following changes in the c:\ windows\php.ini .
Uncomment (Removing semicolon) the line that follows extension=php_mysql.dll and extension=php_mbstring.dll .
The next step, i typed the following code in the notepad and saved it htdocs file and named as dbtest.php
<?php
$db_server = "localhost";
$db_user = "root";
$db_pwd = ""; //Enter your root password here.
$db_db = "mysql";
if (!$cnn = mysql_connect($db_server, $db_user, $db_pwd)) {
echo mysql_error();
exit();
}
if (!mysql_select_db($db_db, $cnn)) {
echo mysql_error();
exit();
}
$sql = "select * from help_category";
if (!$res = mysql_query($sql, $cnn)) {
echo mysql_error();
exit();
}
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
$data[] = $row;
}
?>
<html>
<head>
<title>Apache/PHP/MySql Test</title>
</head>
<body>
<h1>Help Categories</h1>
<?
echo "<style>table.dump { font-family:Arial; font-size:8pt; }</style>";
echo "<table class=\"dump\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\">\n";
echo "<tr>";
echo "<th>#</th>";
foreach($data[0] as $key=>$val) {
echo "<th><b>";
echo $key;
echo "</b></th>";
}
echo "</tr>\n";
$row_cnt = 0;
foreach($data as $row) {
$row_cnt++;
echo "<tr align='center'>";
echo "<td>".$row_cnt."</td>";
foreach($row as $val) {
echo "<td>";
echo $val;
echo "</td>";
}
echo"</tr>\n";
}
echo "</table>\n";
?>
</body>
</html>
then i run the dbtest.php in the browser.
I am getting an error msg as " Client does not support authentication protocol requested by server; consider upgrading MySQL client".
where do u think the problem lies?? I want to make sure that am i following the right direction.Am i missing something that still need to done??
I know this may sound basic but i really do not have any clue about this.Can someone help me ,please !!!
Any sugggestion or advice is appreicated.If anybody could help,please let me know.
Thanks in advance..
Cheers,
VG
I have a little bit problem here.I have installed PHP version 4.4.1 and it's working well. I want to connect PHP with MySQl . I have also installed MySQL and it installed successfully.
Inorder to configure PHP to work with Mysql, I did the following changes in the c:\ windows\php.ini .
Uncomment (Removing semicolon) the line that follows extension=php_mysql.dll and extension=php_mbstring.dll .
The next step, i typed the following code in the notepad and saved it htdocs file and named as dbtest.php
<?php
$db_server = "localhost";
$db_user = "root";
$db_pwd = ""; //Enter your root password here.
$db_db = "mysql";
if (!$cnn = mysql_connect($db_server, $db_user, $db_pwd)) {
echo mysql_error();
exit();
}
if (!mysql_select_db($db_db, $cnn)) {
echo mysql_error();
exit();
}
$sql = "select * from help_category";
if (!$res = mysql_query($sql, $cnn)) {
echo mysql_error();
exit();
}
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) {
$data[] = $row;
}
?>
<html>
<head>
<title>Apache/PHP/MySql Test</title>
</head>
<body>
<h1>Help Categories</h1>
<?
echo "<style>table.dump { font-family:Arial; font-size:8pt; }</style>";
echo "<table class=\"dump\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\">\n";
echo "<tr>";
echo "<th>#</th>";
foreach($data[0] as $key=>$val) {
echo "<th><b>";
echo $key;
echo "</b></th>";
}
echo "</tr>\n";
$row_cnt = 0;
foreach($data as $row) {
$row_cnt++;
echo "<tr align='center'>";
echo "<td>".$row_cnt."</td>";
foreach($row as $val) {
echo "<td>";
echo $val;
echo "</td>";
}
echo"</tr>\n";
}
echo "</table>\n";
?>
</body>
</html>
then i run the dbtest.php in the browser.
I am getting an error msg as " Client does not support authentication protocol requested by server; consider upgrading MySQL client".
where do u think the problem lies?? I want to make sure that am i following the right direction.Am i missing something that still need to done??
I know this may sound basic but i really do not have any clue about this.Can someone help me ,please !!!
Any sugggestion or advice is appreicated.If anybody could help,please let me know.
Thanks in advance..
Cheers,
VG
Hey VG,
Upon first glance, I would suggest you try a lot less code for your initial run. A simple echo of "blah, blah" would suffice after you open the connection to the database.
I'm not real familiar with this specific error, but it sounds like it can't find the db. Here are some questions I have:
Best of luck - you're doing good so far!
Upon first glance, I would suggest you try a lot less code for your initial run. A simple echo of "blah, blah" would suffice after you open the connection to the database.
I'm not real familiar with this specific error, but it sounds like it can't find the db. Here are some questions I have:
- Is the database name really mysql? [If so, you might want to consider renaming it]
- Is the db on this same machine or on the net? [If on another machine, your connection needs the address]
Best of luck - you're doing good so far!
![]() |
Similar Threads
- php5 and phpmyadmin?? (PHP)
- Apache (Linux Servers and Apache)
- php mysql help (PHP)
- How many clients can access a PHP script at a time from a MySQL server? (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: database structure - boohooo help me
- Next Thread: Clean database
| Thread Tools | Search this Thread |
Tag cloud for MySQL
1 agplv3 alfresco amazon api artisticlicense aws bizspark camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count crm data database design developer development distinct drupal dui ec2 email enter enterprise error facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip join journalism keyword kickfire laptop legal license licensing linux maintenance mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource operand oracle pdf penelope php priceupdating query referencedesign saas search select sharepoint simpledb sourcecode spotify sql sugarcrm techsupport thunderbird update virtualization





