Re: [PHP-DB] Query stopping after 2 records?

[email protected] (Chris)
Newsgroups php.db
Message-ID <[email protected]>
Hawx wrote:
> On Mon, 27 Apr 2009 07:19:23 -0700, "Miller, Terion"
> <[email protected]> wrote:
>> I need help/advice figuring out why my query dies after 2 records.  Here
> is
>> the query:
>>
>>          // Build your INSERT statement here
>>       
>>
>>  $query = "INSERT into `warrants` (wid, name, age, warrant, bond,
> wnumber,
>> crime) VALUES (";
>>     $query .= " '$wid', '$name', '$age', '$warrant',
>> '$bond', '$wnumber', '$crime' )";
>>         $wid = mysql_insert_id();
>>
>> // run query
>>     
>>  mysql_query($query) or die ("GRRRRRRR");
>>
>>
>>   echo $query;
>>
>> It inserts two records and dies half way thru the 3rd?
>> Thanks in advance for clues to fix this.
>> T.Miller
> 
> Make sure any apostrophes in the variable strings are escaped correctly.
> Check the addslashes() function.

No - use the mysql_real_escape_string function. Addslashes is the wrong 
thing to use here.

-- 
Postgresql & php tutorials
http://www.designmagick.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.