Re: Inserting variables

From: Date: Tue, 09 Oct 2001 12:48:33 +0000
Subject: Re: Inserting variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70459@lists.php.net to get a copy of this message
"Rw" <roydallas61@nospamhotmail.com> wrote in message news:20011009111747.94889.qmail@pb1.pair.com... > I have a form which variables ($q1 and $q2) to a PHP script and the sql > statment is also passed as a hidden vriable called $sqlstatement > > When I set $sqlstatement = INSERT INTO tdefa8 VALUES ("$q1", "$q2", > "2001-10-09") > THEN it inserts "$q1" and "$q2" into the database - rather than their > assigned values > > When I set $sqlstatement = INSERT INTO tdefa8 VALUES ($q1, $q2, > "2001-10-09") > THEN it doesn't insert ANYTHING > > FYI: I execute the statemnet like this: > $query = "$sqlstatement"; > $result = MYSQL_QUERY($query); > > I even tried: $query = $sqlstatement; > > > Any ideas? Hey, Shouldn't the variables be wrapped with single quotes? $sqlstatement = "INSERT INTO tdefa8 VALUES ('$q1', '$q2', '2001-10-09')"; $result = @mysql_query($sqlstatement) // check for sql errors or die (mysql_error()); James

« previous php.general (#70459) next »