Re: ADODB Insert Question (Syntax)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Graham Anderson wrote:
Wow.  I feel really dumb.
I thought (incorrectly) that the surrounding quotes would screw with the variables in the ADODB's INSERT statement.

many thanks
G

On Aug 7, 2007, at 2:06 PM, Uber Wannabe wrote:

-----Original Message-----
From: Graham Anderson [mailto:grahama1970@xxxxxxxxx]
Sent: Tuesday, August 07, 2007 3:34 PM
To: php-general
Subject:  ADODB Insert Question (Syntax)

Hi

What is the proper way to get the ADODB class to automatically add
quotes to the below sql ?
I'm guessing that the below fails because none of the variables get
quoted with the method, qstr.

$sql = "insert into email (to_name, to_email, from_name, from_email,
subject, message, timestamp, ip) ";
$sql .= "values ($to_name, $to_email, $from_name, $from_email,
$subject, $message, $time, $ip)";


I tried something like the below to no avail
$sql .= "values($conn->qstr($to_name), $conn->qstr
($to_email), .......)";


Is there an accepted way to place multiple $variables inside an ADODB
insert statement?

many thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-----End Original Message-----


Okay, I'm probably missing something, but why can't the values portion just
say:

"values ('$to_name', '$to_email', '$from_name',... etc.

hold on now. you might want to make sure and escape data before you just throw it into the query like that.

His method was just fine, but the problem is is that the $obj->method() thing wont work in a quoted string.

If he had E_NOTICE turned on, he would see the error.

what needs to happen is that he needs to break out of the double quotes and concat the string(s) and method calls together like this.

$sql .= "values(".$conn->qstr($to_name).", ".$conn->qstr($to_email).", .......)";


... with the single quotes around the variable names?


-- N/A





--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux