scott.stephan Posted July 28, 2009 Share Posted July 28, 2009 I have a function I pass an array to do some stuff with. Here's the array initialization, plus the clause giving me trouble: if($type == 'acknowledge' || $type == 'view'){ $table_name[0]="new_batch"; $table_name[1]="bol_new"; $table_name[2]="lots_new"; } bol_display($table_name, $curr_po_num); And here's what gives me a problem: $queryall="SELECT * FROM $T_NAMES[0] WHERE po_num='$curr_po_num'"; $result=mysql_query($queryall) or die(mysql_error()); And the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '] WHERE po_num='777MCLANE'' at line 1 If I change it to $queryall="SELECT * FROM '$T_NAMES[0]' WHERE po_num='$curr_po_num'"; , I get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''new_batch' WHERE po_num='777MCLANE'' at line 1 It looks like I'm getting an extra " ' " in there. Any idea where? What's my goof here? Link to comment https://forums.phpfreaks.com/topic/167808-solved-problem-using-an-array-value-in-a-sql-where-clause/ Share on other sites More sharing options...
scott.stephan Posted July 28, 2009 Author Share Posted July 28, 2009 Problem solved. It was a different, similar clause: $querybol="SELECT * FROM $T_NAMES[1]] WHERE po_num='$curr_po_num'"; Where I had an extra goofy bracket. I swear, I struggle with these things for like 40 minutes, post ot here and then solve it 30 seconds later. Is there some kind of ESP stuff going on? Link to comment https://forums.phpfreaks.com/topic/167808-solved-problem-using-an-array-value-in-a-sql-where-clause/#findComment-885014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.