![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
When creating a query to select data from the Mysql database via phpadmin this works... ----------------------------- $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ')&& bok_adminkod< 2) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- However I'd like to make the 2 a variable. So I set $myvar to 2 as follows.... I tried ----------------------------- $myvar = 2; $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ')&& bok_adminkod< $myvar) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- But it does not find any records. What am I missing in the syntax? Any help greatly appreciated. Garry Jones Sweden |
#3
| |||
| |||
|
|
When creating a query to select data from the Mysql database via phpadmin this works... ----------------------------- $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ') && bok_adminkod < 2) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- However I'd like to make the 2 a variable. So I set $myvar to 2 as follows.... I tried ----------------------------- $myvar = 2; $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ') && bok_adminkod < $myvar) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- But it does not find any records. What am I missing in the syntax? |
#4
| |||
| |||
|
|
When creating a query to select data from the Mysql database via phpadmin this works... ----------------------------- $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ')&& bok_adminkod< 2) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- However I'd like to make the 2 a variable. So I set $myvar to 2 as follows.... I tried ----------------------------- $myvar = 2; $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ')&& bok_adminkod< $myvar) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- But it does not find any records. What am I missing in the syntax? Any help greatly appreciated. Garry Jones Sweden |
#5
| |||
| |||
|
|
i.e. $query="select a from b where id='%d'",$c); Sine %d will try and make $c an integer, even if it is a hackers string or whatever, it won't do too much damage. |
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Thanks for your help everyone. This bok_adminkod< '. $myvar .' did it... |
#8
| |||
| |||
|
|
Am 12.01.2011 17:31, schrieb The Natural Philosopher: i.e. $query="select a from b where id='%d'",$c); Sine %d will try and make $c an integer, even if it is a hackers string or whatever, it won't do too much damage. And since it's an integer, why would you want to enclose it with ticks in the query? Helmut habit ;-) |
#9
| |||
| |||
|
|
When creating a query to select data from the Mysql database via phpadmin this works... ----------------------------- $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ') && bok_adminkod < 2) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- However I'd like to make the 2 a variable. So I set $myvar to 2 as follows.... I tried ----------------------------- $myvar = 2; $paigntontb = 'SELECT * FROM ct_bok LEFT JOIN resmal ON (resmal.resmalid=ct_bok.resmalvalid) LEFT JOIN buss_plats ON (buss_plats.buss_req = ct_bok.bokbus) WHERE (resmalvalid IN (' . implode(', ', $items) . ') && bok_adminkod < $myvar) ORDER BY bokeft,bokfor,bokanmref'; $paigntontbd=mysql_query($paigntontb); ----------------------------- But it does not find any records. What am I missing in the syntax? |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |