Jump to content

[SOLVED] Help wih error code


pnkgirl25

Recommended Posts

Warning: mysql_query(): Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2) in /home/content/f/o/c/focusevents/html/signup_ac.php on line 20

 

Warning: mysql_query(): A link to the server could not be established in /home/content/f/o/c/focusevents/html/signup_ac.php on line 20

Not found your email in our databaseCannot send Confirmation link to your e-mail address

 

<?
$host="******"; // Host name 
$username="******"; // Mysql username 
$password="******"; // Mysql password 
$db_name="****"; // Database name

// table name 
$tbl_name="temp_members_db";

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

// values sent from form 
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$weddingdate=$_POST['weddingdate'];
$username=$_POST['username'];
$password=$_POST['password'];

// Insert data into database 
$sql="INSERT INTO $tbl_name(confirm_code, firstname, lastname, email, weddingdate, username, password)VALUES('$confirm_code', '$firstname', '$lastname', '$email', '$weddingdate', '$username', '$password')";
$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 One Spot confirmation link";

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

// Your message
$message="Thank you for joining One Stop\r\n";
$message="To activate your account please click on the link bellow\r\n";
$message.="Click on this link to activate your account \r\n";
$message.="http://www.yourweb.com/confirm.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";
}

?>

 

Mod edit: db connection variable removed for security.

Link to comment
https://forums.phpfreaks.com/topic/66536-solved-help-wih-error-code/
Share on other sites

You haven't made a connection to the database, you have specified the $host,$username,$password and $db_name (which you should have blanked out, but oh well) but havent connected. After those four variables you need:

 

<?php

$con = mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db($db_name) or die(mysql_error());

?>

 

mysql_connect and mysql_select_db

 

Hope that helps,

 

~ Chocopi

If you'd like to do it in a factored way:

 

replace this:

 

$host="*************"; // Host name

$username="***********r"; // Mysql username

$password="*********"; // Mysql password

$db_name="***********"; // Database name

 

with this:

 

mysql_select_db("************", mysql_connect("**********.*******.net", "***********", "************"));

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.