Re: Ever see a variable not resolve in a Query?

From: Date: Sat, 20 May 2000 05:22:01 +0000
Subject: Re: Ever see a variable not resolve in a Query?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-57@lists.php.net to get a copy of this message
On Fri, 19 May 2000, Lara Fabans wrote: > I couldn't find anything like this in the archives (or the FAQ) > > Here is my query: > $extopic4 = "INSERT into entries (CREATOR, CREATED, COMMENT, APPROVER, "; > $extopic4 .= "APPROVED, TITLE, ABSTRACT, BODY, ENT_TYPE, ABLOB, BOARDID) > VALUES"; > $extopic4 .= " ('$aoumem', '$today', > '$aorbit_comment_access', 'NULL', > 'NULL', "; > $extopic4 .= "'$orbit_msgboard_title', '$orbit_msgboard_description', > 'NULL', "; > $extopic4 .= "'Message','NULL', $boardid)"; When you define this query for $extopic4, it's including the -current- values of all the variables you're using. So when the bottom line, $extopic4 .= "'Message','NULL', $boardid)"; comes up, there isn't a value assigned to $boardid yet, so you get an empty string. I'd suggest moving the above lines down to just before mysql_query is called. HTH, Matt > I have numerous print statements (and I do query or die). So I know $boardid > is being set to an integer in the previous mysql_query. I pull the result > properly. > However, it will not resolve in this query. > > Here's where the queries get called: > // get the topicid > $mysql_result = mysql_query($extopic3, $dbh) or die("Query: > $extopic3<BR>\n" . mysql_error()); > $topicrec = mysql_fetch_array($mysql_result); > $topicid = $topicrec["ID"]; > // return boardid > $result = mysql_query($extopic2, $dbh) or die("Query: $extopic2<BR>\n" . > mysql_error()); > $boardid = mysql_insert_id($result); > print "<h2>board ID is $boardid</h2>"; > // putting everything else in its places > print "<h2>about to put the $boardid into $extopic4</h2>"; > $result3 = mysql_query($extopic4, $dbh) or die("Query: $extopic4<BR>\n" . > mysql_error());; > > > > And here's what shows up in my window: > board ID is 21 > about to put the 21 into INSERT into entries (CREATOR, CREATED, COMMENT, > APPROVER, APPROVED, TITLE, ABSTRACT, BODY, ENT_TYPE, ABLOB, BOARDID) VALUES > ('rjackson', 'FridayMay19, 2000', 'Member', 'NULL', > 'NULL', 'Lara\'s 21st > test', 'This is a test to put a board under an existing topic. Keeping > prefs the same.', 'NULL', 'Message','NULL', ) > Query: INSERT into entries (CREATOR, CREATED, COMMENT, APPROVER, APPROVED, > TITLE, ABSTRACT, BODY, ENT_TYPE, ABLOB, BOARDID) VALUES ('rjackson', > 'FridayMay19, 2000', 'Member', 'NULL', 'NULL', > 'Lara\'s 21st test', 'This > is a test to put a board under an existing topic. Keeping prefs the same.', > 'NULL', 'Message','NULL', ) > You have an error in your SQL syntax near ')' at line 1 > > Any thoughts would be greatly appreciated, > Thank you so much, > Lara

« previous php.db (#57) next »