1

Here is the error message:

Fatal error: Call to undefined function mysql_connect() in /var/www/config.php on line 10

Below is the code:

<?php

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

include('config.php');

// table name
$tbl_name=temp_members_db;

// Random confirmation code
$confirm_code=md5(uniqid(rand()));

// values sent from form
$name=$_POST['name'];
$email=$_POST['email'];
$country=$_POST['country'];

// Insert data into database
$sql="INSERT INTO $tbl_name(confirm_code, name, email, password, country)VALUES('$confirm_code', '$name', '$email', '$password', '$country')";
$result=mysql_query($sql);

// if suceesfully inserted data into database, send confirmation link to email
if($result){

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email;

// Your subject
$subject="Your confirmation link here";

// From
$header="from: your name <your email>";

// Your message
$message="Your Comfirmation link \r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.yourweb.com/confirmation.php?passkey=$confirm_code";

// send email
$sentmail = mail($to,$subject,$message,$header);

}

// if not found
else {
echo "Not found your email in our database";
}

// if your email succesfully sent
if($sentmail){
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else {
echo "Cannot send Confirmation link to your e-mail address";
}

?>php
Bobby
  • 11,167
  • 5
  • 43
  • 68
abhi
  • 19
  • 1
  • 2
  • The error is in config.php, so it would be more useful to see the code from that file. Chances are you're simply calling the mysql_connect function with incorrect parameters. – Coin_op Oct 28 '10 at 15:15
  • you should sanitise user input: http://stackoverflow.com/questions/129677/whats-the-best-method-for-sanitizing-user-input-with-php – Phill Pafford Oct 28 '10 at 15:16
  • @laurencek That would yield a different error message. The issue is that the function isn't defined at all, not that there is an argument miss-match. – user229044 Oct 28 '10 at 15:17
  • What OS are you using. If you're using a Linux flavor, the MySQL support for PHP is a separate package but it's usually really simple to install – Cfreak Oct 28 '10 at 15:18

4 Answers4

4

Your PHP installation was compiled without MySQL support. Either read the instructions for compiling PHP with MySQL, or contact your server administrators and find out why it's unavailable.

If you're using a pre-built bundle like WAMP or XAMPP, update your question with the appropriate tag to receive more specific help.

user229044
  • 222,134
  • 40
  • 319
  • 330
2

look into your php.ini and search for that line:

extension=php_mysql_libmysql.dll

if you have a ; standing infront of the word extension in that very line like this:

;extension=php_mysql_libmysql.dll

remove the ; and restart apache/iis. Then it should work.

If the ; is not in foront of that line or that line doesn't exist then look into your php/ext/ folder if these two files exist:

php_mysql.dll
php_mysql_libmysql.dll

If they do exist then just put this line into yur php.ini and restart apache/iis:

extension=php_mysql_libmysql.dll

Otherwise you'll have to recompile php like my predecessors suggested

ITroubs
  • 10,656
  • 4
  • 26
  • 25
1

You need to install MySQL and the PHP MySQL module.

jojonas
  • 1,503
  • 13
  • 23
0

check this site

http://www.somacon.com/p109.php

basically if im assuming everything is good in the config file there's been some misconfiguration so mysql isn't working properly

Breezer
  • 10,084
  • 6
  • 28
  • 49
  • if you follow the guide step by step you should be good ps. what os are u running your setup on? – Breezer Oct 28 '10 at 15:34
  • I have recompiled the php installation...However now i am getting the below error... – abhi Oct 28 '10 at 15:42
  • Notice: Use of undefined constant temp_members_db - assumed 'temp_members_db' in /var/www/signup_ac.php on line 10 Notice: Undefined index: name in /var/www/signup_ac.php on line 16 Notice: Undefined index: email in /var/www/signup_ac.php on line 17 Notice: Undefined index: country in /var/www/signup_ac.php on line 18 Cannot send Confirmation link to your e-mail addressphp – abhi Oct 28 '10 at 15:42
  • and what php version? the mysql error seemed to be solved now anyways it looks like you have alot of other issues though – Breezer Oct 28 '10 at 15:57
  • well those are just notices add or die (mysql_error ()); after mysql_query($sql) so it looks like this $result=mysql_query($sql) or die (mysql_error ()); – Breezer Oct 28 '10 at 16:15