<?xml version="1.0" encoding="windows-1252"?>
<node id="7550" title="Why does my query work on the command line, but fail in my browser?" created="2000-04-13 21:46:33" updated="2005-07-30 10:50:37">
<type id="1857">
categorized question</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
This is often a quoting issue.  For example, your query may look like this:
&lt;code&gt;INSERT member (last, first)
VALUES(NULL, "chromatic");&lt;/code&gt; and your script like this:
&lt;code&gt;$last = "NULL";
$first = "chromatic";
$query = 
qq {
	INSERT member (last, first)
	VALUES ($last, $first)
};
$rows = $dbh-&gt;do($query);&lt;/code&gt;
Printing your $query would reveal that $last and $first are not being quoted.
&lt;p&gt;
The solution is to use something like this:
&lt;code&gt;$last = $dbh-&gt;quote("NULL");
$first = $dbh-&gt;quote("chromatic");&lt;/code&gt;
or this:
&lt;code&gt;$query = 
qq {
	INSERT member (last, first)
	VALUES (?, ?)
};
$rows = $dbh-&gt;do($query, undef, $last, $first);&lt;/code&gt;</field>
<field name="parent_node">
1831</field>
</data>
</node>
