Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Combining two fields to make a third then insert into DB

Participant ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

I have this script:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {

  $insertSQL = sprintf("INSERT INTO members (Firstname, Surname, `Section`, Login, Password, DefaultPassword, Email) VALUES (%s, %s, %s, %s, %s, %s, %s)",

                       GetSQLValueString($_POST['Firstname'], "text"),

                       GetSQLValueString($_POST['Surname'], "text"),

                       GetSQLValueString($_POST['Section'], "text"),

                       GetSQLValueString($_POST['Login'], "text"),

                       GetSQLValueString($_POST['Password'], "text"),

                       GetSQLValueString($_POST['DefaultPassword'], "text"),

                       GetSQLValueString($_POST['Email'], "text"));

But I want to the value for the Login to be the Firstname + Surname all in lowercase.

I have tried this, but it doesn't work...

$Login = strtolower($_POST['Firstname'] . $_POST['Surname']);

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {

  $insertSQL = sprintf("INSERT INTO members (Firstname, Surname, `Section`, Login, Password, DefaultPassword, Email) VALUES (%s, %s, %s, %s, %s, %s, %s)",

                       GetSQLValueString($_POST['Firstname'], "text"),

                       GetSQLValueString($_POST['Surname'], "text"),

                       GetSQLValueString($_POST['Section'], "text"),

                       $Login, "text",

                       GetSQLValueString($_POST['Password'], "text"),

                       GetSQLValueString($_POST['DefaultPassword'], "text"),

                       GetSQLValueString($_POST['Email'], "text"));

Any ideas what I am doing wrong?

TOPICS
Server side applications

Views

412
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 08, 2011 Sep 08, 2011

Your login line should be:

GetSQLValueString($Login, "text"),

There is only one statement there and you wrote "$Login, "text") which is actually 2 statements.  The ( ) around the $Login text executes it as one statement like the DW code is looking for.

Outside of that it should work.

Votes

Translate
Community Expert ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

Your login line should be:

GetSQLValueString($Login, "text"),

There is only one statement there and you wrote "$Login, "text") which is actually 2 statements.  The ( ) around the $Login text executes it as one statement like the DW code is looking for.

Outside of that it should work.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 08, 2011 Sep 08, 2011

Copy link to clipboard

Copied

LATEST

Perfect thanks!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines