Jump to content

PHP Script Error


DeathDream

Recommended Posts

I have my PHP Script fine, the form to register fine, MySQL seems fine, but I'm getting this error:

 

Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in /home/www/l2enigma.freehostia.com/acc.php on line 8
Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client

 

Is there something i have to edit in MySQL or the script?

I'm Using this to have users create accounts on my users through a web page, and the last hard step for the website is getting the account registration to work. I would very much appreciate it if anyone could help me.

 

Account Page is Here: http://l2enigma.freehostia.com/account.php

 

My PHP Script is this:

(All Classified Info is Hidden with xxx)

 

<?php
//set host, username and password for MySQL
$dbhost = "xx.xxx.xx.xxx";
$dbuser = "xxxxxxx";
$dbpass = "xxxxxxxxxx";

//connect to MySQL or return an error
$conn = mysql_connect("$dbhost", "$dbuser", "$dbpass")
or die('Could not connect: ' . mysql_error());

//set database name
$dbname = "xxxxx";

//select database or return an error
$dbselect = mysql_select_db("$dbname") 
or die ('Could not select database');

//get username and password info from the form, protecting against SQL injection
$pass = mysql_real_escape_string($_POST["pass"]);
$confirm = mysql_real_escape_string($_POST["confirm"]);
$user = mysql_real_escape_string($_POST["name"]);

//validate user input
if(!preg_match('/^[a-zA-Z0-9]{5,20}$/',$user)) {
die ('Error: Usernames can only contain alphanumeric characters and must be between 5 and 20 characters in length.');
}

if(!preg_match('/^[a-zA-Z0-9]{5,20}$/',$pass)) {
die ('Error: Passwords can only contain alphanumeric characters and must be between 5 and 20 characters in length.');
}

if($pass != $confirm) {
die ('Error: Passwords do not match.');
}

//make sure user doesn't already exist and if it doesn't, add new record to the database
$result = mysql_query("SELECT login FROM accounts WHERE login='$user'");

if(mysql_num_rows($result)>0) {
die ('Error: Username already exists.');
}else{
mysql_query("INSERT INTO accounts (login, password, access_level) VALUES ('".$_POST['name']."', '".base64_encode(pack('H*', sha1($_POST['pass'])))."', 0)")
or die ('Error: ' . mysql_error());
}

//report successful registration
echo "Account created successfully.";

//close MySQL connection
mysql_close();

?> 

 

 

Link to comment
https://forums.phpfreaks.com/topic/132791-php-script-error/
Share on other sites

where is the mysql server you are connecting to?

is it with free hostia or your own?

 

when looking over the free hostia website i can't see what version they use.

do you know the version of server you are connecting to?

do you know the version of the client connection mysql library is being used?

 

Scott.

Link to comment
https://forums.phpfreaks.com/topic/132791-php-script-error/#findComment-690611
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.