Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: newbie needs help |
|
Author |
|
scandalousagent
Joined: 30 Sep 2006 Posts: 1
|
Posted: Sat 30 Sep '06 6:05 Post subject: newbie needs help |
|
|
hi,
m taking a course that teaches about distributed database systems. well the thing is we are using mysql, php and apache to creates web based interfaces for our database.
ok my problem is that i've set myql 4.1 , apache 2.0 and php 4 to work with my tutorials at home and teach myself. everything is running ok i am able to execute php scripts and mysql is running properly. the problem is that when i enter something through my web form i get a error. i've tested this script at the lab it works properly but does not work at home.
here is the error i am getting
Welcome test user to CS2004
Your Student ID is: s100
Your gender is male
Warning: mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client in C:\Program Files\Apache Group\Apache2\htdocs\myfiles\week8\frmStudentProcess2.php on line 24
Could not connect successfully:Client does not support authentication protocol requested by server; consider upgrading MySQL client
and here is my code
<HTML>
<HEAD>
<TITLE>Php form processing </TITLE>
</HEAD>
<BODY>
<?php
$fname =$_REQUEST["fname"];
$lname=$_REQUEST["lname"];
$studentId=$_REQUEST["studentId"];
$gender = $_REQUEST["gender"];
print"Welcome $fname $lname to CS2004 </br>";
print "Your Student ID is: $studentId </br>";
print "Your gender is $gender</br>";
$conn= mysql_connect("localhost","root","crazy4rog");
if (!$conn){
die('Could not connect successfully:'. mysql_error());
}
print "Connect successfully </br>";
$db= mysql_select_db('S11050405',$conn);
if (!$db){
die('Can\'t use S11020305:'. mysql_error());
}
print " database selected";
$sqlStatement="Insert into student(First_name,Last_name,Student_id,Gender)
Values ('$fname', '$lname' , '$studentId' , '$gender')";
$result = mysql_query($sqlStatement, $conn);
if (!result){
die('Invalid query:' . mysql_error());
}
else
print "</br> One record added";
mysql_close($conn);
?>
</BODY >
</HTML >
any suggestions and comments really need them coz i need it to run at home to work on my project |
|
Back to top |
|
CanUuRead
Joined: 18 Sep 2006 Posts: 38
|
Posted: Sat 30 Sep '06 7:23 Post subject: |
|
|
*
1. Change double quotes to single quotes - save doubles for nested quotes - it is just better form; however, it is not absolutely necessary. Here is an example: echo ('<td class="index">');
**2. Use a space after the commas in the connect string - in your mysql_connect statement there are no spaces after the string for server and user. I think this is the reason for your error.
3. The (X)HTML for line-break is <br /> NOT </br>
Try a direct copy of your code corrected into the document on your system (i.e. - eliminate typos):
Code: | $fname =$_REQUEST['fname'];
$lname=$_REQUEST['lname'];
$studentId=$_REQUEST['studentId'];
$gender = $_REQUEST['gender'];
print 'Welcome $fname $lname to CS2004 <br />;
print 'Your Student ID is: $studentId <br />';
print 'Your gender is $gender<br />';
$conn= mysql_connect('localhost', 'root', 'crazy4rog');
if (!$conn){
die('Could not connect successfully:'. mysql_error());
}
print 'Connect successfully <br />'; |
If you still have the protocol error, it is most likely use of localhost versus 127.0.0.1. From the PHP manual:
Quote: | Note:
Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "127.0.0.1" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as mysql.default_host string in your PHP configuration and leave the server field blank.
|
|
|
Back to top |
|
|
|
|
|
|