Jump to content

Help! Fatal error: Call to undefined function mysql_select_database()


Ruko

Recommended Posts

I need help. I just made my registration script and when I hit the submit button, I get this error:

 

Fatal error: Call to undefined function mysql_select_database() in /home/ruko/chat-planet/flash-planet/do_reg.php on line 10

 

Line 10:

$db = mysql_select_database($dbname, $connection);

Im kinda new to php and i got the script from a tutorial.

 

Well, hopefully my response addressed your problem, mysql_select_database isn't a function (unless you define it as one).

 

However, PHP does have the built in function mysql_select_db:

http://php.net/manual/en/function.mysql-select-db.php

fixed it and works! thanks man. Another (minor) problem in the registration script is when I hit the submit button with the form incompleted, i see this:

 

Please fill in all the fields!Thanks for registering with us!

 

Code (where the problem is):

 

if($name == false || $pass == false || $pass_conf == false || $email == false){
echo "Please fill in all the fields!"; };
if($pass != $pass_conf){
echo "Passwords do not match!";
} else {
$connection = mysql_connect($host, $dbuser, $dbpass);
$db = mysql_select_db($dbname, $connection);
$sql =  "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)";
$result = mysql_query($sql);
echo "Thanks for registering with us!";
};
?>

I wrote it all out. Its a really messy script. Maybe you guys can fix all this?

fixed it and works! thanks man. Another (minor) problem in the registration script is when I hit the submit button with the form incompleted, i see this:

 

Please fill in all the fields!Thanks for registering with us!

 

Code (where the problem is):

 

if($name == false || $pass == false || $pass_conf == false || $email == false){
echo "Please fill in all the fields!"; };
if($pass != $pass_conf){
echo "Passwords do not match!";
} else {
//rename submit to Form Submits name
if(isset($_POST['submit'])){
$connection = mysql_connect($host, $dbuser, $dbpass);
$db = mysql_select_db($dbname, $connection);
$sql =  "INSERT INTO user (username,password,email,ip) VALUES ($name, $pass, $email, $ip)";
$result = mysql_query($sql);
echo "Thanks for registering with us!";
}
};
?>

I wrote it all out. Its a really messy script. Maybe you guys can fix all this?

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.