Jump to content

Solution of Error in two SELCT box


dearmoawiz

Recommended Posts

just put them in Radio button and write this condition

if(isset($_REQUEST['rd1']))

{

  $fldcategory=$_REQUEST['cboCategory1'];

  $sql ="INSERT INTO tbltextpageseng (cat_id, pagename, preamble, fldtext)

          VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')";

dbQuery($sql);

$sql2 ="INSERT INTO  tbltextpagesswedish (cat_id, pagename, preamble, fldtext)

        VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')";

dbQuery($sql2);

 

}

 

if(isset($_REQUEST['rd2']))

{

 

  $fldcategory=$_REQUEST['cboCategory2'];

  $sql ="INSERT INTO tbltextpageseng (tp_id, pagename, preamble, fldtext)

          VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')";

dbQuery($sql);

$sql2 ="INSERT INTO  tbltextpagesswedish (tp_id, pagename, preamble, fldtext)

        VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')";

dbQuery($sql2);

}

 

Link to comment
Share on other sites

Here is a tidier version of what you have done,

 

<?php
if(isset($_POST['rd1'])) {
   
$fldcategory = mysql_real_escape_string($_POST['cboCategory1']);
   
   $sql ="INSERT INTO tbltextpageseng (cat_id, pagename, preamble, fldtext) 
   VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')";
   
   dbQuery($sql);
   
   $sql ="INSERT INTO  tbltextpagesswedish (cat_id, pagename, preamble, fldtext) 
   VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')";
   
   dbQuery($sql);

}

if(isset($_POST['rd2'])) {

  $fldcategory = mysql_real_escape_string($_POST['cboCategory2']);
  
  $sql ="INSERT INTO tbltextpageseng (tp_id, pagename, preamble, fldtext) 
  VALUES ('$fldcategory', '$txtname', '$txtprembleeng', '$txttexteng')";
  
  dbQuery($sql);
  
  $sql ="INSERT INTO  tbltextpagesswedish (tp_id, pagename, preamble, fldtext) 
  VALUES ('$fldcategory', '$txtname', '$txtprembleswedish', '$txttextswedish')";
  
  dbQuery($sql);
}
?>

 

You should use POST or GET instead of REQUEST in almost all situations, REQUEST data could come from any source.

 

I have got rid of the $sql2 statements because you can just reassign the value $sql after your first dbQuery($sql) function, it won't interfere with the previous statement or execution.

 

I also added some escaping on your POST data because you should always perform some sort of data validation especially if your placing that into an SQL statement.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.