sql select with php variable

Posted by user1572526 on Stack Overflow See other posts from Stack Overflow or by user1572526
Published on 2012-09-28T21:22:06Z Indexed on 2012/09/28 21:37 UTC
Read the original article Hit count: 167

Filed under:

I'm trying to print out a html-table from db-table 'dimensions'. I only want dimensions from the selected pipetype which I get from a dropdownbox. For now I just put in "Steel" manually. Steel has pipe_id = 2 in db-table 'pipes'.

I've run the first query in my db-tool and it returns 2 so there's nothing wrong there. The second query returns nothing. But when I manually set $wq = 2 (which I comment out below) it prints out the html-table perfectly. What am I doing wrong here?

$wq="SELECT pipe_id FROM pipes WHERE title_en = 'Steel'";
//$wq = '2';

$sql="SELECT * FROM dimensions WHERE  pipe_id = '".$wq."'";

© Stack Overflow or respective owner

Related posts about php