How to use Insert into query for joomla 2.5?

前端 未结 3 1274
天涯浪人
天涯浪人 2021-01-16 06:00

I am using query for joomla.

$query = \"INSERT INTO \'#__demo\'( \'id\', \'fname\', \'mname\', \'lname\' ) VALUES ( \'$val\', \'$post[\'fname\']\', \'$post[\         


        
3条回答
  •  深忆病人
    2021-01-16 06:20

    There are two mistakes on your query.

    1. You haven't escaped your quotes in $_POST values.

      '$post['fname']'
      //     ^ here and other places
      
    2. You are using single quotes ' to represent tables and field names.

       .. INTO '#__demo'( ..       
      //       ^ here and other places
      

    Now after removing all such problems. You query becomes:

    $query = "INSERT INTO `#__demo` ( `id`, `fname`, `mname`, `lname` ) VALUES ( '$val', '$post[fname]', '$post[Mname]', '$post[Lname]' );";
    

提交回复
热议问题