Note that there are some explanatory texts on larger screens.

plurals
  1. POError connecting to database in mysql using "mysqli", Where am I wrong?
    text
    copied!<p>I have a User registration page, in which a user submits credentials and it stores to database. Next task is supplying user an activation-cum-verification link to users mail inbox, such a way that user clicks the link and the activation code pertaining to user must update to NULL and makes his account active, so that he can log in.</p> <p>My code : FILE 1 : mysite.php</p> <pre><code>if($_REQUEST['Itemid']==209) { $email_id=$_REQUEST['email']; if($email_id != '') { //This if condition will submit the data into the database if (!isset($_POST['submit'])) { HTML_mysite::newuser($subdom_names, $section_ord, $status); } else { //$confirm_code=md5(uniqid(rand())); $hostname = 'localhost'; //the parameters for the club database $sqluser = 'root'; $sqlpass = ''; $dbName = 'club'; // Get connection to MySQL $link = @mysql_pconnect($hostname, $sqluser, $sqlpass) or die('Unable to connect to database'); // Select the database @mysql_select_db($dbName) or die('Unable to select database'); //check if the email id already exists. $query_usrchk = "SELECT EML, PSW FROM visitor WHERE EML = '$_POST[email]'"; //Data is being inserted in visitor table $result_usrchk = mysql_query($query_usrchk); $num_rows_usrchk = mysql_num_rows($result_usrchk); //update if email/password if correct if($num_rows_usrchk == 1) // Checking if email id is present in the database..,if yes, status will be displayed. { $status="This Email address is already registered with us"; HTML_mysite::newuser($subdom_names, $section_ord, $status); } else { $confirm_code=md5(uniqid(rand())); $query_usrinsert = "INSERT INTO visitor(`confirm_code`,`EML`, `PSW`, `PFN`, `FFN`, `GD1`, `AID`, `FA1`, `FP1`, `CT1`, `CN1`, `FT1`, `MOB`, `CID`) VALUES ('$confirm_code','$_POST[email]','$_POST[pswd]', '$_POST[name]', '$_POST[organisation]', '$_POST[department]', '$_POST[designation]', '$_POST[address]', '$_POST[city]', '$_POST[zipcode]', '$_POST[country]', '$_POST[phonenumber]', '$_POST[mobile]', '$_POST[special]')"; $result_usrinsert = mysql_query($query_usrinsert); } } </code></pre> <p>FILE 2:confirm.php</p> <pre><code>&lt;? include('config1.php'); $passkey=$_GET['passkey']; if(isset($passkey)){ $query_activate_account = "UPDATE visitor SET confirm_code=NULL WHERE(EML ='$email' AND confirm_code='$passkey')LIMIT 1"; $result_activate_account = mysqli_query($link,$query_activate_account); if (mysqli_affected_rows($link) == 1) //if update query was successfull { echo "Your account is now active. You may now login here : http://*********/club/login/login.php"; } else echo "Not activated"; } ?&gt; </code></pre> <p>FILE 3: config1.php</p> <pre><code>&lt;?php $hostname='localhost'; $sqluser='root'; $sqlpass=''; $dbName='club'; $link=@mysqli_connect($hostname,$sqluser,$sqlpass) or die('Error Connecting'); @mysqli_select_db($dbName,$link) or die('Unable to connect'); ?&gt; </code></pre> <p>My output when clicked on the link is Unable to connect!!</p> <p>Please help me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload