I am having trouble getting one of my variable to be successfully inserted into my mySQL query. Here is the query string:
$strShipMethodInfo = "SELECT BAMMDD, BAYY, BAXXX, ORDNUM, SHPNUM, \"SHIPMENT METHOD\", \"SHIPMENT STATUS\" FROM SHPPMTHD WHERE BAMMDD = " . $BAMMDD . " AND BAYY = " . $BAYY . " AND BAXXX = " . $BAXXX . " AND SHPNUM = " . $arrShippingInfo[$x]['SHPNUM'] . " AND ORDNUM = '" . $ORDNUM . "' ORDER BY SHPNUM";
I am using $arrShippingInfo[$x]['SHPNUM']
in another query that is very similar, and it is putting the variable in that one. However, when I do it with this query, it comes back as blank. All the other values (BAMMDD
, BAYY
, BAXXX
, etc.) are successfully put in, but the variable for SHPNUM
does not get put in.
I have tried everything I can think of, thinking that it might be a quote in the wrong place, but I have been unsuccessful. Could anyone please help me figure this out? Thanks.
EDIT: I did a print_r
on the string, and it printed twice... once with the SHPNUM
correctly inserted and once with it blank. Turns out it was a logic error in the for loop I was using (I needed to run the query for each shipment in the order). <
somehow got changed to <=
so once I changed that it worked. Thank you everyone for your responses.