如何在joomla 2.5中使用插入到查询中? [英] How to use Insert into query for joomla 2.5?
本文介绍了如何在joomla 2.5中使用插入到查询中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用joomla查询.
I am using query for joomla.
$query = "INSERT INTO '#__demo'( 'id', 'fname', 'mname', 'lname' ) VALUES ( '$val', '$post['fname']', '$post['Mname']', '$post['Lname']' );";
出现错误
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
推荐答案
您的查询有两个错误.
-
您没有在
$_POST
值中使用引号引起来.
You haven't escaped your quotes in
$_POST
values.
'$post['fname']'
// ^ here and other places
您正在使用单引号'
表示表和字段名称.
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]' );";
这篇关于如何在joomla 2.5中使用插入到查询中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文