如何在 MySQL 语句中包含 PHP 变量
P粉738248522
2023-08-23 21:12:18
[PHP讨论组]
<p>我正在尝试在内容表中插入值。如果我在 VALUES 中没有 PHP 变量,它就可以正常工作。当我将变量 <code>$type</code> 放入 <code>VALUES</code> 中时,这不起作用。我做错了什么?</p>
<pre class="brush:php;toolbar:false;">$type = 'testing';
mysql_query("INSERT INTO contents (type, reporter, description)
VALUES($type, 'john', 'whatever')");</pre>
<p><br /></p>