www.webdeveloper.com
Results 1 to 4 of 4

Thread: Database field names changes - can't seem to change these in my PHP file

  1. #1
    Join Date
    Jan 2003
    Location
    UK
    Posts
    267

    Database field names changes - can't seem to change these in my PHP file

    Hi,

    I have changed two field names on my MySQL database:

    Phone is now PrimaryPhone
    Email is now PrimaryEmail

    However I have tried to change these like-for-like on the control panel for my website (see attached file) but the form stops working correctly.

    The email doesn't validate and it's starting to allow me to add merchants with a name but not the required email address.

    Please are you able to help?admin.txt

  2. #2
    Join Date
    Apr 2012
    Posts
    38
    Code:
    			if($_POST["Name".$i]!="")
    			{
    				$Qry  = "Name='".cleanQuery($_POST["Name".$i])."'";
    				$Qry .= ",Phone='".cleanQuery($_POST["Phone".$i])."'";
    				$Qry .= ",Email='".cleanQuery($_POST["Email".$i])."'";
    				$Qry .= ",Privacy='".cleanQuery($_POST["Privacy".$i])."'";
    				mysql_query("Insert Into Merchants Set $Qry");
    			}
    You should edit Phone to PrimaryPhone and Email to PrimaryEmail

  3. #3
    Join Date
    Jan 2003
    Location
    UK
    Posts
    267
    I tried this but it won't save the phone number and email address:

    if($_POST["Name".$i]!="")
    {
    $Qry = "Name='".cleanQuery($_POST["Name".$i])."'";
    $Qry .= ",Phone='".cleanQuery($_POST["PrimaryPhone".$i])."'";
    $Qry .= ",Email='".cleanQuery($_POST["PrimaryEmail".$i])."'";
    $Qry .= ",Privacy='".cleanQuery($_POST["PrimaryEmailPrivacy".$i])."'";
    mysql_query("Insert Into Merchants Set $Qry");
    }

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    898
    Shouldn't those individual lines creating the query pieces use the NEW field names instead of the old ones?
    Looks like you're going to run:

    "insert into merchants set Phone=(value of $_POST["PrimaryPhone".$i])"

    instead of

    "insert into merchants set PrimaryPhone=(value of $_POST["PrimaryPhone".$i])"


    Just curious but why all this logic to build a simple insert query?

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



Recent Articles