Results 1 to 2 of 2

Thread: [RESOLVED] Mysql/PHP insert & CONCAT

  1. #1
    Join Date
    Jun 2009
    Chi town. IL68 ICAO code home airport, literally.

    resolved [RESOLVED] Mysql/PHP insert & CONCAT

    Hello all, Im building a login script for some people, and I would like somone to have a once over this script thus far. I know I still havent check the emails nor a few other things i need to do. I will get back to those. But for now can anyone have a looky and see if it looks good. They only issue I think here is the CONCAT function. I am not sure I scripted that part right.

    PHP Code:
    //connects to databases

    //Create var names
    $first_name mysql_real_escape_string($_POST['F_Name']);
    $last_name mysql_real_escape_string($_POST['L_Name']);
    $phone_number_1 mysql_real_escape_string($_POST['Pnumber1']);
    $phone_number_2 mysql_real_escape_string($_POST['Pnumber2']);
    $address mysql_real_escape_string($_POST['Address']);
    $state mysql_real_escape_string($_POST['State']);
    $city mysql_real_escape_string($_POST['City']);
    $zip_code mysql_real_escape_string($_POST['Zip']);
    $email_1 mysql_real_escape_string($_POST['Email1']);
    $email_2 mysql_real_escape_string($_POST['Email2']);
    $username mysql_real_escape_string($_POST['Uname']);
    $password_1 mysql_real_escape_string($_POST['Pass']);
    $jed mysql_real_escape_string($_POST['Jednostka']);
    $dob mysql_real_escape_string($_POST['DOB']);
    $stopien mysql_real_escape_string($_POST['Stopein']);
    $funk mysql_real_escape_string($_POST['FUNK']);
    $hasher = new PasswordHash(8True);
    $password $hasher->HashPassword($password_1);
    $ENC =MD5($password_1);
    $ERRmsg "";
    //Checks if any feilds were left empty and creates an error message to display
    if(empty($first_name)) $ERRmsg .= 'You did not enter a First Name!  Pleaase go back and try again! \n';
    $last_name)) $ERRmsg .= 'You did not enter a Last Name!  Please go back and try again! \n';
    $phone_number_1)) $ERRmsg .= 'You did not enter a Phone Number!  Please go back and try again! \n';
    $address)) $ERRmsg .= 'You did not enter an Address!  Please go back and try again! \n';
    $state)) $ERRmsg .= 'You did not choose a State!  Please go back and try again! \n':
    $city)) $ERRmsg .= 'You did not enter a City!  Please go back and try again! \n';
    $zip_code$ERRmsg .= 'You did not enter a Zip Code.  Please go back and try again! \n';
    $email_1$ERRmsg .= 'You did not enter a Email.  Please go back and try again! \n';
    $email_2$ERRmsg .= 'You did not re-enter you Email.  Please go back and try again! \n';
    $username$ERRmsg .= 'You did not enter a Username.  Please go back and try again! \n';
    $password_1$ERRmsg .= 'You did not enter a password!  Please go back and try again! \n';
    $jed$ERRmsg .= 'You did not choose a Jednostka!  Please go back and try again! \n';
    $dob$ERRmsg .= 'You did not enter a Date of Birth!  Please go back and try again! \n';
    $stopien$ERRmsg .= 'You did not choose a Stopien!  Please go back and try again! \n';
    $funk$ERRmsg .= 'You did not enter a Funkcjia!  Please go back and try again! \n';
    //Checks to see if error message is empty, if empty does rest of code
    if(empty($ERRmsg) {
    //pick databases and tables
                            //creates query for warta database
    $wdp "INSERT INTO Users_tbl (`ID`, `F_NAME`, `L_Name`, `P_number1`, `P_number2`, `Address`, `City`, `State`, `Zip`, `Email`, `username`, `password`, `Jednostka`, `Funkcjia`, `High`, `Active`, `user_registered`, `user_email`, `user_login`, `user_pass`, `user_nicename`, `display_name`, `groupID`, `prefs_list_item`)
                                VALUES('', '
    $first_name', '$last_name', '$phone_number_1', $phone_number_2', '$address', '$state', '$zip_code', '$email_1', '$username', '$password', '$jed', '$funk', '$jed', '0', '', '$email_1', '$username', '$password', '."=CONCAT("$First_name" ' ' "$Last_name")".', '."=CONCAT("$First_name" ' ' "$Last_name")".', '', '')";
                    else {

    For want of a nail...the horseshoe was lost. For want of a horseshoe, the steed was lost. For want of a steed...the message was not delivered. For want of an undelivered message.....the war was lost.

  2. #2
    Join Date
    Aug 2004
    Looks like there is a mismatch between the number of columns listed in your insert statement and the number of values (24 vs. 23), so you need to figure out what was left out. As far as the CONCAT() goes, since it's a MySQL function, not a PHP function, it needs to be part of the SQL string literal (and I recommend using multiple lines to keep things easier to debug):
    PHP Code:
            $wdp "
                INSERT INTO Users_tbl (
                ) VALUES(
    $password', -- you left out the leading quote here
    $First_name', ' ', '$Last_name'), 
    $First_name', ' ', '$Last_name'),

    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 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
HTML5 Development Center