mysql_query: INSERT does not insert anything at all in database
Results 1 to 5 of 5

Thread: mysql_query: INSERT does not insert anything at all in database

  1. #1
    Junior Member
    Join Date
    Oct 2017
    Posts
    2

    mysql_query: INSERT does not insert anything at all in database

    My Sql Code Is :

    -- phpMyAdmin SQL Dump
    -- version 4.7.3
    -- https://www.phpmyadmin.net/
    --
    -- Host: localhost:3306
    -- Generation Time: Oct 05, 2017 at 07:59 PM
    -- Server version: 5.5.56-cll-lve
    -- PHP Version: 5.6.30

    SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    SET AUTOCOMMIT = 0;
    START TRANSACTION;
    SET time_zone = "+00:00";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8mb4 */;

    --
    -- Database: `devadiga_matrimonial`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `users`
    --

    CREATE TABLE `users` (
    `UserID` bigint(20) NOT NULL,
    `LoginID` varchar(250) DEFAULT NULL,
    `EmailAddress` varchar(250) DEFAULT NULL,
    `Password` varchar(250) DEFAULT NULL,
    `Gender` varchar(250) DEFAULT NULL,
    `BirthDate` varchar(250) DEFAULT NULL,
    `BirthMonth` varchar(250) DEFAULT NULL,
    `BirthYear` varchar(250) DEFAULT NULL,
    `dobstatus` int(11) NOT NULL DEFAULT '0',
    `Age` int(11) NOT NULL DEFAULT '0',
    `ReligionID` int(11) NOT NULL DEFAULT '0',
    `CountryID` int(11) NOT NULL DEFAULT '0',
    `ConfirmationCode` text,
    `Status` int(11) NOT NULL DEFAULT '0',
    `ApprovalStatus` int(11) NOT NULL DEFAULT '0',
    `GoldMember` int(11) NOT NULL DEFAULT '0',
    `AddedDate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
    `GoldMemberDate` datetime DEFAULT '0000-00-00 00:00:00'
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Indexes for dumped tables
    --

    --
    -- Indexes for table `users`
    --
    ALTER TABLE `users`
    ADD PRIMARY KEY (`UserID`);

    --
    -- AUTO_INCREMENT for dumped tables
    --

    --
    -- AUTO_INCREMENT for table `users`
    --
    ALTER TABLE `users`
    MODIFY `UserID` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;COMMIT;

    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

  2. #2
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Contact Unit "Coping Mechanism"
    Posts
    22,518
    What are you trying to insert? Into which table? What is the code you're trying to use to do it? What error messages if any are you getting? You're not telling us anything beyond "It doesn't work" and that's not enough to tell you anything except "sorry to hear that".
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #3
    Junior Member
    Join Date
    Oct 2017
    Posts
    2
    When am going to fill a user register page, its all filled data will not insert in sql database, for a reason which confirmation code link is sent on users mail, on click it will not activate and it will give the message like :" Oooops! Your Registration has not been successfully Completed... Please follow the Registration Confirmation Link propely to complete your registration..".

    my webpage register link is : http://devadigaportal.co.in/register.php

    page config code:

    <?PHP
    session_start();
    include("connection.php");

    $sqlsettings = "SELECT * from admin";
    $resultsettings = mysql_query($sqlsettings);
    $rowsettings = mysql_fetch_array($resultsettings);

    $referral_code = $_REQUEST['referral_code'];


    if($referral_code)
    {
    $user_sql = "SELECT LoginID,email FROM users WHERE referral_code='$referral_code'";
    $user_result = mysql_query($user_sql,$conn);
    $row = mysql_fetch_row($user_result);
    $main_userid = $row[0];
    $main_user_email = $row[1];
    }

    $emailMsg = "";
    if($_POST['continue']=="true")
    {
    $sql = "SELECT * FROM users WHERE EmailAddress='".mysql_escape_string($_POST['email'])."'";
    $result = mysql_query($sql,$conn);

    $sql2 = "SELECT * FROM users WHERE LoginID='".mysql_escape_string($_POST['login'])."'";
    $result2 = mysql_query($sql2,$conn);

    if($_REQUEST['dobstatus']=="true")
    {
    $dobstatus = 1;
    }
    else
    {
    $dobstatus = 0;
    }

    $age = GetAge(mysql_escape_string($_POST['year']), mysql_escape_string($_POST['month']), mysql_escape_string($_POST['day']));

    if (@mysql_num_rows($result)!=0){
    $emailMsg = "<font color='#FF0000'><strong>* This E-Mail Address is ALREADY REGISTRED </strong></font>";
    }



    else if(@mysql_num_rows($result2)!=0){
    $emailMsg = "<font color='#FF0000'><strong>* This Profile ID is ALREADY REGISTRED</strong></font>";
    }

    else if($age < 18 || $age > 60)
    {
    $emailMsg = "<font color='#FF0000'><strong>You cannot be register with us, if your age is less than 18 or greater than 60</strong></font>";
    }

    else{
    if(!$referral_code)
    {
    $referral_new_code = md5(uniqid(rand(), true));
    $referral_string = "<br/> <br/>Please send the following referral link to your friends so that your profile gets activated <a href='".$rowsettings['url']."/register.php?referral_code=$referral_new_code'>Click here to Register</a>";
    }
    else
    {
    $referral_new_code = '';
    $referral_string = '';
    //Finding the main user userID
    $user_sql = "SELECT LoginID FROM users WHERE referral_code='$referral_code'";
    $user_result = mysql_query($user_sql,$conn);
    $row = mysql_fetch_row($user_result);
    $main_userid = $row[0];
    $insert_sql = "INSERT INTO users_referral(UserID, newuserID, recorddate)
    VALUES ('".$main_userid."', '".mysql_escape_string($_POST['login'])."', NOW())";
    //echo $insert_sql;
    $result_sql = mysql_query($insert_sql);
    }
    //exit;
    $insert = "insert into users(LoginID, EmailAddress, Password, Gender, BirthDate, BirthMonth, BirthYear, ReligionID, CountryID, ConfirmationCode, referral_code, AddedDate, Age, dobstatus)
    VALUES (
    '".mysql_escape_string($_POST['login'])."',
    '".mysql_escape_string($_POST['email'])."',
    '".mysql_escape_string($_POST['password1'])."',
    '".mysql_escape_string($_POST['gender'])."',
    '".mysql_escape_string($_POST['day'])."',
    '".mysql_escape_string($_POST['month'])."',
    '".mysql_escape_string($_POST['year'])."',
    ".$_POST['community'].",
    ".$_POST['countryofresidence'].",
    '".md5(mysql_escape_string($_POST['email']))."',
    '".$referral_new_code."',
    NOW(),
    '".$age."',
    ".$dobstatus."
    )";
    $resultt = mysql_query($insert);

    if($rowsettings['smtpstatus'] == 1)
    {
    $email_layout = "<br><br><img src='".$rowsettings['url']."/images/matrimonial-logo-sm.gif'><br><table border='0' width='100%'><tr><Td colspan='2' background='".$rowsettings['url']."/images/footer_seprator.gif' height='2'></Td></tr></table><br><br><br>Dear Member,<br><br>Your Registration with ".$rowsettings['ScriptName']." has been successfully completed, but you need to confirm your registration first by clicking the below link. If you cannot access the confirmation page by clicking at this link, then kindly copy paste this link into your browser's address bar and press enter. After you will confirm your registration, You will be able to create your profile.<br><br><br>click below to confirm your registration:<br><br><a href='".$rowsettings['url']."/registration_confirmation.php?confirm=".md5(mysql_escape_string($_POST['email']))."'>".$rowsettings['url']."/registration_confirmation.php?confirm=".md5(mysql_escape_string($_POST['email']))."</a>".$referral_string;



    require("phpmailer/class.phpmailer.php");
    $mail = new PHPMailer();

    $mail->IsSMTP();
    $mail->Host = $rowsettings['smtp'];
    $mail->Port = $rowsettings['port'];
    $mail->SMTPAuth = true;
    $mail->Username = $rowsettings['AdminEmail'];
    $mail->Password = $rowsettings['AdminEmailPassword'];

    $mail->From = $rowsettings['AdminEmail'];
    $mail->FromName = $rowsettings['ScriptName'];
    $mail->AddAddress($_POST['email']);


    $mail->WordWrap = 50; // set word wrap to 50 characters
    $mail->IsHTML(true); // set email format to HTML

    $mail->Subject = "Action Required to Confirm Registration";
    $mail->Body = $email_layout;
    $mail->Send();

    if($referral_code)
    {
    $new_user_mail= "<br><br><img src='".$rowsettings['url']."/images/matrimonial-logo-sm.gif'><br><table border='0' width='100%'><tr><Td colspan='2' background='".$rowsettings['url']."/images/footer_seprator.gif' height='2'></Td></tr></table><br><br><br>Dear Member,<br><br>Your friend ".$_POST['login']." Joined your group";

    $newuser= new PHPMailer();
    $newuser->IsSMTP();
    $newuser->Host = $rowsettings['smtp'];
    $newuser->Port = $rowsettings['port'];
    $newuser->SMTPAuth = true;
    $newuser->Username = $rowsettings['AdminEmail'];
    $newuser->Password = $rowsettings['AdminEmailPassword'];

    $newuser->From = $rowsettings['AdminEmail'];
    $newuser->FromName = $rowsettings['ScriptName'];
    $newuser->AddAddress($mail_user_email);


    $newuser->WordWrap = 50; // set word wrap to 50 characters
    $newuser->IsHTML(true); // set email format to HTML

    $newuser->Subject = "New user ".$_POST['login']." to your group";
    $newuser->Body = $new_user_mail;
    $newuser->Send();

    }
    //echo $email_layout;
    }
    else
    {
    $to=$_POST['email'];
    $email_layout = "<br><br><img src='".$rowsettings['url']."/images/matrimonial-logo-sm.gif'><br><table border='0' width='100%'><tr><Td colspan='2' background='".$rowsettings['url']."/images/footer_seprator.gif' height='2'></Td></tr></table><br><br><br>Dear Member,<br><br>Your Registration with ".$rowsettings['ScriptName']." has been successfully completed, but you need to confirm your registration first by clicking the below link. If you cannot access the confirmation page by clicking at this link, then kindly copy paste this link into your browser's address bar and press enter. After you will confirm your registration, You will be able to create your profile.<br><br><br>click below to confirm your registration:<br><br><a href='".$rowsettings['url']."/registration_confirmation.php?confirm=".md5(mysql_escape_string($_POST['email']))."'>".$rowsettings['url']."/registration_confirmation.php?confirm=".md5(mysql_escape_string($_POST['email']))."</a>".$referral_string;
    $subject="Action Required to Confirm Registration";
    $description=$email_layout;
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: ".$rowsettings['ScriptName']." <".$rowsettings['AdminEmail'].">\r\n";

    $res=@mail($to,$subject,$description,$headers);
    }
    // echo $email_layout;
    header("Location: register2.php?email=".mysql_escape_string($_POST['email']));
    }
    }
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title><?PHP echo $rowsettings['ScriptName']?>- Register</title>

    Please find if any mistake in coding and let me know the details for the same.
    Looking your kind reply
    Thanking you sir.

  4. #4
    Junior Member benanamen's Avatar
    Join Date
    Oct 2015
    Posts
    3
    This is obsolete and dangerous code that will not work at all in current versions of PDO. There is no fixing this code. It is complete junk. Stop copy/pasting random code off the net and learn PDO and prepared statements. Here is a link to get you going. https://phpdelusions.net/pdo

  5. #5
    Junior Member benanamen's Avatar
    Join Date
    Oct 2015
    Posts
    3
    Typo Correction: This is obsolete and dangerous code that will not work at all in current versions of PHP.

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •